Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Sairaj Kodilkar <sarunkod@amd.com>
To: "Clément Mathieu--Drif" <clement.mathieu--drif@bull.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Alejandro Jimenez" <alejandro.j.jimenez@oracle.com>,
	"Ani Sinha" <anisinha@redhat.com>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Jason Wang" <jasowangio@gmail.com>,
	"Marcelo Tosatti" <mtosatti@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Sairaj Kodilkar" <sarunkod@amd.com>,
	"Yi Liu" <yi.l.liu@intel.com>,
	kvm@vger.kernel.org, qemu-devel@nongnu.org
Cc: <vasant.hegde@amd.com>, <suravee.suthikulpanit@amd.com>
Subject: [PATCH 1/8] amd_iommu: Assign ioapic_as only when interrupt remapping is supported.
Date: Wed, 14 Oct 2026 11:04:26 +0530	[thread overview]
Message-ID: <20261014053433.24564-2-sarunkod@amd.com> (raw)
In-Reply-To: <20261014053433.24564-1-sarunkod@amd.com>

When interrupt remapping is disabled (intremap=off), the IOAPIC should
use the system address space instead of the IOMMU address space.
Currently, the IOAPIC is unconditionally assigned to the IOMMU address
space, which causes IOAPIC-triggered interrupts to be incorrectly
translated by the IOMMU even when interrupt remapping is disabled.

Signed-off-by: Sairaj Kodilkar <sarunkod@amd.com>
---
 hw/i386/amd_iommu.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index 578c27ccbef6..614c7a131482 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -2733,8 +2733,16 @@ static void amdvi_sysbus_realize(DeviceState *dev, Error **errp)
     memory_region_add_subregion_overlap(&s->mr_sys, AMDVI_INT_ADDR_FIRST,
                                         &s->mr_ir, 1);
 
-    /* Pseudo address space under root PCI bus. */
-    x86ms->ioapic_as = amdvi_host_dma_iommu(bus, s, AMDVI_IOAPIC_SB_DEVID);
+    /**
+     * Pseudo address space under root PCI bus.
+     * The linux kernel disables the intremap when it cannot find IOAPIC under
+     * AMD IOMMU IVRS, hence create a ioapic_as with root bus even though AMD
+     * IOMMU is not serving devices attached to root bus.
+     */
+    if (x86_iommu_ir_supported(X86_IOMMU_DEVICE(s))) {
+        x86ms->ioapic_as = amdvi_host_dma_iommu(pcms->pcibus, s,
+                                                AMDVI_IOAPIC_SB_DEVID);
+    }
 
     if (kvm_enabled() && x86ms->apic_id_limit > 255 && !s->xtsup) {
         error_report("AMD IOMMU with x2APIC configuration requires xtsup=on");

base-commit: 562bae590f194fb590beb5c65da44fc35ab9f64a
-- 
2.34.1


  reply	other threads:[~2026-10-14  5:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14  5:34 [PATCH 0/8] amd_iommu: Allow IOMMU to attach on non system bus Sairaj Kodilkar
2026-10-14  5:34 ` Sairaj Kodilkar [this message]
2026-10-14  5:34 ` [PATCH 2/8] x86-iommu: Introduce x86_iommu_device_get() for x86-iommu retrieval Sairaj Kodilkar
2026-10-14  5:34 ` [PATCH 3/8] amd_iommu: Add support for get_x86_iommu callback Sairaj Kodilkar
2026-10-14  5:34 ` [PATCH 4/8] intel_iommu: " Sairaj Kodilkar
2026-10-14  9:57   ` Clément MATHIEU--DRIF
2026-10-14  5:34 ` [PATCH 5/8] i386/kvm: Use x86_iommu_device_get() for per-device IOMMU lookup Sairaj Kodilkar
2026-10-14  5:34 ` [PATCH 6/8] amd_iommu: Introduce root bus Sairaj Kodilkar
2026-10-14  5:34 ` [PATCH 7/8] acpi-build: Create PCI topology using amd iommu " Sairaj Kodilkar
2026-10-14  5:34 ` [PATCH 8/8] amd_iommu: Allow IOMMU to attachment on non-system (pcie.0) bus Sairaj Kodilkar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261014053433.24564-2-sarunkod@amd.com \
    --to=sarunkod@amd.com \
    --cc=alejandro.j.jimenez@oracle.com \
    --cc=anisinha@redhat.com \
    --cc=clement.mathieu--drif@bull.com \
    --cc=imammedo@redhat.com \
    --cc=jasowangio@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=vasant.hegde@amd.com \
    --cc=yi.l.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox