Re: [PATCH] iommu/amd: Stop irq_remapping_select() matching when remapping is disabled

2021-01-05 Thread Will Deacon
On Tue, 05 Jan 2021 01:36:13 +, David Woodhouse wrote:
> The AMD IOMMU initialisation registers the IRQ remapping domain for
> each IOMMU before doing the final sanity check that every I/OAPIC is
> covered.
> 
> This means that the AMD irq_remapping_select() function gets invoked
> even when IRQ remapping has been disabled, eventually leading to a NULL
> pointer dereference in alloc_irq_table().
> 
> [...]

Applied to arm64 (for-next/iommu/fixes), thanks!

[1/1] iommu/amd: Stop irq_remapping_select() matching when remapping is disabled
  https://git.kernel.org/arm64/c/b34f10c2dc59

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev


[PATCH] iommu/amd: Stop irq_remapping_select() matching when remapping is disabled

2021-01-04 Thread David Woodhouse
From: David Woodhouse 

The AMD IOMMU initialisation registers the IRQ remapping domain for
each IOMMU before doing the final sanity check that every I/OAPIC is
covered.

This means that the AMD irq_remapping_select() function gets invoked
even when IRQ remapping has been disabled, eventually leading to a NULL
pointer dereference in alloc_irq_table().

Unfortunately, the IVRS isn't fully parsed early enough that the sanity
check can be done in time to registering the IRQ domain altogether.
Doing that would be nice, but is a larger and more error-prone task. The
simple fix is just for irq_remapping_select() to refuse to report a
match when IRQ remapping has disabled.

Link: https://lore.kernel.org/lkml/ed4be9b4-24ac-7128-c522-7ef359e81...@gmx.at
Fixes: a1a785b57242 ("iommu/amd: Implement select() method on remapping 
irqdomain")
Reported-by: Johnathan Smithinovic 
Signed-off-by: David Woodhouse 
---
 drivers/iommu/amd/iommu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 7e2c445a1fae..f0adbc48fd17 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -3854,6 +3854,9 @@ static int irq_remapping_select(struct irq_domain *d, 
struct irq_fwspec *fwspec,
struct amd_iommu *iommu;
int devid = -1;
 
+   if (!amd_iommu_irq_remap)
+   return 0;
+
if (x86_fwspec_is_ioapic(fwspec))
devid = get_ioapic_devid(fwspec->param[0]);
else if (x86_fwspec_is_hpet(fwspec))
-- 
2.29.2



smime.p7s
Description: S/MIME cryptographic signature