Skip to content

Commit b34f10c

Browse files
dwmw2willdeacon
authored andcommitted
iommu/amd: Stop irq_remapping_select() matching when remapping is disabled
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-7ef359e8185d@gmx.at Fixes: a1a785b ("iommu/amd: Implement select() method on remapping irqdomain") Reported-by: Johnathan Smithinovic <johnathan.smithinovic@gmx.at> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Link: https://lore.kernel.org/r/04bbe8bca87f81a3cfa93ec4299e53f47e00e5b3.camel@infradead.org Signed-off-by: Will Deacon <will@kernel.org>
1 parent 12bc457 commit b34f10c

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/iommu/amd/iommu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3854,6 +3854,9 @@ static int irq_remapping_select(struct irq_domain *d, struct irq_fwspec *fwspec,
38543854
struct amd_iommu *iommu;
38553855
int devid = -1;
38563856

3857+
if (!amd_iommu_irq_remap)
3858+
return 0;
3859+
38573860
if (x86_fwspec_is_ioapic(fwspec))
38583861
devid = get_ioapic_devid(fwspec->param[0]);
38593862
else if (x86_fwspec_is_hpet(fwspec))

0 commit comments

Comments
 (0)