Skip to content

Commit c12b08e

Browse files
yuzhaogooglejoergroedel
authored andcommitted
iommu/amd: Fix amd_iommu=force_isolation
The parameter is still there but it's ignored. We need to check its value before deciding to go into passthrough mode for AMD IOMMU v2 capable device. We occasionally use this parameter to force v2 capable device into translation mode to debug memory corruption that we suspect is caused by DMA writes. To address the following comment from Joerg Roedel on the first version, v2 capability of device is completely ignored. > This breaks the iommu_v2 use-case, as it needs a direct mapping for the > devices that support it. And from Documentation/admin-guide/kernel-parameters.txt: This option does not override iommu=pt Fixes: aafd8ba ("iommu/amd: Implement add_device and remove_device") Signed-off-by: Yu Zhao <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 6f5086a commit c12b08e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/iommu/amd_iommu.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,14 @@ static int iommu_init_device(struct device *dev)
440440

441441
dev_data->alias = get_alias(dev);
442442

443-
if (dev_is_pci(dev) && pci_iommuv2_capable(to_pci_dev(dev))) {
443+
/*
444+
* By default we use passthrough mode for IOMMUv2 capable device.
445+
* But if amd_iommu=force_isolation is set (e.g. to debug DMA to
446+
* invalid address), we ignore the capability for the device so
447+
* it'll be forced to go into translation mode.
448+
*/
449+
if ((iommu_pass_through || !amd_iommu_force_isolation) &&
450+
dev_is_pci(dev) && pci_iommuv2_capable(to_pci_dev(dev))) {
444451
struct amd_iommu *iommu;
445452

446453
iommu = amd_iommu_rlookup_table[dev_data->devid];

0 commit comments

Comments
 (0)