iommu/vt-d: patches for v5.6 - 2nd wave
Hi Joerg,
Below patches have been piled up for v5.6 since v5.5-rc3. They are mostly misc changes and cleanups.
- Instead of aborting DMAR processing, mark firmware tainted if any RMRRs fail sanity check.
- Check host bridge type correctly.
- Allow devices with RMRRs to use identity domain.
- Remove duplicated default identity domain treatment.
Please consider them for the iommu/vt-d branch.
Best regards,
-baolu
Barret Rhoden (2):
iommu/vt-d: Mark firmware tainted if RMRR fails sanity check iommu/vt-d: Add RMRR base and end addresses sanity check
Lu Baolu (2):
iommu/vt-d: Allow devices with RMRRs to use identity domain iommu/vt-d: Unnecessary to handle default identity domain
jimyan (1):
iommu/vt-d: Don't reject Host Bridge due to scope mismatch
drivers/iommu/dmar.c | 2 +- drivers/iommu/intel-iommu.c | 47 ++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 25 deletions(-)
Signature · 6 lines
2.17.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH 1/5 iommu/vt-d: Don't reject Host Bridge due to scope mismatch
From: jimyan <[email protected]>
On a system with two host bridges(0000:00:00.0,0000:80:00.0), iommu initialization fails with
DMAR: Device scope type does not match for 0000:80:00.0
This is because the DMAR table reports this device as having scope 2 (ACPI_DMAR_SCOPE_TYPE_BRIDGE):
but the device has a type 0 PCI header:
80:00.0 Class 0600: Device 8086:2020 (rev 06) 00: 86 80 20 20 47 05 10 00 06 00 00 06 10 00 00 00 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20: 00 00 00 00 00 00 00 00 00 00 00 00 86 80 00 00 30: 00 00 00 00 90 00 00 00 00 00 00 00 00 01 00 00
VT-d works perfectly on this system, so there's no reason to bail out on initialization due to this apparent scope mismatch. Add the class 0x06 ("PCI_BASE_CLASS_BRIDGE") as a heuristic for allowing DMAR initialization for non-bridge PCI devices listed with scope bridge.
--- drivers/iommu/dmar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/dmar.c +1 -1
@@ -244,7 +244,7 @@ int dmar_insert_dev_scope(struct dmar_pci_notify_info *info, info->dev->hdr_type != PCI_HEADER_TYPE_NORMAL) || (scope->entry_type == ACPI_DMAR_SCOPE_TYPE_BRIDGE && (info->dev->hdr_type == PCI_HEADER_TYPE_NORMAL && - info->dev->class >> 8 != PCI_CLASS_BRIDGE_OTHER))) { + info->dev->class >> 16 != PCI_BASE_CLASS_BRIDGE))) {pr_warn ("Device scope type does not match for %s\n" ,pci_name (info->dev));return -EINVAL ;
Signature · 6 lines
2.17.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH 2/5 iommu/vt-d: Mark firmware tainted if RMRR fails sanity check
In reply to Lu BaoluFrom: Barret Rhoden <[email protected]>
RMRR entries describe memory regions that are DMA targets for devices outside the kernel's control.
RMRR entries that fail the sanity check are pointing to regions of memory that the firmware did not tell the kernel are reserved or otherwise should not be used.
Instead of aborting DMAR processing, this commit marks the firmware as tainted. These RMRRs will still be identity mapped, otherwise, some devices, e.x. graphic devices, will not work during boot.
--- drivers/iommu/intel-iommu.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/iommu/intel-iommu.c +8 -4
@@ -4458,12 +4458,16 @@ int __init dmar_parse_one_rmrr(struct acpi_dmar_header *header, void *arg) {struct acpi_dmar_reserved_memory *rmrr;struct dmar_rmrr_unit *rmrru; -int ret; rmrr = (struct acpi_dmar_reserved_memory *)header; - ret =arch_rmrr_sanity_check (rmrr); -if (ret) -return ret; +if (arch_rmrr_sanity_check (rmrr)) +WARN_TAINT (1 ,TAINT_FIRMWARE_WORKAROUND , +"Your BIOS is broken; bad RMRR [%#018Lx-%#018Lx]\n" +"BIOS vendor: %s; Ver: %s; Product Version: %s\n" , + rmrr->base_address, rmrr->end_address, +dmi_get_system_info (DMI_BIOS_VENDOR ), +dmi_get_system_info (DMI_BIOS_VERSION ), +dmi_get_system_info (DMI_PRODUCT_VERSION )); rmrru =kzalloc (sizeof (*rmrru),GFP_KERNEL );if (!rmrru)
Signature · 6 lines
2.17.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH 4/5 iommu/vt-d: Allow devices with RMRRs to use identity domain
In reply to Lu BaoluSince commit ea2447f700cab ("intel-iommu: Prevent devices with RMRRs from being placed into SI Domain"), the Intel IOMMU driver doesn't allow any devices with RMRR locked to use the identity domain. This was added to to fix the issue where the RMRR info for devices being placed in and out of the identity domain gets lost. This identity maps all RMRRs when setting up the identity domain, so that devices with RMRRs could also use it.
--- drivers/iommu/intel-iommu.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/iommu/intel-iommu.c +2 -13
@@ -2893,10 +2893,8 @@ static int __init si_domain_init(int hw) }/* -* Normally we use DMA domains for devices which have RMRRs. But we -* loose this requirement for graphic and usb devices. Identity map -* the RMRRs for graphic and USB devices so that they could use the -* si_domain. +* Identity map the RMRRs so that devices with RMRRs could also use +* the si_domain. */ for_each_rmrr_units (rmrr) { for_each_active_dev_scope(rmrr->devices, rmrr->devices_cnt,
@@ -2904,9 +2902,6 @@ static int __init si_domain_init(int hw)unsigned long long start = rmrr->base_address;unsigned long long end = rmrr->end_address; -if (device_is_rmrr_locked (dev)) -continue ; -if (WARN_ON (end < start || end >>agaw_to_width (si_domain->agaw)))continue ;
@@ -3045,9 +3040,6 @@ static int device_def_domain_type(struct device *dev)if (dev_is_pci (dev)) {struct pci_dev *pdev =to_pci_dev (dev); -if (device_is_rmrr_locked (dev)) -return IOMMU_DOMAIN_DMA ; -/* * Prevent any device marked as untrusted from getting * placed into the statically identity mapping domain.
@@ -3085,9 +3077,6 @@ static int device_def_domain_type(struct device *dev)return IOMMU_DOMAIN_DMA ; }else if (pci_pcie_type (pdev) ==PCI_EXP_TYPE_PCI_BRIDGE )return IOMMU_DOMAIN_DMA ; - }else { -if (device_has_rmrr (dev)) -return IOMMU_DOMAIN_DMA ; } return (iommu_identity_mapping & IDENTMAP_ALL) ?
Signature · 6 lines
2.17.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH 3/5 iommu/vt-d: Add RMRR base and end addresses sanity check
In reply to Lu BaoluFrom: Barret Rhoden <[email protected]>
The VT-d spec specifies requirements for the RMRR entries base and end (called 'Limit' in the docs) addresses.
This commit will cause the DMAR processing to mark the firmware as tainted if any RMRR entries that do not meet these requirements.
--- drivers/iommu/intel-iommu.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +12 -1
@@ -4454,13 +4454,24 @@ static void __init init_iommu_pm_ops(void)static inline void init_iommu_pm_ops (void ) {}#endif /* CONFIG_PM */ +static int rmrr_sanity_check (struct acpi_dmar_reserved_memory *rmrr) +{ +if (!IS_ALIGNED (rmrr->base_address,PAGE_SIZE ) || + !IS_ALIGNED (rmrr->end_address +1 ,PAGE_SIZE ) || + rmrr->end_address <= rmrr->base_address || +arch_rmrr_sanity_check (rmrr)) +return -EINVAL ; + +return 0 ; +} +int __init dmar_parse_one_rmrr (struct acpi_dmar_header *header,void *arg) {struct acpi_dmar_reserved_memory *rmrr;struct dmar_rmrr_unit *rmrru; rmrr = (struct acpi_dmar_reserved_memory *)header; -if (arch_rmrr_sanity_check (rmrr)) +if (rmrr_sanity_check (rmrr)) WARN_TAINT(1, TAINT_FIRMWARE_WORKAROUND, "Your BIOS is broken; bad RMRR [%#018Lx-%#018Lx]\n" "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
Signature · 6 lines
2.17.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH 5/5 iommu/vt-d: Unnecessary to handle default identity domain
In reply to Lu BaoluThe iommu default domain framework has been designed to take care of setting identity default domain type. It's unnecessary to handle this again in the VT-d driver. Hence, remove it.
--- drivers/iommu/intel-iommu.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/iommu/intel-iommu.c +2 -7
@@ -387,7 +387,6 @@ static int intel_iommu_superpage = 1;static int iommu_identity_mapping;static int intel_no_bounce; -#define IDENTMAP_ALL 1#define IDENTMAP_GFX 2#define IDENTMAP_AZALIA 4
@@ -3079,8 +3078,7 @@ static int device_def_domain_type(struct device *dev)return IOMMU_DOMAIN_DMA ; } -return (iommu_identity_mapping &IDENTMAP_ALL ) ? -IOMMU_DOMAIN_IDENTITY :0 ; +return 0 ; }static void intel_iommu_init_qi (struct intel_iommu *iommu)
@@ -3424,9 +3422,6 @@ static int __init init_dmars(void) iommu->flush.flush_iotlb (iommu,0 ,0 ,0 ,DMA_TLB_GLOBAL_FLUSH ); } -if (iommu_default_passthrough ()) - iommu_identity_mapping |=IDENTMAP_ALL ; -#ifdef CONFIG_INTEL_IOMMU_BROKEN_GFX_WA dmar_map_gfx =0 ;#endif
@@ -5038,7 +5033,7 @@ static int __init platform_optin_force_iommu(void)* map for all devices except those marked as being untrusted. */ if (dmar_disabled) - iommu_identity_mapping |=IDENTMAP_ALL ; +iommu_set_default_passthrough (false); dmar_disabled =0 ; no_iommu =0 ;
Signature · 6 lines
2.17.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Joerg Roedel
maintainerQuoted 8 lines · Lu Baolu
Barret Rhoden (2):
iommu/vt-d: Mark firmware tainted if RMRR fails sanity check iommu/vt-d: Add RMRR base and end addresses sanity checkLu Baolu (2):
iommu/vt-d: Allow devices with RMRRs to use identity domain iommu/vt-d: Unnecessary to handle default identity domain
Quoted 6 lines
jimyan (1):
iommu/vt-d: Don't reject Host Bridge due to scope mismatchdrivers/iommu/dmar.c | 2 +- drivers/iommu/intel-iommu.c | 47 ++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 25 deletions(-)
All queued to the x86/vt-d branch, thanks.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu