From nobody Fri May 3 00:08:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549118859896814.7194905130399; Sat, 2 Feb 2019 06:47:39 -0800 (PST) Received: from localhost ([127.0.0.1]:43112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpwZx-0006FT-H0 for importer@patchew.org; Sat, 02 Feb 2019 09:47:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpwZ2-0005vV-Rc for qemu-devel@nongnu.org; Sat, 02 Feb 2019 09:46:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpwZ1-0000h7-VG for qemu-devel@nongnu.org; Sat, 02 Feb 2019 09:46:36 -0500 Received: from mout.gmx.net ([212.227.15.19]:43039) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gpwZ1-0000Ym-MR for qemu-devel@nongnu.org; Sat, 02 Feb 2019 09:46:35 -0500 Received: from localhost.localdomain ([89.71.135.231]) by mail.gmx.com (mrgmx001 [212.227.17.184]) with ESMTPSA (Nemesis) id 0LomuB-1hN5Zz1ovD-00gqoK; Sat, 02 Feb 2019 15:46:16 +0100 From: Kamil Rytarowski To: qemu-devel@nongnu.org Date: Sat, 2 Feb 2019 15:45:31 +0100 Message-Id: <20190202144531.5772-1-n54@gmx.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:QypoohU0+acVVJxoGUsbBxOyAClf5OqLAM+AHv9mIXi9m62N0L/ Z2Cp+/gYHdaCtp+HbpjT5UHJcQXj5seSCaF47EK4xWKDksd36VCzlTPqqwPFSX2ffLUH3nE ixuQ2DX/gOJqU/wf1/SUF6HBUyFxJd9Rm+il3vn+qcCobG4P8s1yJtq5YnE29FYjRwvt95K I7997qVVV5D61SjZbnXhw== X-UI-Out-Filterresults: notjunk:1;V03:K0:W71PMerefcc=:RhMgm8G6tGzi8EN8lopm0j B6plL11RgXydCwarCiqzhfMz7sY5EcxO8LeGuMHh0+gmamMNYPricQlxLVM3Tyb/ULWhPX0bD BeT8XY+a7ypwVvx0UBIBTcgzOCKl4a3jlVGqq0F4VkB73cj6ICupYFeLf4p7UFi+KRgui25+I 8fbJzWsyuIK+pytAIlYr9JJg3WPOWzeoX6Ae1jt6QZSMqLKYve45SLrjMe4O2SMqpZn7tOdXc 3PlZ9ph17nK/f/TZQd9mKs7Ss7AXPdxR2D719K22G7L9GgP2IFDrjOFd1ignvBdNNNtrEN4iK WFjQrhfOjIH2hYcoj653lwENvYL5KihL9Vbs4+Z8OFWwZRKZR4iaw9d6RivaWcXeJpF6dHTAu c81UZVkuVPuRf84IcV7eKqx6UtKnAk32auC3DU6WCtxUVeMyTVYr4ir8l58Avr3v2jZRqOfXc upDZot1BcmIAtthVmZkIfio63HBmGPCj6iInC0Pt/IrFES/r3ssKr2zp1pkgjrXRORtUlGr6e 3sbyA/ThY+Av0I4B2hZk6AEHjcvA4YXXrEhTvcj4wsqs9PWgFeVhF2KfMAwUlJA1lU5KliJBU 9nUxXdqk65J7p0u5OinyAAmwkxae7iH+gpnsLCnmVNSareseYkEMFKHBrwKjbw8taBft1QP9y 8lr58aX9lnnVoHlQjNFVfgsBRyo+CESuKVcxTmI7V7rq+9JtpIDI1Fil3XP5yIwCS2CICdC8o 4tNWJzUQ35N5cqcbf+nUm7AhpolOBZFZAb7IHUy2VvjhGnj7w/5vd4SQLFdo9Swx5FLGa/nKF uX+KWLaKrIRdSPeSSujrhIRe98uktz443XQgmYovRegiymfuJux9h5QdfdQgUhq9aeC1sef3A pvaQDoZfL4lHzfEOURaTHmveYONhiTtmJwke8xP2s= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.19 Subject: [Qemu-devel] [PATCH] target-i386: Enhance the stub for kvm_arch_get_supported_cpuid() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Kamil Rytarowski , pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 --- 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 e= xtension); kvm_vcpu_ioctl(cpu, KVM_ENABLE_CAP, &cap); \ }) =20 +#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); =20 =20 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 =20 bool kvm_hv_vpindex_settable(void) --=20 2.20.1