qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] amd_iommu: Fix kvm_enable_x2apic link error with clang in non-KVM builds
@ 2024-11-14 11:45 Sairaj Kodilkar
  2024-11-29 10:29 ` Philippe Mathieu-Daudé
  2024-11-29 11:23 ` Philippe Mathieu-Daudé
  0 siblings, 2 replies; 5+ messages in thread
From: Sairaj Kodilkar @ 2024-11-14 11:45 UTC (permalink / raw)
  To: qemu-devel
  Cc: pbonzini, Suravee.Suthikulpanit, Vasant.Hegde, Santosh Shukla,
	Phil Dennis-Jordan

Commit b12cb3819 (amd_iommu: Check APIC ID > 255 for XTSup) throws
linking error for the `kvm_enable_x2apic` when kvm is disabled
and Clang is used for compilation.

This issue comes up because Clang does not remove the function callsite
(kvm_enable_x2apic in this case) during optimization when if condition
have variable. Intel IOMMU driver solves this issue by creating separate
if condition for checking variables, which causes call site being
optimized away by virtue of `kvm_irqchip_is_split()` being defined as 0.
Implement same solution for the AMD driver.

Fixes: b12cb3819baf (amd_iommu: Check APIC ID > 255 for XTSup)
Signed-off-by: Sairaj Kodilkar <sarunkod@amd.com>
Signed-off-by: Santosh Shukla <santosh.shukla@amd.com>
Tested-by: Phil Dennis-Jordan <phil@philjordan.eu>
---
 hw/i386/amd_iommu.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index 13af7211e11d..af0f4da1f69e 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -1657,9 +1657,11 @@ static void amdvi_sysbus_realize(DeviceState *dev, Error **errp)
         error_report("AMD IOMMU with x2APIC confguration requires xtsup=on");
         exit(EXIT_FAILURE);
     }
-    if (s->xtsup && kvm_irqchip_is_split() && !kvm_enable_x2apic()) {
-        error_report("AMD IOMMU xtsup=on requires support on the KVM side");
-        exit(EXIT_FAILURE);
+    if (s->xtsup) {
+        if (kvm_irqchip_is_split() && !kvm_enable_x2apic()) {
+            error_report("AMD IOMMU xtsup=on requires support on the KVM side");
+            exit(EXIT_FAILURE);
+        }
     }
 
     pci_setup_iommu(bus, &amdvi_iommu_ops, s);
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-11-29 15:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-14 11:45 [PATCH] amd_iommu: Fix kvm_enable_x2apic link error with clang in non-KVM builds Sairaj Kodilkar
2024-11-29 10:29 ` Philippe Mathieu-Daudé
2024-11-29 15:51   ` Philippe Mathieu-Daudé
2024-11-29 15:51   ` Philippe Mathieu-Daudé
2024-11-29 11:23 ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).