From patchwork Mon Sep 11 13:15:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 721456 Delivered-To: patch@linaro.org Received: by 2002:adf:f64d:0:b0:31d:da82:a3b4 with SMTP id x13csp1092967wrp; Mon, 11 Sep 2023 06:15:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF8YkcqJCVTDrowfHx+OZwSooLIWxIxpVG3oGdhFcUG/zCxZy9C7ogQXX2vf8AWJvGMtUmD X-Received: by 2002:a05:620a:1721:b0:770:f3e6:ba2e with SMTP id az33-20020a05620a172100b00770f3e6ba2emr6236385qkb.39.1694438148622; Mon, 11 Sep 2023 06:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694438148; cv=none; d=google.com; s=arc-20160816; b=bVys+w9c5/s+xy1m2geYXvuGrjVAT8CWwlFfkPInPEjlElx4tRprZ1Dwi6p1/eS7Br 6tLaWZRQN43edkeUfjElhLvneEYIz0+8TjVNxRJpIAm70YB0dELQYdxt0EPCw0AzuIeq EZ/nsYjo2TiEs3r/JnOWkr7g1oAFrqRCt7KcecVv7st7cWlWnuOtoYf4P8Vmzlhv2/xF SdWstrtLokqqPTSl12Z6tKp2KJ09DNr5nF/0NjEH2kccFFks/FHMUmIKt8JtpkvxaZaO oQwir20Gw0MC8qsVN4ZbyDS4fqANoNBAEaDRyjNKVbsLZZ/ZFRH5tMN9QfTk9FvhNqIT N1Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=JTa1mjppJcFOyEO7rTUqbYp1VGc27zPh41oxE71ODV4=; fh=BxZucXlUvKICkpqummbDUFYcMxO/gnumRtRfpS19nTo=; b=NnOq5lzLu1Ttsc7viSClrZaIue1P3M9/Uk/aH5Tli7a5bL5dt0bR9ljmitvAQBFQkZ 9PWfybBCOMXTTZY58wD3VDxAJGcAyOlUphhC5ejJi2TICFp3MglXGtUTlmvQdrUnWoPE q25SgDBYe8YYV/LkPoH06W7IMeH6XF/zRYqOtpOuhnsL6MNVyJHlRs3DQr4tSmyTRl/l TzrDQXLv9/wdHtIqVvSm/QGnOcijvrah9/YO4Nenu8U9DRuLY7xa0sTuqOVb36uZRRUM 2E64dxXSC0lTsTPbzCMpsHnXY8NfN655+KTogQskUxz3YKdaOzZJ/Tj23U2P5Y+Fsj8N q8HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CCWgzBuz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r4-20020a05620a298400b007681352af57si4751054qkp.244.2023.09.11.06.15.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Sep 2023 06:15:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CCWgzBuz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qfglF-0003V1-55; Mon, 11 Sep 2023 09:15:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qfgl3-0003Nc-EZ for qemu-devel@nongnu.org; Mon, 11 Sep 2023 09:15:25 -0400 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qfgl0-0003FP-5U for qemu-devel@nongnu.org; Mon, 11 Sep 2023 09:15:17 -0400 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-51e28cac164so11838046a12.1 for ; Mon, 11 Sep 2023 06:15:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694438111; x=1695042911; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=JTa1mjppJcFOyEO7rTUqbYp1VGc27zPh41oxE71ODV4=; b=CCWgzBuz6Gmm66xqlApUbUM747V0LS/mScmyf7uTsT1GmVy5bkRGpi49+sZ6D0y/ZO j7VI+JpKiy7rKJgkvLoaO/KfabWrxylOSSvvxxP5K7sWma1axcGvyDOKbKMWghBNfW9m xuPHzfY89RSXhpR5yEkafW08utlqJIgYzZ0Md3WoeTSo8FieBPoopVzCKK5a0ftQfs18 u0n2hP8P0nK9fQlcRrfnKdZlh3UthgIPRNFgC/eEi2m6jbuQiR/kKR18UIwCa0tU/Mh5 oKcVm12fhugsbEtAyctyiCZ8U3NBuLr/Z9iJNwi3RY5JP028brdDIZRvVZYb8a36rZ3B 05yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694438111; x=1695042911; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JTa1mjppJcFOyEO7rTUqbYp1VGc27zPh41oxE71ODV4=; b=SYrjmAyKVIXH2M015a98yi9Xhbe+d8A0ZFHiqjM01AqoiUsHldJzN6CSU3ggE5sgFc suXYZk6Bh7jnnbulmcIAnY+J2QRI6zqBWjtMBDDKGV2q9iUZ9IAobXESnPxpVU8u5/Ha cQHBckz2x9Phoav4xwsRfrD6Cc1NMzRn9pO2FqetxnuM3m2rgk1/k243iY8ITYkBK69X 3V8QGpVBMpRAx929tsAhrDSszE9e/2ZYU4l+5Nm5CF4YIqslIfFCDHG6i8wQWcsao7D4 up0CA5MCAnOTn57Zr6wkB4cfbAhfcqVPfI1d1icT4efgL4pCLR3aTp+50DH2s1ugra9N hEzA== X-Gm-Message-State: AOJu0YxT4utdn7mwYVDe7ln/Sq4SGJdETH8ugDbTRGJYxrky2puZ0wv1 MwtZpoCeWraOtd/IZtvWzLDsTGt7ijSkwEoF8As= X-Received: by 2002:a17:907:8a1c:b0:9a5:7dec:fab9 with SMTP id sc28-20020a1709078a1c00b009a57decfab9mr17789791ejc.9.1694438111054; Mon, 11 Sep 2023 06:15:11 -0700 (PDT) Received: from m1x-phil.lan (tfy62-h01-176-171-221-76.dsl.sta.abo.bbox.fr. [176.171.221.76]) by smtp.gmail.com with ESMTPSA id d16-20020a17090694d000b00982be08a9besm5397044ejy.172.2023.09.11.06.15.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 11 Sep 2023 06:15:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Daniel Henrique Barboza , Paolo Bonzini , Michael Tokarev , Stefan Hajnoczi , Richard Henderson , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Kevin Wolf , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= Subject: [PATCH v2] target/i386: Re-introduce few KVM stubs for Clang debug builds Date: Mon, 11 Sep 2023 15:15:07 +0200 Message-ID: <20230911131507.24943-1-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=philmd@linaro.org; helo=mail-ed1-x533.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since commits 3adce820cf..ef1cf6890f, When building on a x86 host configured as: $ ./configure --cc=clang \ --target-list=x86_64-linux-user,x86_64-softmmu \ --enable-debug we get: [71/71] Linking target qemu-x86_64 FAILED: qemu-x86_64 /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `cpu_x86_cpuid': cpu.c:(.text+0x1374): undefined reference to `kvm_arch_get_supported_cpuid' /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_filter_features': cpu.c:(.text+0x81c2): undefined reference to `kvm_arch_get_supported_cpuid' /usr/bin/ld: cpu.c:(.text+0x81da): undefined reference to `kvm_arch_get_supported_cpuid' /usr/bin/ld: cpu.c:(.text+0x81f2): undefined reference to `kvm_arch_get_supported_cpuid' /usr/bin/ld: cpu.c:(.text+0x820a): undefined reference to `kvm_arch_get_supported_cpuid' /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:cpu.c:(.text+0x8225): more undefined references to `kvm_arch_get_supported_cpuid' follow clang: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed. '--enable-debug' disables optimizations (CFLAGS=-O0). While at this (un)optimization level GCC eliminate the following dead code: if (0 && foo()) { ... } Clang does not. This was previously documented in commit 2140cfa51d ("i386: Fix build by providing stub kvm_arch_get_supported_cpuid()"). Fix by partially reverting those commits, restoring a pair of stubs for the unoptimized Clang builds. Reported-by: Kevin Wolf Suggested-by: Daniel P. Berrangé Fixes: 3adce820cf ("target/i386: Remove unused KVM stubs") Fixes: ef1cf6890f ("target/i386: Allow elision of kvm_hv_vpindex_settable()") Signed-off-by: Philippe Mathieu-Daudé --- target/i386/kvm/kvm-stub.c | 31 +++++++++++++++++++++++++++++++ target/i386/kvm/meson.build | 2 ++ 2 files changed, 33 insertions(+) create mode 100644 target/i386/kvm/kvm-stub.c diff --git a/target/i386/kvm/kvm-stub.c b/target/i386/kvm/kvm-stub.c new file mode 100644 index 0000000000..d3d4a238ce --- /dev/null +++ b/target/i386/kvm/kvm-stub.c @@ -0,0 +1,31 @@ +/* + * QEMU KVM x86 specific function stubs + * + * Copyright Linaro Limited 2012 + * + * Author: Peter Maydell + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ +#include "qemu/osdep.h" +#include "cpu.h" +#include "kvm_i386.h" + +#ifndef __OPTIMIZE__ +/* 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) +{ + return false; +} diff --git a/target/i386/kvm/meson.build b/target/i386/kvm/meson.build index 5d9174bbb5..40fbde96ca 100644 --- a/target/i386/kvm/meson.build +++ b/target/i386/kvm/meson.build @@ -1,3 +1,5 @@ +i386_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c')) + i386_softmmu_kvm_ss = ss.source_set() i386_softmmu_kvm_ss.add(files(