lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Sat, 25 May 2019 13:41:26 +0800 From: Lu Baolu <baolu.lu@...ux.intel.com> To: David Woodhouse <dwmw2@...radead.org>, Joerg Roedel <joro@...tes.org> Cc: ashok.raj@...el.com, jacob.jun.pan@...el.com, kevin.tian@...el.com, jamessewart@...sta.com, tmurphy@...sta.com, dima@...sta.com, sai.praneeth.prakhya@...el.com, iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org, Lu Baolu <baolu.lu@...ux.intel.com> Subject: [PATCH v4 05/15] iommu/vt-d: Add device_def_domain_type() helper This helper returns the default domain type that the device requires. Signed-off-by: Lu Baolu <baolu.lu@...ux.intel.com> --- drivers/iommu/intel-iommu.c | 40 +++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index bac226dc8360..e1663af4e01b 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -2958,29 +2958,37 @@ static bool device_is_rmrr_locked(struct device *dev) return true; } -static int iommu_should_identity_map(struct device *dev, int startup) +/* + * Return the required default domain type for a specific device. + * + * @dev: the device in query + * @startup: true if this is during early boot + * + * Returns: + * - IOMMU_DOMAIN_DMA: device requires a dynamic mapping domain + * - IOMMU_DOMAIN_IDENTITY: device requires an identical mapping domain + * - 0: both identity and dynamic domains work for this device + */ +static int device_def_domain_type(struct device *dev, int startup) { if (dev_is_pci(dev)) { struct pci_dev *pdev = to_pci_dev(dev); if (device_is_rmrr_locked(dev)) - return 0; + return IOMMU_DOMAIN_DMA; /* * Prevent any device marked as untrusted from getting * placed into the statically identity mapping domain. */ if (pdev->untrusted) - return 0; + return IOMMU_DOMAIN_DMA; if ((iommu_identity_mapping & IDENTMAP_AZALIA) && IS_AZALIA(pdev)) - return 1; + return IOMMU_DOMAIN_IDENTITY; if ((iommu_identity_mapping & IDENTMAP_GFX) && IS_GFX_DEVICE(pdev)) - return 1; - - if (!(iommu_identity_mapping & IDENTMAP_ALL)) - return 0; + return IOMMU_DOMAIN_IDENTITY; /* * We want to start off with all devices in the 1:1 domain, and @@ -3001,14 +3009,14 @@ static int iommu_should_identity_map(struct device *dev, int startup) */ if (!pci_is_pcie(pdev)) { if (!pci_is_root_bus(pdev->bus)) - return 0; + return IOMMU_DOMAIN_DMA; if (pdev->class >> 8 == PCI_CLASS_BRIDGE_PCI) - return 0; + return IOMMU_DOMAIN_DMA; } else if (pci_pcie_type(pdev) == PCI_EXP_TYPE_PCI_BRIDGE) - return 0; + return IOMMU_DOMAIN_DMA; } else { if (device_has_rmrr(dev)) - return 0; + return IOMMU_DOMAIN_DMA; } /* @@ -3030,7 +3038,13 @@ static int iommu_should_identity_map(struct device *dev, int startup) return dma_mask >= dma_get_required_mask(dev); } - return 1; + return (iommu_identity_mapping & IDENTMAP_ALL) ? + IOMMU_DOMAIN_IDENTITY : 0; +} + +static inline int iommu_should_identity_map(struct device *dev, int startup) +{ + return device_def_domain_type(dev, startup) == IOMMU_DOMAIN_IDENTITY; } static int __init dev_prepare_static_identity_mapping(struct device *dev, int hw) -- 2.17.1
Powered by blists - more mailing lists