From patchwork Wed Sep 13 09:30:03 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: 722116 Delivered-To: patch@linaro.org Received: by 2002:a5d:4387:0:b0:31d:da82:a3b4 with SMTP id i7csp192367wrq; Wed, 13 Sep 2023 02:31:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHd/nC7EnepGJdLMaff4S5O3bWqKO44VLCwbxO6WnjfLWF0pZ6OilUTolTxUbtZEHWGK7/d X-Received: by 2002:a05:6214:29e8:b0:647:30f9:4b79 with SMTP id jv8-20020a05621429e800b0064730f94b79mr6260661qvb.7.1694597464307; Wed, 13 Sep 2023 02:31:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694597464; cv=none; d=google.com; s=arc-20160816; b=Nyn6Zaq5TEqQ3hWkIm9bXse2LD1kExFtBliArzrP4MVbp/ylHnRO6iIV+mR0obH9Jw y6Y+LBRRuY/a605F64FdIGYDAuCrXBBQaLSQqYiUaplrIrzdnoHjJBXOaZDqNzl9MfGh ryJZr2Hsp4zCvDyJmk4GsUyEz2jMoYulW2n7CdDkYBFrWbZvWGP26z98ASAhF8JThVxj mzkd6m1opd106MUke9u5b+wQmV8WSQMxZhUJfr4Q7rjtsXTggmcIpIFy+0N5u3iwVE0s mi3SfiRz66eaWv7eX9jDLwQp7h4JYMOR2gi/32uPbnkZZQgE/r25spGBLUgVo731fJdO Mk3Q== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1Ef+xjoTCq+y/8i7W8/XmeY8Z3xpQKPoxBTn9z9VDh0=; fh=gGU+936hSKyjfCkvw+7ovSo4LbZMBSzYH7C194STwMA=; b=s/A5Zt1+mdxF5Xx9crONZki0g6qgm/IiJQAMq6KwJhddrzLFY4ZweuWR+UMdiMgNcF 0NCseAqMm2gaBqXqHh1swRgVkqybX0JbO3EibCW9LsnWZBtgnCNg0oiQItpCKpaRSrMJ +9T/NA5YacW7dg5xCHM4AYmqGCsxX0mLcCE4dTMkvsXEW6k85ykMxnlYvLuRIvxK8Dhh Q5cyjbIsGstNHw3f+6HfrntvEBpn3Sr2mzUezVpt0gxVuUZt+GHVAn97tCrJ5zHBWaPz yAhT5VCtD2WvHljMY9s/h7X4DtIcOoIQ5UdptU+bn49YcG/Y7q4QU5cRtyao53FVK3nT m39g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tuF0bLHI; 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 z11-20020a0cda8b000000b0064f4eb2fd49si7004949qvj.504.2023.09.13.02.31.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Sep 2023 02:31:04 -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=tuF0bLHI; 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 1qgMCe-0000zU-9J; Wed, 13 Sep 2023 05:30:32 -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 1qgMCX-0000ye-Gm for qemu-devel@nongnu.org; Wed, 13 Sep 2023 05:30:29 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgMCT-0002Bm-UP for qemu-devel@nongnu.org; Wed, 13 Sep 2023 05:30:24 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-31c8321c48fso438230f8f.1 for ; Wed, 13 Sep 2023 02:30:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694597419; x=1695202219; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1Ef+xjoTCq+y/8i7W8/XmeY8Z3xpQKPoxBTn9z9VDh0=; b=tuF0bLHId2aSIh0qNoo3tim8zY74YWgI8OCmYHv19N4VnvSMyLO8pd2NB8PGRmCKuD +7KKj5OkbovZ+JB+a4zBoI4Z/Nwavyo/qSJIWTzcMyvUptDqSsKfqRzVUPnz8EhmOgiO SYj59PrXMeegnm+alXBEpdHM/w2u06JSeu2ro2wOpSuuvXOWXJRDPfp0omf/x2jjThD7 DoUwUDxWe8fQeXYHmZPZOskO0sI6mL0wwxlUgx/qdltEE2mzMeHayeDAbZ9rcRgPjOd8 yZK3VN9YRCNJ39/TSmMzrYflJRivKa9D7RfEJKr6okFEAVk5dSSzFMdmAG+Rfvl/oJe6 cPBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694597419; x=1695202219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1Ef+xjoTCq+y/8i7W8/XmeY8Z3xpQKPoxBTn9z9VDh0=; b=CKxItQSXtWZFc9LC+5Uz0+yZtengnCsUTomy1VHIKQrKgKaiFw4V0kP7RSY4AIX/DE OU35ZwB5SdtUs0wQrBE9wllA0tNkV8UvWsAl8dXuiuJOkJZFx2uQPS7N8WYXPZG4ipmZ QT00JUj9kYZy0JpqQFWnosVeHyLpPqzD0QjNP7PUAEbTFUOnwbOIHe2Vw7GBowRNnHs5 5FFAo7x2u300Ey3NhOqHrJBaOQb78L6RMDk9iOM96lxTamUnVpaLqICGlCkumExdGFiT NEaWcndyWFU8YVaEyVsXK7QpF506Aq6bYf6ksMYts2R1A4BTgPdM0g38kY4LnSkvVOC4 /7Dw== X-Gm-Message-State: AOJu0YwxldPrtiqVWBMVAsyPnDcIyBWozWW9iaAWLZTTDvE7ru7qIjq/ ZydUFVPLUHqW2UMlE/mAA5dJs8EkXZDxkZ3xhkE= X-Received: by 2002:adf:e403:0:b0:31f:7324:d47d with SMTP id g3-20020adfe403000000b0031f7324d47dmr3941318wrm.1.1694597419050; Wed, 13 Sep 2023 02:30:19 -0700 (PDT) Received: from m1x-phil.lan (176-131-211-241.abo.bbox.fr. [176.131.211.241]) by smtp.gmail.com with ESMTPSA id l9-20020a5d4bc9000000b003180027d67asm14946210wrt.19.2023.09.13.02.30.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 13 Sep 2023 02:30:18 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , kvm@vger.kernel.org, Paolo Bonzini , Stefan Hajnoczi , Michael Tokarev , Kevin Wolf , Richard Henderson , Daniel Henrique Barboza , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v5 1/6] target/i386: Check kvm_hyperv_expand_features() return value Date: Wed, 13 Sep 2023 11:30:03 +0200 Message-ID: <20230913093009.83520-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230913093009.83520-1-philmd@linaro.org> References: <20230913093009.83520-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.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 In case more code is added after the kvm_hyperv_expand_features() call, check its return value (since it can fail). Fixes: 071ce4b03b ("i386: expand Hyper-V features during CPU feature expansion time") Signed-off-by: Philippe Mathieu-Daudé --- target/i386/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 24ee67b42d..bd6a932d08 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7121,8 +7121,8 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **errp) env->cpuid_xlevel2 = env->cpuid_min_xlevel2; } - if (kvm_enabled()) { - kvm_hyperv_expand_features(cpu, errp); + if (kvm_enabled() && !kvm_hyperv_expand_features(cpu, errp)) { + return; } } From patchwork Wed Sep 13 09:30:04 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: 722121 Delivered-To: patch@linaro.org Received: by 2002:a5d:4387:0:b0:31d:da82:a3b4 with SMTP id i7csp192657wrq; Wed, 13 Sep 2023 02:31:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfUuTro2T4XNXeYCDiLatjDSZIo254j04HQGhgeWZBVfYhrdxPOU5DlnEOF8HNTSxYcOtT X-Received: by 2002:a05:620a:1723:b0:770:f347:474b with SMTP id az35-20020a05620a172300b00770f347474bmr2011233qkb.68.1694597512913; Wed, 13 Sep 2023 02:31:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694597512; cv=none; d=google.com; s=arc-20160816; b=Oo7swoGfnl4H6ytWYL3UjsBd9lewBn7mrvXA+KPU9ZFGOz3nbt03Y3LLfaerkatUaV cyHhqQWPmCpXmALwJ0B1jDQt+rO0D3S5MxCsM845Wxk9su4yAQ+t34IKtZyODvctyk+f 6TsZEHfliS5ehPljeUGZpm7yz/I6aaU81FWVU98o+A7XKo3eZMapSA8fIJwwUiNLRsW1 SNqTyWLIAIwTqprSHT2YUxzRc+yLYSEWWvEH5ZNXlEdvfYiHDOPNM5pDJdpmFO3ZBeHl evCFh71/1Q8dM8NeNMpkDRjlMviF93MbRLbpmBxrfYDeaRgqjPjjh08+jRjryGaPfbmB aAug== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EJ4BcJE7pBMWigDDKZYpQ7Lkem5BrBoGp2n7HRl4RO0=; fh=gGU+936hSKyjfCkvw+7ovSo4LbZMBSzYH7C194STwMA=; b=SeSgPvcC+yEA1cMyu4P4YnIrKW3DN0Hzsg+NNoKsHiXCAvo7/EhYjEpxX25H9rIJEo UDkOIB0rLL/sac7vWf7+OdV62YzXRx4JZyu5zfJ6hx0ZgQ8yERgS7v42xa3C/XP1L9Bp abJ+Oq/u6W0ri2qf3qM5ZiyJzWM3Pwoa6Erip2Hk9qSaJms4FQOJ/n6S97M2m4FxNxb/ C8LmrcysfKS3p88u8uXEqc/L/V9jzpXbq2e2alz57M9UBTemFTrOX9NaVLJXO9PBE2c5 YUdVYyxUAZ0yR5TjxtWz/r7TWs4LsNrHFbApe5gXSl/cKzVvP6JK9+VwQ+T23wCFbVfX MsQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ot3baEvq; 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 k6-20020a05620a414600b0076ef0b3cd12si7240399qko.692.2023.09.13.02.31.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Sep 2023 02:31:52 -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=Ot3baEvq; 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 1qgMCf-0000zx-SE; Wed, 13 Sep 2023 05:30:33 -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 1qgMCc-0000zC-Iz for qemu-devel@nongnu.org; Wed, 13 Sep 2023 05:30:31 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgMCZ-0002DA-0R for qemu-devel@nongnu.org; Wed, 13 Sep 2023 05:30:29 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40037db2fe7so70555085e9.0 for ; Wed, 13 Sep 2023 02:30:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694597425; x=1695202225; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EJ4BcJE7pBMWigDDKZYpQ7Lkem5BrBoGp2n7HRl4RO0=; b=Ot3baEvqjPo4C2g3L/m5n6VZIaJaEPuMcah+4LrhS8DqsI/8wpfwpk+DQBP7HRJN6y +DlyZ2G+XjERDL2NXiXVG127AajRNFs3tMqKiEamGmXqe58x0IEFc4zWRMvdQDUh4U8p ePvlMGqdvz5rPVF3ZA5+WEevGAz6hvsL6ORtEGsVaRq6w4HJAYPgpBoOeVmoKBUl5Mc/ K06IVExntQ0aCKPO7ALtjoDd+/5LG0RqG3eBbLSfCwU9ciMc237KJEH5SIFOTjd0SOFJ F41BCn9Ln+bTfNLi1R1/DEuMa0BDav6kZqKtFPg1XHOnQq0RPv3t72DJ6L5BwRRoCyDO xS5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694597425; x=1695202225; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EJ4BcJE7pBMWigDDKZYpQ7Lkem5BrBoGp2n7HRl4RO0=; b=C/WOF8WWGLsw0p+kDbkbUdzxLjw2VRghWzvRtK22WQABwcPGfwtUxEyRtrNz1ne8mW XwOW81YqFJh4bXbzZHiR/2l0PMAGPOZz5WgWo3/SjrTH56+Ij8MIOmR9vG9A9mGrOWnO j5P9OEWfvat0a5vRRqfoLP0+TvnelADTWYvu7z4NBUjjUtheanmd/y2VkUe7Q7v6xL+C 2IhUBIRJzyScMsy8flr4mVmrXNxhllkjGp1ML5esz8ChfbvnLCV87oYBm5NRVPsPALS/ FuIUXVz1EliaT6BWJKBOhcQDRL4Mv8oNlT0jlbVhEMLszXNtJnCpCXuMnAB2fho9v+gB wBrg== X-Gm-Message-State: AOJu0YyQh1QrnEHP5ePwr7pk3qOkXugo0y/n8zpZWUU+XuJXXV4XFOEX HPX0KuyYLKdKGStvlj58SqoOrf3uvsz180HlVrg= X-Received: by 2002:a7b:c8d6:0:b0:402:8c7e:3fc4 with SMTP id f22-20020a7bc8d6000000b004028c7e3fc4mr1633611wml.30.1694597425050; Wed, 13 Sep 2023 02:30:25 -0700 (PDT) Received: from m1x-phil.lan (176-131-211-241.abo.bbox.fr. [176.131.211.241]) by smtp.gmail.com with ESMTPSA id b14-20020a05600c11ce00b003fee8502999sm1476159wmi.18.2023.09.13.02.30.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 13 Sep 2023 02:30:24 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , kvm@vger.kernel.org, Paolo Bonzini , Stefan Hajnoczi , Michael Tokarev , Kevin Wolf , Richard Henderson , Daniel Henrique Barboza , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v5 2/6] target/i386: Drop accel_uses_host_cpuid before x86_cpu_get_supported_cpuid Date: Wed, 13 Sep 2023 11:30:04 +0200 Message-ID: <20230913093009.83520-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230913093009.83520-1-philmd@linaro.org> References: <20230913093009.83520-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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 x86_cpu_get_supported_cpuid() already checks for KVM/HVF accelerators, so it is not needed to manually check it via a call to accel_uses_host_cpuid() before calling it. Suggested-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daudé --- target/i386/cpu.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index bd6a932d08..94b1ba0cf1 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6207,7 +6207,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, break; case 0xA: /* Architectural Performance Monitoring Leaf */ - if (accel_uses_host_cpuid() && cpu->enable_pmu) { + if (cpu->enable_pmu) { x86_cpu_get_supported_cpuid(0xA, count, eax, ebx, ecx, edx); } else { *eax = 0; @@ -6247,8 +6247,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ebx &= 0xffff; /* The count doesn't need to be reliable. */ break; case 0x1C: - if (accel_uses_host_cpuid() && cpu->enable_pmu && - (env->features[FEAT_7_0_EDX] & CPUID_7_0_EDX_ARCH_LBR)) { + if (cpu->enable_pmu && (env->features[FEAT_7_0_EDX] & CPUID_7_0_EDX_ARCH_LBR)) { x86_cpu_get_supported_cpuid(0x1C, 0, eax, ebx, ecx, edx); *edx = 0; } @@ -6322,9 +6321,8 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, } else { *ecx &= ~XSTATE_ARCH_LBR_MASK; } - } else if (count == 0xf && - accel_uses_host_cpuid() && cpu->enable_pmu && - (env->features[FEAT_7_0_EDX] & CPUID_7_0_EDX_ARCH_LBR)) { + } else if (count == 0xf && cpu->enable_pmu + && (env->features[FEAT_7_0_EDX] & CPUID_7_0_EDX_ARCH_LBR)) { x86_cpu_get_supported_cpuid(0xD, count, eax, ebx, ecx, edx); } else if (count < ARRAY_SIZE(x86_ext_save_areas)) { const ExtSaveArea *esa = &x86_ext_save_areas[count]; From patchwork Wed Sep 13 09:30:05 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: 722119 Delivered-To: patch@linaro.org Received: by 2002:a5d:4387:0:b0:31d:da82:a3b4 with SMTP id i7csp192581wrq; Wed, 13 Sep 2023 02:31:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7UcDEwCCePLKGtyzMdx52KcqfqJHRWLVIGd2d/K8pOGC+4WMlyZKdsO1DxmIad5qYCOf3 X-Received: by 2002:ad4:4a70:0:b0:647:122f:84ee with SMTP id cn16-20020ad44a70000000b00647122f84eemr1884673qvb.56.1694597502000; Wed, 13 Sep 2023 02:31:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694597501; cv=none; d=google.com; s=arc-20160816; b=lBwNk5lp3oJgC3Q5PGvBKg2VTS5bG5hBCpnI10uOYainckFIgJM2HA55MDPbgBrhmF 7CJqugwGzTpK0vX9sjTBkTOXXMs2dCfyFQVx4nIHF0edlTMPWWI+AStH0pNPE0Qvrd5E yR71nN4uBO6hRG2AUQPGLvg/ua4TXwFkHzris5A3eH6yaKoSn5TpAOH+6W9IhjaPcnmA Sbw4B8UmQjbXDjsvlbi5PW+wcOXlpDyfayiEjdTcYIcO3a9GgpeLzEKn+O3GozC+vZzr PvYd4xoVOZYzpTCm1wTcxaaO1gGc+Qu6DeRY1Jk2rUs7gzh0GBIgnMhHobw4sEUppReH kW9Q== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZR4T6NlMHpArLYrHIDyBj0HhdFN73kI81RfJc3c6SLI=; fh=Tcvj3E2v34C1uTif5zEEStTNZmONfYtXvHGBHAnde9s=; b=mSOzBPF2lduXnTJ2rhJtMUlTlu34NCR1rPsTafza9eRlG7csFfyDE7SEX8m0vv6qos XjxlrQzoDZ8LGDYp1ZLac32rISsOq5DFaFfqqxg1fpD+yOblc2svlIdaWqzBIRG1v3iA IWghQQnVvI7UB8i5vJVaNi6b3EJO5jbQJjjtnWRWLAHRJisKyDCYfUAnQQJ1Ki6z2HOX H9utPtYrKAz+7ITnd9Ep34DBoatFF7b7lTNcJVWG/nhubSACGsv/h64riG9+t8MIjqe8 HFp5prKoHl8r/+fEpxGnW4vAirqkG9lYl2Q6CsahS0L34fwgn1ZiKqz6wvNAad5hRRxD 4yow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U0kVmcAy; 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 t8-20020a0cef08000000b00655dd867231si4987095qvr.104.2023.09.13.02.31.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Sep 2023 02:31:41 -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=U0kVmcAy; 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 1qgMCn-0001BH-3s; Wed, 13 Sep 2023 05:30:41 -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 1qgMCl-00017A-56 for qemu-devel@nongnu.org; Wed, 13 Sep 2023 05:30:39 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgMCf-0002Fx-H1 for qemu-devel@nongnu.org; Wed, 13 Sep 2023 05:30:37 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-401f68602a8so71489345e9.3 for ; Wed, 13 Sep 2023 02:30:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694597431; x=1695202231; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZR4T6NlMHpArLYrHIDyBj0HhdFN73kI81RfJc3c6SLI=; b=U0kVmcAyBcPfz8zmlCOxGeiDx+utKPLhh/aADnihlIvJLH5dA+vIEOewQkKrKhLcan jqkoZDYizJuuccbvRoEJj89nnSc6VhiGStwXuXbqDZHfZcdrMq1+bhmdarlLYA4ropYH SkwBiX9m6ha5TEGuwXqrEpgibyGKf12Rw5pMVJx2GrtYshfkbx0uHNIlWF/cGrZv4X4I bUh4oBbqlVtz9MoUcXmb+jeMvbS3TvioQ0vLo5qH++yepHVpQRJsQrsrkOIs+7YjTeEX D8Ceklef0p+aCYPZvufmFkCw0vJby4VELwYSsA6D564jhNlXQ70fTSpitT5TZiKv5qpH eZmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694597431; x=1695202231; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZR4T6NlMHpArLYrHIDyBj0HhdFN73kI81RfJc3c6SLI=; b=s1HUbrbn7t5wyNReFDarEHDqzJ4EfcuDMfQMbPkn3NZeeCncyFHGvogmndyoLvwjFI /yMnkfbhK6J0VM9i13xjvDZN+ZvCl7DDbInK+Uec3HVIJXlGrSzCKoXmJ5JAdz8qRxSR 847kQGmmWiTQyJPapUEE19Dn/Dw22BQkfcr1Pdjyh0YGvc+LcI6lXOFO/hYlIwODhvaf obYzaI4ilc5espL49eHAzpYBTAAkZ+kyTQzyQtUucaAX1b4TEYTdr1UOUU4M1Ej0U2Dv UEUly03n13qxKMsXSD8kEAyRXK4Uod5XpklYITpgcEhu3GgDuhWmV9cn1z90tWYJ1A1Y 0ohg== X-Gm-Message-State: AOJu0YzzKrY4sb2dT1sVaGyPw21vEoDvI9hdN7hWPs0ld8ki5tizHEEl jBePYfnfyW67V1bxCyKH3EJu3aL3l/ATagoAzVg= X-Received: by 2002:a1c:7212:0:b0:401:c636:8f4c with SMTP id n18-20020a1c7212000000b00401c6368f4cmr1628404wmc.3.1694597430942; Wed, 13 Sep 2023 02:30:30 -0700 (PDT) Received: from m1x-phil.lan (176-131-211-241.abo.bbox.fr. [176.131.211.241]) by smtp.gmail.com with ESMTPSA id r6-20020a05600c35c600b003fbe791a0e8sm1540652wmq.0.2023.09.13.02.30.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 13 Sep 2023 02:30:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , kvm@vger.kernel.org, Paolo Bonzini , Stefan Hajnoczi , Michael Tokarev , Kevin Wolf , Richard Henderson , Daniel Henrique Barboza , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-stable@nongnu.org Subject: [PATCH v5 3/6] target/i386: Call accel-agnostic x86_cpu_get_supported_cpuid() Date: Wed, 13 Sep 2023 11:30:05 +0200 Message-ID: <20230913093009.83520-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230913093009.83520-1-philmd@linaro.org> References: <20230913093009.83520-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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=unavailable 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 x86_cpu_get_supported_cpuid() is generic and handles the different accelerators. Use it instead of kvm_arch_get_supported_cpuid(). That fixes a link failure introduced by commit 3adce820cf ("target/i386: Remove unused KVM stubs") when QEMU is configured as: $ ./configure --cc=clang \ --target-list=x86_64-linux-user,x86_64-softmmu \ --enable-debug We were getting: [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. For the record, this is because '--enable-debug' disables optimizations (CFLAGS=-O0). While at this (un)optimization level GCC eliminate the following dead code (CPP output of mentioned build): static void x86_cpu_get_supported_cpuid(uint32_t func, uint32_t index, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { if ((0)) { *eax = kvm_arch_get_supported_cpuid(kvm_state, func, index, R_EAX); *ebx = kvm_arch_get_supported_cpuid(kvm_state, func, index, R_EBX); *ecx = kvm_arch_get_supported_cpuid(kvm_state, func, index, R_ECX); *edx = kvm_arch_get_supported_cpuid(kvm_state, func, index, R_EDX); } else if (0) { *eax = 0; *ebx = 0; *ecx = 0; *edx = 0; } else { *eax = 0; *ebx = 0; *ecx = 0; *edx = 0; } Clang does not (see commit 2140cfa51d "i386: Fix build by providing stub kvm_arch_get_supported_cpuid()"). Cc: qemu-stable@nongnu.org Fixes: 3adce820cf ("target/i386: Remove unused KVM stubs") Reported-by: Kevin Wolf Suggested-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daudé --- target/i386/cpu.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 94b1ba0cf1..b2a20365e1 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6154,6 +6154,8 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, case 7: /* Structured Extended Feature Flags Enumeration Leaf */ if (count == 0) { + uint32_t eax_0_unused, ebx_0, ecx_0, edx_0_unused; + /* Maximum ECX value for sub-leaves */ *eax = env->cpuid_level_func7; *ebx = env->features[FEAT_7_0_EBX]; /* Feature flags */ @@ -6168,17 +6170,15 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, * support enabling SGX and/or SGX flexible launch control, * then we need to update the VM's CPUID values accordingly. */ - if ((*ebx & CPUID_7_0_EBX_SGX) && - (!kvm_enabled() || - !(kvm_arch_get_supported_cpuid(cs->kvm_state, 0x7, 0, R_EBX) & - CPUID_7_0_EBX_SGX))) { + x86_cpu_get_supported_cpuid(0x7, 0, + &eax_0_unused, &ebx_0, + &ecx_0, &edx_0_unused); + if ((*ebx & CPUID_7_0_EBX_SGX) && !(ebx_0 & CPUID_7_0_EBX_SGX)) { *ebx &= ~CPUID_7_0_EBX_SGX; } - if ((*ecx & CPUID_7_0_ECX_SGX_LC) && - (!(*ebx & CPUID_7_0_EBX_SGX) || !kvm_enabled() || - !(kvm_arch_get_supported_cpuid(cs->kvm_state, 0x7, 0, R_ECX) & - CPUID_7_0_ECX_SGX_LC))) { + if ((*ecx & CPUID_7_0_ECX_SGX_LC) + && (!(*ebx & CPUID_7_0_EBX_SGX) || !(ecx_0 & CPUID_7_0_ECX_SGX_LC))) { *ecx &= ~CPUID_7_0_ECX_SGX_LC; } } else if (count == 1) { @@ -7150,14 +7150,14 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool verbose) mark_unavailable_features(cpu, w, unavailable_features, prefix); } - if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) && - kvm_enabled()) { - KVMState *s = CPU(cpu)->kvm_state; - uint32_t eax_0 = kvm_arch_get_supported_cpuid(s, 0x14, 0, R_EAX); - uint32_t ebx_0 = kvm_arch_get_supported_cpuid(s, 0x14, 0, R_EBX); - uint32_t ecx_0 = kvm_arch_get_supported_cpuid(s, 0x14, 0, R_ECX); - uint32_t eax_1 = kvm_arch_get_supported_cpuid(s, 0x14, 1, R_EAX); - uint32_t ebx_1 = kvm_arch_get_supported_cpuid(s, 0x14, 1, R_EBX); + if (env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) { + uint32_t eax_0, ebx_0, ecx_0, edx_0_unused; + uint32_t eax_1, ebx_1, ecx_1_unused, edx_1_unused; + + x86_cpu_get_supported_cpuid(0x14, 0, + &eax_0, &ebx_0, &ecx_0, &edx_0_unused); + x86_cpu_get_supported_cpuid(0x14, 1, + &eax_1, &ebx_1, &ecx_1_unused, &edx_1_unused); if (!eax_0 || ((ebx_0 & INTEL_PT_MINIMAL_EBX) != INTEL_PT_MINIMAL_EBX) || From patchwork Wed Sep 13 09:30:06 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: 722118 Delivered-To: patch@linaro.org Received: by 2002:a5d:4387:0:b0:31d:da82:a3b4 with SMTP id i7csp192561wrq; Wed, 13 Sep 2023 02:31:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQI1SOrbwOTgQmsCadPE6Z3goQUUJW7K7TWGYfFr1Dufmzi14Grf+fa6+BROkIZs9gPDfL X-Received: by 2002:a05:6214:5190:b0:64f:4472:2773 with SMTP id kl16-20020a056214519000b0064f44722773mr1943242qvb.7.1694597497993; Wed, 13 Sep 2023 02:31:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694597497; cv=none; d=google.com; s=arc-20160816; b=V5Xj0miviVJiVisSZ0qPJsDCQ4ICz6L0znBLxLQ63vpbRxt4xbRstzP0ochMaNWkli o69QUdgazP5V0UN4UuWmM4l0aMlMAcQuR0XUwcJGAX5A3jAjdMcr3CViGWyfGcTJVVSM PE6srgLj47Bj3+ClQBZ08NP9DbFqedF27/U1i2vXh3sT8OlvzwyJbYjONQb7fL1n6AnR ml9DSAjkh8MCGxxknA90pZXFAouHaizteBqU7RnQLF7IIhWYQIQUJRGARoMxSG6XiB7i WFZaLbPXf2aH9N36JCH95YYjB8+1pJTtSGF4zuHd6AOMT4CDpZ5t4ndwg6fyA+g/iXEM 2XsA== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4Qlz4UlYziPNq8F2NThvhMEsqE2XcvVN84mcny9xQ0s=; fh=gGU+936hSKyjfCkvw+7ovSo4LbZMBSzYH7C194STwMA=; b=WTIlSd51o6wQdYeYLaT+tG2XQcIYJbMXgpD+0AOQA8CTb/Y7NuSgyccQkQKBNdI8Re g5BEHMmkSSmS/bEKl4hWWx+c/TqZ6jFpWNrE61Y72vLln4SInXQBPsQduCzGRV5MQc1H 852Z4n2EKbRCJyL2t0AURNAUAG8QaOBEIWZRb/G9kOKkN/RfC8EmR7k2u9TlOHARH82V vWQLIjXpJvhO9zTPWor2zzW12Tp07MakjbRwsIsiUORy1Hu4vKq41eFdiqr/cRBRHSqQ qAtUwQrJ1kBa7Zutfi16gA8jqfXBr7lAY+jX1OJetKVvrK+M53BTgfev9SCKYHK3V9hx 6w8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=StI41PZp; 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 y21-20020a05620a25d500b0076d9a8c430dsi6988751qko.24.2023.09.13.02.31.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Sep 2023 02:31:37 -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=StI41PZp; 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 1qgMCr-0001FB-Nx; Wed, 13 Sep 2023 05:30:45 -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 1qgMCq-0001Di-8U for qemu-devel@nongnu.org; Wed, 13 Sep 2023 05:30:44 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgMCm-0002JY-DE for qemu-devel@nongnu.org; Wed, 13 Sep 2023 05:30:43 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-402cc6b8bedso74613855e9.1 for ; Wed, 13 Sep 2023 02:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694597437; x=1695202237; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4Qlz4UlYziPNq8F2NThvhMEsqE2XcvVN84mcny9xQ0s=; b=StI41PZpsGof1u6ic0imNlFMajuNiHlWROgMEep7VDj4TXwcRMamR5f4CGDKsJlTnw K5QKBYzQOuPl9Vja6/MeTf7CB1UhaiZZpeuqlFdlJzGAszxgvttC7Y+CaidTXECM5ePf Tceqrk7fK/Zh+Ts7jgT/cBgeGMxu689TpnWVwRrDHgzX7cljCH748yX9Qj1FAUuCc+4D 84iMOtoC/V19K9k7PfBegkgSlM8NgZ+2hjFi6FKkdwx4JyKd5QztGPTOOiWYFy1/upv5 un9BQ8Rt/58Fz9wOkSxGb6sDb6cTRAbBqjirdvAJNgwpC36baGeruxMT5DUAQUqytdjI xd5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694597437; x=1695202237; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4Qlz4UlYziPNq8F2NThvhMEsqE2XcvVN84mcny9xQ0s=; b=YhOvbRKvfFq0EoPyKObcwKisaehwst5TjcCD8UsSrkQ2kugXF2xlNFdEfhZGsk/Sbj 2p/yfQdUmavsHYSki6xUMVP+3kHg1X8HuAOKk1+jhzzCFtqg3V09O5ChJZtKUa5Mbak6 TIhbx3XQZCP5QCbAqdJWLfLB7sevDLLMFdxJPAwjNM9C7xzI07VZfKYoF5dSciTIQ2QG 0vLiD3uUtDprHbHIrVl/0La0RK8siSty5Xn8Ogpk8pE7rLpDOW2wrCDasYDQ+D3RjtTi JyYWrM/hA3wrKBgaaUgLnsu6r5HHiFfUABgCuaiU5pr2YRZLy/Em9MCXxrgS3WMD9265 FWUQ== X-Gm-Message-State: AOJu0Yzh7+TFFWXJp6zHlmlc7Zf0kB9qQxkRPrU4Tkh3ZUGEtFo5ir5d dRuKtDvToGjMN4nsIGfVgTYG3KBKBJHL8CwmAJg= X-Received: by 2002:a05:600c:1c89:b0:402:cf9f:c02d with SMTP id k9-20020a05600c1c8900b00402cf9fc02dmr1480014wms.8.1694597437459; Wed, 13 Sep 2023 02:30:37 -0700 (PDT) Received: from m1x-phil.lan (176-131-211-241.abo.bbox.fr. [176.131.211.241]) by smtp.gmail.com with ESMTPSA id x20-20020a05600c2a5400b003fe601a7d46sm1452383wme.45.2023.09.13.02.30.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 13 Sep 2023 02:30:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , kvm@vger.kernel.org, Paolo Bonzini , Stefan Hajnoczi , Michael Tokarev , Kevin Wolf , Richard Henderson , Daniel Henrique Barboza , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v5 4/6] target/i386: Move x86_cpu_get_migratable_flags() around Date: Wed, 13 Sep 2023 11:30:06 +0200 Message-ID: <20230913093009.83520-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230913093009.83520-1-philmd@linaro.org> References: <20230913093009.83520-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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 x86_cpu_get_migratable_flags() is only used once in x86_cpu_get_supported_feature_word(). Move it the code just before its caller, to reduce #ifdef'ry in the next commit, when we restrict both functions to system emulation. Signed-off-by: Philippe Mathieu-Daudé --- target/i386/cpu.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index b2a20365e1..3df85a6347 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1664,29 +1664,6 @@ static inline uint64_t x86_cpu_xsave_xss_components(X86CPU *cpu) cpu->env.features[FEAT_XSAVE_XSS_LO]; } -/* - * Returns the set of feature flags that are supported and migratable by - * QEMU, for a given FeatureWord. - */ -static uint64_t x86_cpu_get_migratable_flags(FeatureWord w) -{ - FeatureWordInfo *wi = &feature_word_info[w]; - uint64_t r = 0; - int i; - - for (i = 0; i < 64; i++) { - uint64_t f = 1ULL << i; - - /* If the feature name is known, it is implicitly considered migratable, - * unless it is explicitly set in unmigratable_flags */ - if ((wi->migratable_flags & f) || - (wi->feat_names[i] && !(wi->unmigratable_flags & f))) { - r |= f; - } - } - return r; -} - void host_cpuid(uint32_t function, uint32_t count, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { @@ -5679,6 +5656,29 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) #endif /* !CONFIG_USER_ONLY */ +/* + * Returns the set of feature flags that are supported and migratable by + * QEMU, for a given FeatureWord. + */ +static uint64_t x86_cpu_get_migratable_flags(FeatureWord w) +{ + FeatureWordInfo *wi = &feature_word_info[w]; + uint64_t r = 0; + int i; + + for (i = 0; i < 64; i++) { + uint64_t f = 1ULL << i; + + /* If the feature name is known, it is implicitly considered migratable, + * unless it is explicitly set in unmigratable_flags */ + if ((wi->migratable_flags & f) || + (wi->feat_names[i] && !(wi->unmigratable_flags & f))) { + r |= f; + } + } + return r; +} + uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, bool migratable_only) { From patchwork Wed Sep 13 09:30: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: 722120 Delivered-To: patch@linaro.org Received: by 2002:a5d:4387:0:b0:31d:da82:a3b4 with SMTP id i7csp192599wrq; Wed, 13 Sep 2023 02:31:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqHPEcBtVsaY4Z5jhu1jWUvECdCRNOMV52CnCqMBi9SKCNXHQdKnGuc6nyaxyNrQpOU/TZ X-Received: by 2002:a05:622a:589:b0:412:945:770b with SMTP id c9-20020a05622a058900b004120945770bmr2055815qtb.18.1694597504515; Wed, 13 Sep 2023 02:31:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694597504; cv=none; d=google.com; s=arc-20160816; b=M3sh+8BBN/v6JduW/HlbqHH4euKbN+tLlIaZkwzrhvxaMLskwwTTHwXYoY3Ycz5YpH O+GlbHJqoMzixgXgf5OwWywo9PTz6ZW8Uk30QKbOetZcP7QOivyGNKyzIf3KWX2QDAIT bRr4NnOStzzI4f1456rjQcrIg/NbHCXWW3q00Aa1R+UFJvmD7CjjqFR1J2+L8AHu4YdV By4fq0RbeqF2XeIcwO9MulO9JKwAFx3EZcA1moef5TEMXpSAxKYQG4P8YhSlXQoxpP70 v/nJ/VbS3tFX7YK8c5I3/a2vsMmJXkL4uVXclwBnduOwFG8iKPV3ZlUOQlsfGJVrFAxp Xr1g== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eKbeAfeEWeYWq6ZMSQ2gP4OMkhbj3lmxF1/S1lGxkFI=; fh=gGU+936hSKyjfCkvw+7ovSo4LbZMBSzYH7C194STwMA=; b=y7iYdJ8wAFApj7FYvJLeZMDHTqe7oW0eyVZXtgPKrvbxDWCSfizVWrElt3EOQq4DcY ifDRaQySdDxcm5BZ/hNhSzLyj+IGosGXbf0uPNWdzbXFxg5M9w2UkkKfYvah0wHwzRDw GKhs1kGkSNvt7Htc9fwG0ztrUZte5LD0+6vDIG533OIe1L5gvk/mcBnNWUDxVowIh6Ko WNKQyZhSt9iZ7snotNx30HS872j1Bc5KUrKRXTb0aeAp48HMsU6MNHxdcmWiFd7PUuOb mFyT7ytG0fgmXpoP7x3i+q8+HgeMOreEftKRodXIEkv5420l6n9Wg3OI5o81YkuvWxCF hx6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CHE19x6S; 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 r18-20020ac85c92000000b0041220e682d3si7382244qta.596.2023.09.13.02.31.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Sep 2023 02:31: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=CHE19x6S; 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 1qgMCw-0001H8-MY; Wed, 13 Sep 2023 05:30:50 -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 1qgMCv-0001Gk-Bu for qemu-devel@nongnu.org; Wed, 13 Sep 2023 05:30:49 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgMCs-0002Ky-5V for qemu-devel@nongnu.org; Wed, 13 Sep 2023 05:30:48 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-31f4a286ae1so6199289f8f.3 for ; Wed, 13 Sep 2023 02:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694597444; x=1695202244; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eKbeAfeEWeYWq6ZMSQ2gP4OMkhbj3lmxF1/S1lGxkFI=; b=CHE19x6SBYVp28nEZ6D7kT6ITh4PMkcmBelUH8DsZgnjFb5s7kS0TmVoa66QkEwquE r37JlKtPfQVC6YEnqwAp4N5uJMrIBQGQA748c62L7inPkwy7Ze9QfikXEjdanjstak96 4UvXTDciyedHazOsWDpKSKIeXyxMD8gw2+Kjf1eXKA2Rvfz4It62w0VC7NSIdPIZ8m6k nmbLml89r7NzpwmejN+ChOAkJ6vthdbaIjI5jbOvKcPkVnW0kF+kzjIlNl7Mu6zx9/1t IF65uFZfQRc2QMzx7LP9oqXAkB4I534SiLUVDJFFcFwb2/+DwftjPFZOD/ZN9fPQzget xG+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694597444; x=1695202244; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eKbeAfeEWeYWq6ZMSQ2gP4OMkhbj3lmxF1/S1lGxkFI=; b=rQVbqhAHleW5yiXcwfQpI0Ksv0RiF1myS25wDxvEiRG5POdxzXxyVqm6a/gRJgKsBs NWXjJd96r3MMyJN/XcyuDaNaDvWGfp/UVAZueYiFFHfZBgBE86HTxx81COdnp6Ral4Pz FW3qO53cYZeJSV54KgmxbMUJvx8udTdbzQmK3nAsSY4z7gGy2boomnpfHoeixHndsaCy S36K4VKHKcqGy116el9Fx6j9h3jgyBdsJt9eTAMOHQ/nY1E95FXIZ2taC14F/0CJ9adR D6n71BlsAUkh1RMeOHc3d6/VJ+ysJnINxYCFlQOR28nOt/rCwb9f618pYGWT9XSJgj9j ZmAw== X-Gm-Message-State: AOJu0Yz/c+nERp8I633xn9npAAT7eJ6BpPtilv7xqUshk/JIYeyum3D7 zJBIuTiVTTj4xuSq2kZ5qeRbPrXb08aGH5ogfgk= X-Received: by 2002:adf:ebc8:0:b0:31a:e6c2:770d with SMTP id v8-20020adfebc8000000b0031ae6c2770dmr1565964wrn.36.1694597444117; Wed, 13 Sep 2023 02:30:44 -0700 (PDT) Received: from m1x-phil.lan (176-131-211-241.abo.bbox.fr. [176.131.211.241]) by smtp.gmail.com with ESMTPSA id u4-20020a5d6da4000000b0031fb91f23e9sm4107295wrs.43.2023.09.13.02.30.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 13 Sep 2023 02:30:43 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , kvm@vger.kernel.org, Paolo Bonzini , Stefan Hajnoczi , Michael Tokarev , Kevin Wolf , Richard Henderson , Daniel Henrique Barboza , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [RFC PATCH v5 5/6] target/i386: Restrict system-specific code from user emulation Date: Wed, 13 Sep 2023 11:30:07 +0200 Message-ID: <20230913093009.83520-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230913093009.83520-1-philmd@linaro.org> References: <20230913093009.83520-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philmd@linaro.org; helo=mail-wr1-x42f.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 Restrict calls to: - kvm_arch_get_supported_cpuid() - kvm_arch_get_supported_msr_feature() - kvm_request_xsave_components() - kvm_hyperv_expand_features() so we can remove restrict "kvm/kvm_i386.h" and all its declarations to system emulation (see the next commit). Signed-off-by: Philippe Mathieu-Daudé --- target/i386/cpu.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 3df85a6347..c201ff26bd 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5654,8 +5654,6 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) return cpu_list; } -#endif /* !CONFIG_USER_ONLY */ - /* * Returns the set of feature flags that are supported and migratable by * QEMU, for a given FeatureWord. @@ -5781,6 +5779,38 @@ static void x86_cpu_get_cache_cpuid(uint32_t func, uint32_t index, } } +#else /* CONFIG_USER_ONLY */ + +uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, + bool migratable_only) +{ + FeatureWordInfo *wi = &feature_word_info[w]; + + return wi->tcg_features; +} + +static void x86_cpu_get_supported_cpuid(uint32_t func, uint32_t index, + uint32_t *eax, uint32_t *ebx, + uint32_t *ecx, uint32_t *edx) +{ + *eax = 0; + *ebx = 0; + *ecx = 0; + *edx = 0; +} + +static void x86_cpu_get_cache_cpuid(uint32_t func, uint32_t index, + uint32_t *eax, uint32_t *ebx, + uint32_t *ecx, uint32_t *edx) +{ + *eax = 0; + *ebx = 0; + *ecx = 0; + *edx = 0; +} + +#endif /* !CONFIG_USER_ONLY */ + /* * Only for builtin_x86_defs models initialized with x86_register_cpudef_types. */ @@ -6918,7 +6948,6 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu) CPUX86State *env = &cpu->env; int i; uint64_t mask; - static bool request_perm; if (!(env->features[FEAT_1_ECX] & CPUID_EXT_XSAVE)) { env->features[FEAT_XSAVE_XCR0_LO] = 0; @@ -6934,11 +6963,15 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu) } } +#ifndef CONFIG_USER_ONLY + static bool request_perm; + /* Only request permission for first vcpu */ if (kvm_enabled() && !request_perm) { kvm_request_xsave_components(cpu, mask); request_perm = true; } +#endif /* !CONFIG_USER_ONLY */ env->features[FEAT_XSAVE_XCR0_LO] = mask & CPUID_XSTATE_XCR0_MASK; env->features[FEAT_XSAVE_XCR0_HI] = mask >> 32; @@ -7119,9 +7152,11 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **errp) env->cpuid_xlevel2 = env->cpuid_min_xlevel2; } +#ifndef CONFIG_USER_ONLY if (kvm_enabled() && !kvm_hyperv_expand_features(cpu, errp)) { return; } +#endif /* !CONFIG_USER_ONLY */ } /* From patchwork Wed Sep 13 09:30:08 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: 722122 Delivered-To: patch@linaro.org Received: by 2002:a5d:4387:0:b0:31d:da82:a3b4 with SMTP id i7csp192724wrq; Wed, 13 Sep 2023 02:32:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdm6G4+hA71TSSP5C0QnWfCAFQf+nr6CpEWNtB1IzREACiidCQxqgclGSsnwl+WEbjBkK8 X-Received: by 2002:a05:620a:4507:b0:768:2da6:577e with SMTP id t7-20020a05620a450700b007682da6577emr2314541qkp.9.1694597523067; Wed, 13 Sep 2023 02:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694597523; cv=none; d=google.com; s=arc-20160816; b=jlWmAANGU4o3lFsAglHVCh1sW9lGWSTgxO4YA4gEA0S9JsgIL789WDTKsXr+cBVAJx kZ+ze1E9rfdFykrH26RNc1tgyOZ5ZZrqUHVqUkkUo11DrmOFyYhhkfc7REQTMJObzRdN vNQ8wgeWS2Xghi0TIiicwqPTCdfMTINuzVJdr91kT3kCDeH3GoguJm813DqDFObkvnFu Oho+vdBmfP7tJZB6IAtCYeuLmaVBBrdZAFzb0clhqt14TFHIOBwCXdVSxoNasFwdidni b83bap3DFLdt2kzcgk5Cy29AJtYwuLxvZUcZoqrQ+kNtZj9zLTr5vXWYB2aRpy+bQr0z /9DQ== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jtT3ML1tHJnWRfmIXQrD6YCHmxZTPOtervgh4drQU7s=; fh=gGU+936hSKyjfCkvw+7ovSo4LbZMBSzYH7C194STwMA=; b=nIyECnFP2ctoHbZcDp/7p8E+NtSI9c/3SU2+iqRWDy8fK5ZCDBeo0sik43nUvvHJ1L Wd2vks4A7dMQfA53LXAYqyag+jxb61arjl1FmBaWjqOJ9eeHtSx0A+skNkWBXdA2G5iQ O1YU2jH6TdzC/RvlQ4szaNQwsjzhUs57hJI15yYBTATfhA3jaHFYyVgvlCXwvP+vQBwy ij+9mNvH/1TTpqTq/wboq/UzoXRFpgV0UjemVK5R2JS90s+Kb+/k9xkQNX4KMODguIwG AhStDtAKzDCphaWtu1WlNyox1bmqTKGOxN06BaOADovVB0C47I9BGT3CF1BNPoGBQZDL A5HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wyNU+9QI; 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 ef9-20020a05620a808900b0076f25a73c79si6939361qkb.246.2023.09.13.02.32.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Sep 2023 02:32:03 -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=wyNU+9QI; 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 1qgMD7-0001JZ-BM; Wed, 13 Sep 2023 05:31:01 -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 1qgMD1-0001Iz-D5 for qemu-devel@nongnu.org; Wed, 13 Sep 2023 05:30:55 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgMCz-0002ME-5U for qemu-devel@nongnu.org; Wed, 13 Sep 2023 05:30:55 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40037db2fe7so70558695e9.0 for ; Wed, 13 Sep 2023 02:30:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694597450; x=1695202250; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jtT3ML1tHJnWRfmIXQrD6YCHmxZTPOtervgh4drQU7s=; b=wyNU+9QIuqMCKmLMuDVDitnZ9U2QI4gOrUOvDogfi5g/eXEY3JeqLu+i9+ey11C5gj 6Uzzhm02qLc8nq70C7SMk2Kb1oOencxz0rBgbVDtw5C8FpDt1mrVRKs7hZwUTrO+2wxh /Yb4+bJPtwb3SIKlxi2LC8Vm4uLp3SvijNkt3ltsSNWYZO1BpvoCn0+ADbe6EcHsSLsR frU82Q8MPNQUfa6MfzdQ+XFyCkgpX0EcWjPmnWRk02Yxig+t03P/NvGCnKdZqMPl1cZu kPED3u4zfpS1tvXN4M1l3h+Bn/RkJ/vIaC/oEPyyrn0s3HE3LALhyCSGLG7R4XN52cL+ 5kjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694597450; x=1695202250; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jtT3ML1tHJnWRfmIXQrD6YCHmxZTPOtervgh4drQU7s=; b=Ngl/74MDcxPDIb9luUwgdxI/VUkK8CMbsDyd642dHPDsEqojC8CEpKakvVMcdYnT2X Zg58L+KIe0bGFNDU4sbvg4YcEAvgmrfN7rXxQx/F2R/fLogQUDCDxCXOBoqJqVOsgGjf t4Mk73Ky7qWe6/rYSsfGfSa4dO30jy0ir29QsRZHP7SjXxhF4fFT7URpm326SfLPxEtb RGWmRsaGWNvarrX3LWaQe97wAH8iIUAUPyf3qo6513opfCxw3Bv6W95Iv0BaGvi4m/D3 d0HK6935xDYzFZiUi0e4BYkfqCL/7v8EpQXJdYjq40WTdJE2Y39XyMlJH82KqbFVHH5/ sdcA== X-Gm-Message-State: AOJu0Yy3j/eFCMdHItsap4RmuwRHjUQ5zqwXWVCWLmeQtnOrom22A7vy s9HkcJIejuQcPHWypVZrqXeEHuTjBj3C3sk6ad4= X-Received: by 2002:a7b:c397:0:b0:402:ea6f:e88f with SMTP id s23-20020a7bc397000000b00402ea6fe88fmr1496700wmj.5.1694597450118; Wed, 13 Sep 2023 02:30:50 -0700 (PDT) Received: from m1x-phil.lan (176-131-211-241.abo.bbox.fr. [176.131.211.241]) by smtp.gmail.com with ESMTPSA id l14-20020a1c790e000000b003fe4ca8decdsm1465100wme.31.2023.09.13.02.30.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 13 Sep 2023 02:30:49 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , kvm@vger.kernel.org, Paolo Bonzini , Stefan Hajnoczi , Michael Tokarev , Kevin Wolf , Richard Henderson , Daniel Henrique Barboza , Marcelo Tosatti , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v5 6/6] target/i386: Prohibit target specific KVM prototypes on user emulation Date: Wed, 13 Sep 2023 11:30:08 +0200 Message-ID: <20230913093009.83520-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230913093009.83520-1-philmd@linaro.org> References: <20230913093009.83520-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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 None of these target-specific prototypes should be used by user emulation. Remove their declaration there, so we get a compile failure if ever used (instead of having to deal with linker and its possible optimizations, such dead code removal). Suggested-by: Kevin Wolf Signed-off-by: Philippe Mathieu-Daudé --- target/i386/kvm/kvm_i386.h | 4 ++++ target/i386/cpu.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index 55d4e68c34..5ef73f0a1c 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -13,6 +13,10 @@ #include "sysemu/kvm.h" +#ifdef CONFIG_USER_ONLY +#error Cannot include kvm_i386.h from user emulation +#endif + #ifdef CONFIG_KVM #define kvm_pit_in_kernel() \ diff --git a/target/i386/cpu.c b/target/i386/cpu.c index c201ff26bd..db8ed6284d 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -26,7 +26,7 @@ #include "tcg/helper-tcg.h" #include "sysemu/reset.h" #include "sysemu/hvf.h" -#include "kvm/kvm_i386.h" +#include "sysemu/kvm.h" #include "sev.h" #include "qapi/error.h" #include "qemu/error-report.h" @@ -40,6 +40,7 @@ #include "exec/address-spaces.h" #include "hw/boards.h" #include "hw/i386/sgx-epc.h" +#include "kvm/kvm_i386.h" #endif #include "disas/capstone.h"