From patchwork Sat Feb 2 14:45:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamil Rytarowski X-Patchwork-Id: 10794317 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B317B91E for ; Sat, 2 Feb 2019 14:47:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E1432FF9F for ; Sat, 2 Feb 2019 14:47:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 920822FFAC; Sat, 2 Feb 2019 14:47:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 159782FF9F for ; Sat, 2 Feb 2019 14:47:19 +0000 (UTC) Received: from localhost ([127.0.0.1]:43110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpwZi-0005wl-Nf for patchwork-qemu-devel@patchwork.kernel.org; Sat, 02 Feb 2019 09:47:18 -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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Tested-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 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)