Skip to content

Commit 387caf0

Browse files
AdrianHuangjoergroedel
authored andcommitted
iommu/amd: Treat per-device exclusion ranges as r/w unity-mapped regions
Some buggy BIOSes might define multiple exclusion ranges of the IVMD entries which are associated with the same IOMMU hardware. This leads to the overwritten exclusion range (exclusion_start and exclusion_length members) in set_device_exclusion_range(). Here is a real case: When attaching two Broadcom RAID controllers to a server, the first one reports the failure during booting (the disks connecting to the RAID controller cannot be detected). This patch prevents the issue by treating per-device exclusion ranges as r/w unity-mapped regions. Discussion: * https://lists.linuxfoundation.org/pipermail/iommu/2019-November/040140.html Suggested-by: Joerg Roedel <[email protected]> Signed-off-by: Adrian Huang <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 46cf053 commit 387caf0

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/iommu/amd_iommu_init.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
#define IVHD_FLAG_ISOC_EN_MASK 0x08
7272

7373
#define IVMD_FLAG_EXCL_RANGE 0x08
74+
#define IVMD_FLAG_IW 0x04
75+
#define IVMD_FLAG_IR 0x02
7476
#define IVMD_FLAG_UNITY_MAP 0x01
7577

7678
#define ACPI_DEVFLAG_INITPASS 0x01
@@ -1121,16 +1123,14 @@ static void __init set_device_exclusion_range(u16 devid, struct ivmd_header *m)
11211123
if (!(m->flags & IVMD_FLAG_EXCL_RANGE))
11221124
return;
11231125

1124-
if (iommu) {
1125-
/*
1126-
* We only can configure exclusion ranges per IOMMU, not
1127-
* per device. But we can enable the exclusion range per
1128-
* device. This is done here
1129-
*/
1130-
set_dev_entry_bit(devid, DEV_ENTRY_EX);
1131-
iommu->exclusion_start = m->range_start;
1132-
iommu->exclusion_length = m->range_length;
1133-
}
1126+
/*
1127+
* Treat per-device exclusion ranges as r/w unity-mapped regions
1128+
* since some buggy BIOSes might lead to the overwritten exclusion
1129+
* range (exclusion_start and exclusion_length members). This
1130+
* happens when there are multiple exclusion ranges (IVMD entries)
1131+
* defined in ACPI table.
1132+
*/
1133+
m->flags = (IVMD_FLAG_IW | IVMD_FLAG_IR | IVMD_FLAG_UNITY_MAP);
11341134
}
11351135

11361136
/*

0 commit comments

Comments
 (0)