Commit 2eeec3ea authored by Joerg Roedel's avatar Joerg Roedel Committed by Kleber Sacilotto de Souza

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

BugLink: https://launchpad.net/bugs/1810328

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: default avatarJoerg Roedel <jroedel@suse.de>
(backported from commit 161b28aa)
[gpiccoli: context adjustment]
Signed-off-by: default avatarGuilherme G. Piccoli <gpiccoli@canonical.com>
Acked-by: default avatarStefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarKleber Souza <kleber.souza@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent bd91917a
...@@ -4648,6 +4648,15 @@ const struct attribute_group *intel_iommu_groups[] = { ...@@ -4648,6 +4648,15 @@ const struct attribute_group *intel_iommu_groups[] = {
NULL, NULL,
}; };
static void intel_disable_iommus(void)
{
struct intel_iommu *iommu = NULL;
struct dmar_drhd_unit *drhd;
for_each_iommu(iommu, drhd)
iommu_disable_translation(iommu);
}
int __init intel_iommu_init(void) int __init intel_iommu_init(void)
{ {
int ret = -ENODEV; int ret = -ENODEV;
...@@ -4676,8 +4685,15 @@ int __init intel_iommu_init(void) ...@@ -4676,8 +4685,15 @@ int __init intel_iommu_init(void)
goto out_free_dmar; goto out_free_dmar;
} }
if (no_iommu || dmar_disabled) if (no_iommu || dmar_disabled) {
/*
* Make sure the IOMMUs are switched off, even when we
* boot into a kexec kernel and the previous kernel left
* them enabled
*/
intel_disable_iommus();
goto out_free_dmar; goto out_free_dmar;
}
if (list_empty(&dmar_rmrr_units)) if (list_empty(&dmar_rmrr_units))
pr_info("No RMRR found\n"); pr_info("No RMRR found\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment