]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/amd: Fix premature break in init_iommu_one()
authorVasant Hegde <vasant.hegde@amd.com>
Sun, 17 May 2026 12:29:25 +0000 (12:29 +0000)
committerJoerg Roedel <joerg.roedel@amd.com>
Thu, 28 May 2026 07:28:58 +0000 (09:28 +0200)
In init_iommu_one(), when processing IOMMU EFR attributes, the code checks
whether GASUP is enabled. If GASUP is not enabled, the code falls back to
legacy guest IR mode and then breaks out of the switch statement.

This break incorrectly skips the subsequent initialization steps that
follow the GASUP check. These initializations are independent of GASUP
support and must always be performed.

Fix this by replacing the early break with a conditional else block,
ensuring that the XTSUP check is only skipped when GASUP is not available.

Fixes: a44092e326d4 ("iommu/amd: Use IVHD EFR for early initialization of IOMMU features")
Reported-by: Sudheer Dantuluri <dantuluris@google.com>
Tested-by: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
drivers/iommu/amd/init.c

index 16073b5614b9896478e3406362d76559e1ae089e..a7dfbd5158632673fb21f2c2c9f74cd3f2b2d33c 100644 (file)
@@ -1917,12 +1917,11 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h,
                /* XT and GAM require GA mode. */
                if ((h->efr_reg & (0x1 << IOMMU_EFR_GASUP_SHIFT)) == 0) {
                        amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY;
-                       break;
+               } else {
+                       if (h->efr_reg & BIT(IOMMU_EFR_XTSUP_SHIFT))
+                               amd_iommu_xt_mode = IRQ_REMAP_X2APIC_MODE;
                }
 
-               if (h->efr_reg & BIT(IOMMU_EFR_XTSUP_SHIFT))
-                       amd_iommu_xt_mode = IRQ_REMAP_X2APIC_MODE;
-
                if (h->efr_attr & BIT(IOMMU_IVHD_ATTR_HATDIS_SHIFT)) {
                        pr_warn_once("Host Address Translation is not supported.\n");
                        amd_iommu_hatdis = true;