qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i386/kvm: Fix kvm_enable_x2apic link error in non-KVM builds
@ 2024-11-13 14:49 Phil Dennis-Jordan
  2024-11-13 18:06 ` Paolo Bonzini
  2024-11-13 18:11 ` Paolo Bonzini
  0 siblings, 2 replies; 11+ messages in thread
From: Phil Dennis-Jordan @ 2024-11-13 14:49 UTC (permalink / raw)
  To: qemu-devel, kvm, mtosatti, pbonzini
  Cc: santosh.shukla, suravee.suthikulpanit, Phil Dennis-Jordan

It appears that existing call sites for the kvm_enable_x2apic()
function rely on the compiler eliding the calls during optimisation
when building with KVM disabled, or on platforms other than Linux,
where that function is declared but not defined.

This fragile reliance recently broke down when commit b12cb38 added
a new call site which apparently failed to be optimised away when
building QEMU on macOS with clang, resulting in a link error.

This change moves the function declaration into the existing
#if CONFIG_KVM
block in the same header file, while the corresponding
#else
block now #defines the symbol as 0, same as for various other
KVM-specific query functions.

Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
---
 target/i386/kvm/kvm_i386.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h
index 9de9c0d3038..7ce47388d90 100644
--- a/target/i386/kvm/kvm_i386.h
+++ b/target/i386/kvm/kvm_i386.h
@@ -21,17 +21,18 @@
     (kvm_irqchip_in_kernel() && !kvm_irqchip_is_split())
 #define kvm_ioapic_in_kernel() \
     (kvm_irqchip_in_kernel() && !kvm_irqchip_is_split())
+bool kvm_enable_x2apic(void);
 
 #else
 
 #define kvm_pit_in_kernel()      0
 #define kvm_pic_in_kernel()      0
 #define kvm_ioapic_in_kernel()   0
+#define kvm_enable_x2apic()      0
 
 #endif  /* CONFIG_KVM */
 
 bool kvm_has_smm(void);
-bool kvm_enable_x2apic(void);
 bool kvm_hv_vpindex_settable(void);
 bool kvm_enable_hypercall(uint64_t enable_mask);
 
-- 
2.39.3 (Apple Git-145)



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

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

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-13 14:49 [PATCH] i386/kvm: Fix kvm_enable_x2apic link error in non-KVM builds Phil Dennis-Jordan
2024-11-13 18:06 ` Paolo Bonzini
2024-11-13 18:14   ` Phil Dennis-Jordan
2024-11-13 18:11 ` Paolo Bonzini
2024-11-13 18:25   ` Shukla, Santosh
2024-11-13 18:39     ` Paolo Bonzini
2024-11-13 18:40       ` Shukla, Santosh
2024-11-28 16:38       ` Phil Dennis-Jordan
2024-11-28 16:46         ` Philippe Mathieu-Daudé
2024-11-28 19:06           ` Phil Dennis-Jordan
2024-11-29 10:59             ` 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).