Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iommu/vt-d: Make sure IOMMUs are off when intel_iommu=off

When booting into a kexec kernel with intel_iommu=off, and
the previous kernel had intel_iommu=on, the IOMMU hardware
is still enabled and gets not disabled by the new kernel.

This causes the boot to fail because DMA is blocked by the
hardware. Disable the IOMMUs when we find it enabled in the
kexec kernel and boot with intel_iommu=off.

Signed-off-by: Joerg Roedel <jroedel@suse.de>

+17 -1
+17 -1
drivers/iommu/intel-iommu.c
··· 4730 4730 return 0; 4731 4731 } 4732 4732 4733 + static void intel_disable_iommus(void) 4734 + { 4735 + struct intel_iommu *iommu = NULL; 4736 + struct dmar_drhd_unit *drhd; 4737 + 4738 + for_each_iommu(iommu, drhd) 4739 + iommu_disable_translation(iommu); 4740 + } 4741 + 4733 4742 static inline struct intel_iommu *dev_to_intel_iommu(struct device *dev) 4734 4743 { 4735 4744 return container_of(dev, struct intel_iommu, iommu.dev); ··· 4849 4840 goto out_free_dmar; 4850 4841 } 4851 4842 4852 - if (no_iommu || dmar_disabled) 4843 + if (no_iommu || dmar_disabled) { 4844 + /* 4845 + * Make sure the IOMMUs are switched off, even when we 4846 + * boot into a kexec kernel and the previous kernel left 4847 + * them enabled 4848 + */ 4849 + intel_disable_iommus(); 4853 4850 goto out_free_dmar; 4851 + } 4854 4852 4855 4853 if (list_empty(&dmar_rmrr_units)) 4856 4854 pr_info("No RMRR found\n");