iommu/vt-d: Make sure IOMMUs are off when intel_iommu=off
Joerg Roedel
maintainerPATCH 1/1 iommu/vt-d: Make sure IOMMUs are off when intel_iommu=off
From: Joerg Roedel <[email protected]>
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.
--- drivers/iommu/intel-iommu.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +17 -1
@@ -4730,6 +4730,15 @@ static int intel_iommu_cpu_dead(unsigned int cpu)return 0 ; } +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); +} +static inline struct intel_iommu *dev_to_intel_iommu (struct device *dev) { return container_of(dev, struct intel_iommu, iommu.dev);
@@ -4840,8 +4849,15 @@ int __init intel_iommu_init(void) 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; + }if (list_empty (&dmar_rmrr_units))pr_info ("No RMRR found\n" );
Signature · 1 line
1.9.1
Quoted 20 lines · On Wed, 29 Mar 2017 17:00:39 +0200 Joerg Roedel <[email protected]> wrote:
From: Joerg Roedel <[email protected]>
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 <[email protected]>--- drivers/iommu/intel-iommu.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)drivers/iommu/intel-iommu.c +0
-0
drivers/iommu/intel-iommu.c static int intel_iommu_cpu_dead(unsigned int · line 4739
Quoted 10 lines
drivers/iommu/intel-iommu.c +7
-0@@ -4730,6 +4730,15 @@ static int intel_iommu_cpu_dead(unsigned int cpu) return 0; } +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);
should we also disable IR here? i.e.iommu_disable_irq_remapping(iommu);
Quoted 16 lines
drivers/iommu/intel-iommu.c +5
-1+} +static inline struct intel_iommu *dev_to_intel_iommu (struct device *dev) { return container_of(dev, struct intel_iommu, iommu.dev);@@ -4840,8 +4849,15 @@ int __init intel_iommu_init(void) goto out_free_dmar; } -if (no_iommu || dmar_disabled) +if (no_iommu || dmar_disabled) { +/* +* Make sure the IOMMUs are switched off, even when we
drivers/iommu/intel-iommu.c +1
-0+* boot into a kexec kernel and the previous kernel left
drivers/iommu/intel-iommu.c int __init intel_iommu_init(void) · line 4863
Quoted 8 lines
drivers/iommu/intel-iommu.c +4
-0+* them enabled +*/ +intel_disable_iommus (); goto out_free_dmar; + }if (list_empty (&dmar_rmrr_units))pr_info ("No RMRR found\n" );
[Jacob Pan]
Quoted 12 lines · Jacob Pan
drivers/iommu/intel-iommu.c static int intel_iommu_cpu_dead(unsigned int cpu) · line 4739
Quoted 7 lines · On Wed, 29 Mar 2017 17:00:39 +0200 Joerg Roedel…
drivers/iommu/intel-iommu.c +7
-0+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);should we also disable IR here? i.e.
iommu_disable_irq_remapping(iommu);
No, irq remapping depends on another parameter (intremap=off) and needs to be handled seperatly. I already looked at it and this needs to be part of a larger effort as it required changes in code-paths that are shared between Intel and AMD IOMMU drivers.
Joerg
Hi Joerg,
Do you plan to merge this one as urgent?
There's bug created about this issue on rhel, it would be great if it can be put in next or merged so that we can back port it.
Thanks
Baoquan
Quoted 59 lines · Joerg Roedel
From: Joerg Roedel <[email protected]>
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 <[email protected]>--- drivers/iommu/intel-iommu.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)drivers/iommu/intel-iommu.c +17
-1@@ -4730,6 +4730,15 @@ static int intel_iommu_cpu_dead(unsigned int cpu)return 0 ; } +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); +} +static inline struct intel_iommu *dev_to_intel_iommu (struct device *dev) { return container_of(dev, struct intel_iommu, iommu.dev);@@ -4840,8 +4849,15 @@ int __init intel_iommu_init(void) 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; + }if (list_empty (&dmar_rmrr_units))pr_info ("No RMRR found\n" );Signature · 6 lines
1.9.1 _______________________________________________ iommu mailing list iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Joerg Roedel
maintainerHi Baoquan,
Quoted 4 lines · Baoquan He
Do you plan to merge this one as urgent?
There's bug created about this issue on rhel, it would be great if it can be put in next or merged so that we can back port it.
No, I am not sending this for v4.11, because this issue existed forever and is no regression. I queued it for v4.12 and the commit-id in the iommu-tree will be the same as upstream, if you need that for your backport.
Joerg
Quoted 5 lines · Joerg Roedel
Hi Baoquan,
Quoted 2 lines · Baoquan He
Do you plan to merge this one as urgent?
Quoted 7 lines
Quoted 2 lines
There's bug created about this issue on rhel, it would be great if it can be put in next or merged so that we can back port it.
No, I am not sending this for v4.11, because this issue existed forever and is no regression. I queued it for v4.12 and the commit-id in the iommu-tree will be the same as upstream, if you need that for your backport.
Yeah, agree. The commit-id should be enough. Thanks a lot!