qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target-i386: Enhance the stub for kvm_arch_get_supported_cpuid()
@ 2019-02-02 14:45 Kamil Rytarowski
  2019-02-03 17:31 ` no-reply
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Kamil Rytarowski @ 2019-02-02 14:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, pbonzini, Kamil Rytarowski

This improves the commit:
"target-i386: Fix build by providing stub kvm_arch_get_supported_cpuid()"
r. 2140cfa51d59177815f5b82e94ac48fb24909aba

Clang/LLVM on NetBSD with enabled optimization cannot link
correct qemu program because of a missing symbol of
kvm_arch_get_supported_cpuid() in kvm-stubs.o used by executables.

There are more than a single one kvm-stub.c and several types
of possible programs such as bsd-user ones. the previous workaround
does not work reliably for all use-cases. Instead of reworking
the stubs and linking rules, move the workaround from a code that
depends on the __OPTIMIZE__ builtin compiler flag, build option (KVM),
compiler and arrangement of linking rules to a simple macro in a
shared header with all the users that defines fallback dummy
implementation, ignoring whether it is optimized out or not.

Signed-off-by: Kamil Rytarowski <n54@gmx.com>
---
 include/sysemu/kvm.h   | 13 +++++++++++++
 target/i386/kvm-stub.c | 10 ----------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index a6d1cd190f..93d3c0f0b3 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -459,8 +459,21 @@ int kvm_vm_check_extension(KVMState *s, unsigned int extension);
         kvm_vcpu_ioctl(cpu, KVM_ENABLE_CAP, &cap);                   \
     })
 
+#ifdef CONFIG_KVM
 uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
                                       uint32_t index, int reg);
+#else
+/*
+ * This function is only called inside conditionals which we
+ * rely on the compiler to optimize out when CONFIG_KVM is not
+ * defined.
+ */
+#define kvm_arch_get_supported_cpuid(a, b, c, d)                     \
+    ({                                                               \
+        abort();                                                     \
+        0;                                                           \
+    })
+#endif
 uint32_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index);
 
 
diff --git a/target/i386/kvm-stub.c b/target/i386/kvm-stub.c
index e7a673e5db..9ce8566700 100644
--- a/target/i386/kvm-stub.c
+++ b/target/i386/kvm-stub.c
@@ -29,16 +29,6 @@ bool kvm_enable_x2apic(void)
 {
     return false;
 }
-
-/* This function is only called inside conditionals which we
- * rely on the compiler to optimize out when CONFIG_KVM is not
- * defined.
- */
-uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
-                                      uint32_t index, int reg)
-{
-    abort();
-}
 #endif
 
 bool kvm_hv_vpindex_settable(void)
-- 
2.20.1

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

end of thread, other threads:[~2019-02-25  8:31 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-02 14:45 [Qemu-devel] [PATCH] target-i386: Enhance the stub for kvm_arch_get_supported_cpuid() Kamil Rytarowski
2019-02-03 17:31 ` no-reply
2019-02-14 18:43 ` Kamil Rytarowski
2019-02-14 18:44 ` Paolo Bonzini
2019-02-14 19:41   ` Kamil Rytarowski
2019-02-14 20:51     ` Paolo Bonzini
2019-02-14 23:38       ` Kamil Rytarowski
2019-02-20 11:59         ` Kamil Rytarowski
2019-02-20 17:29           ` Paolo Bonzini
2019-02-21  2:08             ` Kamil Rytarowski
2019-02-21 17:41               ` Paolo Bonzini
2019-02-25  6:26               ` Kamil Rytarowski
     [not found]                 ` <CABgObfb22erktrGeOArTvF=0YMG3W8vHQT1+s0p9iRAMa4BvMA@mail.gmail.com>
2019-02-25  8:31                   ` Kamil Rytarowski

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).