From patchwork Mon Sep 11 10:38:32 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: 721455 Delivered-To: patch@linaro.org Received: by 2002:adf:f64d:0:b0:31d:da82:a3b4 with SMTP id x13csp1023774wrp; Mon, 11 Sep 2023 03:39:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbx+YyNSMixLmLDxTEW/n8CWY961BwqdNdtRoTQd8LcMmHFBhAj0GPJfgnm3Mlx3BVCJaR X-Received: by 2002:a0c:f68d:0:b0:647:1e50:b64d with SMTP id p13-20020a0cf68d000000b006471e50b64dmr8941073qvn.27.1694428784098; Mon, 11 Sep 2023 03:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694428784; cv=none; d=google.com; s=arc-20160816; b=EIeprhPqVLB3SbUVHnl9dob8QdzIkNaOHgJ6fvzvR1j+u2ihCZiZth2TSqbiw3a2DH yf8DNGPG2yX43c/QcDMLzoKFOqOIlAEqaQPyLwyqI2ommL/Z4lnvkS6qtIdnce8+1I2s KclDPUx3q7ow8txL8DbA8IExvmiMvFyoaCg2YPht5fuZptN1ExkenclJHmz0rwB2QDEl yf7uqS4N08zwxwtlzBecc8r8tKGWU4igx1u1MhtREiF6SZ+eVoCxRZ6IO/eRrGsUDKDX h+T7a8USewZUDRGysJ9qkDjSoa3CehSxTt9pEyR8ncOksyfpAtvZBVu2FkCE0Ii9hD4M Woyw== 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=YnEbICE5DmlevtBmaZnl3yDN8nVPjB9EnaMUokRPLHQ=; fh=DPitpwADt0a7Sd854jgp2f7NWYBvKdp0Ky6VYy5P9ng=; b=px5wqKQO36MvcPiCu3xf++yhnn68CE3vt6iNMj5MDpdb8UjQh2MODJtfGMEORzYIyw 7AsgFs7bmEzObDxkfE8Nx+yWHhF3mB4MC6JIv6Wx7nBJudCFqUoN/aEgdQVs1K8Tb+Mz SZovhGSj+fi/fsT9nwPukv9og5ou717ii5DOacuR3pDWbhIvKPEGIBZ2vKqPczdvqNWC vKWE1hXcO7zUNfS2H5d/u6VaAwFibtBlguWyxi6Htev3v3r+VIzCgtZy+vWh7I13OdrX 3GgcOysC5R3vAkRCpU8JC46pBpVxnEJj0U7l92z3AFmKKcieQmxqwQyizKUYeNdqvqM+ 3/iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CHWbkoLm; 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 w17-20020a05620a0e9100b00770f346e9e7si2696456qkm.103.2023.09.11.03.39.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Sep 2023 03:39:44 -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=CHWbkoLm; 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 1qfeJW-0000gO-I5; Mon, 11 Sep 2023 06:38:42 -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 1qfeJU-0000fu-Nn for qemu-devel@nongnu.org; Mon, 11 Sep 2023 06:38:40 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qfeJS-0005up-8o for qemu-devel@nongnu.org; Mon, 11 Sep 2023 06:38:40 -0400 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-99bf3f59905so531316266b.3 for ; Mon, 11 Sep 2023 03:38:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694428716; x=1695033516; 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=YnEbICE5DmlevtBmaZnl3yDN8nVPjB9EnaMUokRPLHQ=; b=CHWbkoLmru0q3HFYB0v6L8jDCqbELU4CaaNSYvl1z/25+grCePsCm2yo1JYtHBwMkx ui7axeGBpuNMRhwoXTezc4BUfODwVItvei9oSt+PhI7GKPXetrlEc7OihMPilhTMFb4P MkA8jpEvIzCgp4TC1qPW9jo0z3nycFfYt5rmlUe41snltv1RJgiWIGtxt6rYQlKSZUj5 Wu7ASeNoYpZrr7Is1pahHyoqqhxQd9dhERrISYlmwfd2M84oTCZwR0aRKxrZWQpGApl7 GwxGaUKQyCuRjf0xvBfcY4zWxYizaGb3G12qQM85Ly3+tn6oo8siFjKHiipBoVo0A7dH WpSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694428716; x=1695033516; 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=YnEbICE5DmlevtBmaZnl3yDN8nVPjB9EnaMUokRPLHQ=; b=jnk5DofhCm4+9jS+AfFV9LEQ9WL0dfGYys5mhFdyWzWEilOSLAcQeBelQ6rNGMNANl FNLSMP/m7jlwfA+YxhGzOF630Bg/WTxE2RjMGV931PSwoe9n/1nHtpdWi8rCAF5witrN PaqmsDDwaeUNsN1QjuZ7VsP9QrjWYE45WJhUIdKuB3h6fvA/0p38VQGmWrOYBwyIuAJb 5tm3hRyG9ovRPoVI2YV93kpqZBro1V7d6rb3h3ZltCZlrauDSQU7lBF94Zz2RtV5GyoM +4AgAGU+yoFXQlEVp4FNw8cPHRoe8EPfiI3jTVnDncgCUuwIjWrNkHIUbVrWnd99hpdC GigA== X-Gm-Message-State: AOJu0YyFLBqK8Zp9JdZHq895Nb1UsfE+e7jORLYW0Pv2UgZeC3kFd1lC bWsRiIAcnpmXYC3dUm2SmoQ3TgiBdY9qG66wEz0= X-Received: by 2002:a17:906:8251:b0:99b:d580:546c with SMTP id f17-20020a170906825100b0099bd580546cmr7687810ejx.23.1694428716135; Mon, 11 Sep 2023 03:38:36 -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 y22-20020a170906449600b0099bc8db97bcsm5125112ejo.131.2023.09.11.03.38.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 11 Sep 2023 03:38:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Paolo Bonzini , Marcelo Tosatti , Michael Tokarev , Stefan Hajnoczi , Richard Henderson , kvm@vger.kernel.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Kevin Wolf Subject: [PATCH] target/i386: Re-introduce few KVM stubs for Clang debug builds Date: Mon, 11 Sep 2023 12:38:32 +0200 Message-ID: <20230911103832.23596-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::62d; envelope-from=philmd@linaro.org; helo=mail-ej1-x62d.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. Therefore restore a pair of stubs for unoptimized Clang builds. Reported-by: Kevin Wolf 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é Reviewed-by: Stefan Hajnoczi --- target/i386/kvm/kvm_i386.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index 55d4e68c34..0b62ac628f 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -32,7 +32,6 @@ bool kvm_has_smm(void); bool kvm_enable_x2apic(void); -bool kvm_hv_vpindex_settable(void); bool kvm_has_pit_state2(void); bool kvm_enable_sgx_provisioning(KVMState *s); @@ -41,8 +40,6 @@ bool kvm_hyperv_expand_features(X86CPU *cpu, Error **errp); void kvm_arch_reset_vcpu(X86CPU *cs); void kvm_arch_after_reset_vcpu(X86CPU *cpu); void kvm_arch_do_init_vcpu(X86CPU *cs); -uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, - uint32_t index, int reg); uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index); void kvm_set_max_apic_id(uint32_t max_apic_id); @@ -60,6 +57,10 @@ void kvm_put_apicbase(X86CPU *cpu, uint64_t value); bool kvm_has_x2apic_api(void); bool kvm_has_waitpkg(void); +bool kvm_hv_vpindex_settable(void); + +uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, + uint32_t index, int reg); uint64_t kvm_swizzle_msi_ext_dest_id(uint64_t address); void kvm_update_msi_routes_all(void *private, bool global, @@ -76,6 +77,20 @@ typedef struct kvm_msr_handlers { bool kvm_filter_msr(KVMState *s, uint32_t msr, QEMURDMSRHandler *rdmsr, QEMUWRMSRHandler *wrmsr); +#elif defined(__clang__) && !defined(__OPTIMIZE__) + +static inline bool kvm_hv_vpindex_settable(void) +{ + g_assert_not_reached(); +} + +static inline uint32_t kvm_arch_get_supported_cpuid(KVMState *env, + uint32_t function, + uint32_t index, int reg) +{ + g_assert_not_reached(); +} + #endif /* CONFIG_KVM */ void kvm_pc_setup_irq_routing(bool pci_enabled);