Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ed6a540 authored by David Woodhouse's avatar David Woodhouse
Browse files

iommu/vt-d: Fix passthrough mode with translation-disabled devices



When we use 'intel_iommu=igfx_off' to disable translation for the
graphics, and when we discover that the BIOS has misconfigured the DMAR
setup for I/OAT, we use a special DUMMY_DEVICE_DOMAIN_INFO value in
dev->archdata.iommu to indicate that translation is disabled.

With passthrough mode, we were attempting to dereference that as a
normal pointer to a struct device_domain_info when setting up an
identity mapping for the affected device.

This fixes the problem by making device_to_iommu() explicitly check for
the special value and indicate that no IOMMU was found to handle the
devices in question.

Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
Cc: stable@vger.kernel.org (which means you can pick up 18436afd now too)
parent b787f68c
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -696,6 +696,11 @@ static inline struct context_entry *iommu_context_addr(struct intel_iommu *iommu
	return &context[devfn];
	return &context[devfn];
}
}


static int iommu_dummy(struct device *dev)
{
	return dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO;
}

static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn)
static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn)
{
{
	struct dmar_drhd_unit *drhd = NULL;
	struct dmar_drhd_unit *drhd = NULL;
@@ -705,6 +710,9 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
	u16 segment = 0;
	u16 segment = 0;
	int i;
	int i;


	if (iommu_dummy(dev))
		return NULL;

	if (dev_is_pci(dev)) {
	if (dev_is_pci(dev)) {
		pdev = to_pci_dev(dev);
		pdev = to_pci_dev(dev);
		segment = pci_domain_nr(pdev->bus);
		segment = pci_domain_nr(pdev->bus);
@@ -2969,11 +2977,6 @@ static inline struct dmar_domain *get_valid_domain_for_dev(struct device *dev)
	return __get_valid_domain_for_dev(dev);
	return __get_valid_domain_for_dev(dev);
}
}


static int iommu_dummy(struct device *dev)
{
	return dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO;
}

/* Check if the dev needs to go through non-identity map and unmap process.*/
/* Check if the dev needs to go through non-identity map and unmap process.*/
static int iommu_no_mapping(struct device *dev)
static int iommu_no_mapping(struct device *dev)
{
{