From nobody Mon May 13 00:10:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1694597464; cv=none; d=zohomail.com; s=zohoarc; b=Q6jtc4ytk/FGJAxlRWY41BcY9Uvwc0PWVuPYULh8t+IwHg4RnoTP/5kjT0JZDv2f31WvZ5GBtnq8OFHbYlrAQiTG+M5O+Lz6Qb2abg6OLqDrX7Cv9yjL0unn4azJ06BeL0vNZ39lGMuSXiHGnH5R8CI7plVVen4nw+wU7e3OLKE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694597464; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1Ef+xjoTCq+y/8i7W8/XmeY8Z3xpQKPoxBTn9z9VDh0=; b=ZoOh5ZLly8lyui166c8brm7A/Gr0amrWvUyvUSyDrcDfnTwJUnpsFiJvEtYKlrkFpLlJycWvlIWGo/7deUkhJjm2RZ1uS0cPLEmCtOj4pHGPUGv1/HRpGJWyzoo21UoTWrP76kTBEI6qMgP2RqCpFvhDcTqskuJ2XrOIvS82mLc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694597464699530.8643184513681; Wed, 13 Sep 2023 02:31:04 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IF81qLWQLTZIurHyfB6n9nBdI6JMAN0Bl+M0T/v9Rb/vaARKtVVv7S5cMZos75Ep62Qy+3cVg== 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=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=20Mathieu-Daud=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694597465509100002 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 expans= ion time") Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 **err= p) env->cpuid_xlevel2 =3D env->cpuid_min_xlevel2; } =20 - if (kvm_enabled()) { - kvm_hyperv_expand_features(cpu, errp); + if (kvm_enabled() && !kvm_hyperv_expand_features(cpu, errp)) { + return; } } =20 --=20 2.41.0 From nobody Mon May 13 00:10:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1694597513; cv=none; d=zohomail.com; s=zohoarc; b=SKqArl0Y+qybNOtQzRE/qIGrNsgB4oMxIz4/KuiWcyqfDtUqYXCVfwu2HaAiRhX8dNacgvTNq3Xt307oaFHGSyLgfV+Y//a2pn30Gs2y7nbSAuZoJvag0DuCgyIRJ2ULljEQ4jTN3Ry75tMIOYhn5YfZUpIIOdUAnjyxDWaHbsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694597513; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EJ4BcJE7pBMWigDDKZYpQ7Lkem5BrBoGp2n7HRl4RO0=; b=jdQwPasqTlScAITo6xpfajEAfWlzmj3EGB8SGYazHLr+btHerILQ02clTGd0+UcCA6DYcVr6ybkcVK6dJ9Huv3pqYl7WlfCNnVBpkbbC0WN1rnMiTM1R3eGvaThvGLXhRUpuwXzWM/geRQiYNvEIzJ32cm3K9BQrcmQgCdWRK84= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694597513323363.7789412200091; Wed, 13 Sep 2023 02:31:53 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IFdROd97h4uzNRN61vFnZYaTWPh6qjyAOrmyyYqJyeWXB3VMK5YJssReCo2Y5Jy+veDjKYKRg== 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=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=20Mathieu-Daud=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694597514788100003 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=C3=A9 --- 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 =3D 0; @@ -6247,8 +6247,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, *ebx &=3D 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_ED= X_ARCH_LBR)) { x86_cpu_get_supported_cpuid(0x1C, 0, eax, ebx, ecx, edx); *edx =3D 0; } @@ -6322,9 +6321,8 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, } else { *ecx &=3D ~XSTATE_ARCH_LBR_MASK; } - } else if (count =3D=3D 0xf && - accel_uses_host_cpuid() && cpu->enable_pmu && - (env->features[FEAT_7_0_EDX] & CPUID_7_0_EDX_ARCH_LBR))= { + } else if (count =3D=3D 0xf && cpu->enable_pmu + && (env->features[FEAT_7_0_EDX] & CPUID_7_0_EDX_ARCH_LB= R)) { x86_cpu_get_supported_cpuid(0xD, count, eax, ebx, ecx, edx); } else if (count < ARRAY_SIZE(x86_ext_save_areas)) { const ExtSaveArea *esa =3D &x86_ext_save_areas[count]; --=20 2.41.0 From nobody Mon May 13 00:10:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1694597502; cv=none; d=zohomail.com; s=zohoarc; b=Q+ea25daLTpzdikmJqiamYibFb7HtESM62q+dOhB9itfvT5nNKSKt+YJqqW6SdbMFblb2HzWW0059v4vklS/sdJNXf4zeWMO81nNPfhJMCVoC9VexeqkVJd/H1BBzImjPFv9AryBi1iPvl6NG97n4BNJIySbU1q/Kk7wIgSh3Rs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694597502; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZR4T6NlMHpArLYrHIDyBj0HhdFN73kI81RfJc3c6SLI=; b=Q0rIbd013qJXRC3HjjrBhbmT5z+tts+fA8ppSA6eWfFEVCtOoorpPMisJFru4eRc8DGr/g7P/Um20bsct4yEqjV68CE8JU9CiXnedrpUv8wavfdIXAdKBljznC7p4snS2LzRweLRI97hgWbnvdzA+JkWnJB5dNmb6/7dGOI/gnc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694597502246891.1335001576567; Wed, 13 Sep 2023 02:31:42 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IEuMwkotR/4nuJtdSguECUmUFieAMVw4UlYscziVUebi6jxfT7Sful3RnFPx8QmcRQyElHHxA== 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=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=20Mathieu-Daud=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694597502730100001 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=3Dclang \ --target-list=3Dx86_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 funct= ion `cpu_x86_cpuid': cpu.c:(.text+0x1374): undefined reference to `kvm_arch_get_supported_cpui= d' /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in funct= ion `x86_cpu_filter_features': cpu.c:(.text+0x81c2): undefined reference to `kvm_arch_get_supported_cpui= d' /usr/bin/ld: cpu.c:(.text+0x81da): undefined reference to `kvm_arch_get_s= upported_cpuid' /usr/bin/ld: cpu.c:(.text+0x81f2): undefined reference to `kvm_arch_get_s= upported_cpuid' /usr/bin/ld: cpu.c:(.text+0x820a): undefined reference to `kvm_arch_get_s= upported_cpuid' /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:cpu.c:(.t= ext+0x8225): more undefined references to `kvm_arch_get_supported_cpuid' fo= llow clang: error: linker command failed with exit code 1 (use -v to see invoc= ation) ninja: build stopped: subcommand failed. For the record, this is because '--enable-debug' disables optimizations (CFLAGS=3D-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 =3D kvm_arch_get_supported_cpuid(kvm_state, func, index, R_EA= X); *ebx =3D kvm_arch_get_supported_cpuid(kvm_state, func, index, R_EB= X); *ecx =3D kvm_arch_get_supported_cpuid(kvm_state, func, index, R_EC= X); *edx =3D kvm_arch_get_supported_cpuid(kvm_state, func, index, R_ED= X); } else if (0) { *eax =3D 0; *ebx =3D 0; *ecx =3D 0; *edx =3D 0; } else { *eax =3D 0; *ebx =3D 0; *ecx =3D 0; *edx =3D 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=C3=A9 --- 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 =3D=3D 0) { + uint32_t eax_0_unused, ebx_0, ecx_0, edx_0_unused; + /* Maximum ECX value for sub-leaves */ *eax =3D env->cpuid_level_func7; *ebx =3D 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_E= BX) & - 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 &=3D ~CPUID_7_0_EBX_SGX; } =20 - 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_E= CX) & - 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 &=3D ~CPUID_7_0_ECX_SGX_LC; } } else if (count =3D=3D 1) { @@ -7150,14 +7150,14 @@ static void x86_cpu_filter_features(X86CPU *cpu, bo= ol verbose) mark_unavailable_features(cpu, w, unavailable_features, prefix); } =20 - if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) && - kvm_enabled()) { - KVMState *s =3D CPU(cpu)->kvm_state; - uint32_t eax_0 =3D kvm_arch_get_supported_cpuid(s, 0x14, 0, R_EAX); - uint32_t ebx_0 =3D kvm_arch_get_supported_cpuid(s, 0x14, 0, R_EBX); - uint32_t ecx_0 =3D kvm_arch_get_supported_cpuid(s, 0x14, 0, R_ECX); - uint32_t eax_1 =3D kvm_arch_get_supported_cpuid(s, 0x14, 1, R_EAX); - uint32_t ebx_1 =3D 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); =20 if (!eax_0 || ((ebx_0 & INTEL_PT_MINIMAL_EBX) !=3D INTEL_PT_MINIMAL_EBX) || --=20 2.41.0 From nobody Mon May 13 00:10:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1694597498; cv=none; d=zohomail.com; s=zohoarc; b=Bs8phBUvcg85dPm/tcuQTp+x7nWfa1VwYF+cLX2nuslcSb+BRTDSA1Yif14k7yIfImDCRyCzlmm6d9V/bvsVRRaArGu4mJh/ug29ojx5DXFF3O/nZwUZJw+w7UJzOLK3dOJgG+5vaSMgqnXzcmGvAaF5sX15LTrksVXR/Fh2gnA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694597498; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4Qlz4UlYziPNq8F2NThvhMEsqE2XcvVN84mcny9xQ0s=; b=e0WXArvhLlL0y4lgIWjbkZiHGfD2QO4WM3hzZyaSJ9e8m+2F8LHg9bwlClvszq/K26wIbLntNmgmRIZrSj5tpOpZVVec3JiGKIB5j5cPS9g1N2H3yZOW0zrFCtzCljD632YbMGUXgFMWIsXfpnjEUCjrjg8CLJowCOJM8FkoXnA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694597498039132.69763182380768; Wed, 13 Sep 2023 02:31:38 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IEWpdoM+WDhrPjgODkxBAhlOnSq5m//vf86ss/9hM1maxstZ2t2i4/KaLoJUfi0o2DpthLKLQ== 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=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=20Mathieu-Daud=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694597500343100003 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=C3=A9 --- 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]; } =20 -/* - * 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 =3D &feature_word_info[w]; - uint64_t r =3D 0; - int i; - - for (i =3D 0; i < 64; i++) { - uint64_t f =3D 1ULL << i; - - /* If the feature name is known, it is implicitly considered migra= table, - * unless it is explicitly set in unmigratable_flags */ - if ((wi->migratable_flags & f) || - (wi->feat_names[i] && !(wi->unmigratable_flags & f))) { - r |=3D 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(Err= or **errp) =20 #endif /* !CONFIG_USER_ONLY */ =20 +/* + * 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 =3D &feature_word_info[w]; + uint64_t r =3D 0; + int i; + + for (i =3D 0; i < 64; i++) { + uint64_t f =3D 1ULL << i; + + /* If the feature name is known, it is implicitly considered migra= table, + * unless it is explicitly set in unmigratable_flags */ + if ((wi->migratable_flags & f) || + (wi->feat_names[i] && !(wi->unmigratable_flags & f))) { + r |=3D f; + } + } + return r; +} + uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, bool migratable_only) { --=20 2.41.0 From nobody Mon May 13 00:10:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1694597504; cv=none; d=zohomail.com; s=zohoarc; b=N3bdyScPI9tKXabSMUkYdHY+Me+P5tqKQGHIJZ6Or7cikXcw7pGA/A+dyrroSEiAkVYFVYZX3tX0IChAQ70tOA8m/iLNF9YvPM3lKxpSctBQdo05gCKbOd19lEOgiBVgR0LA57oisLCu2loRa9xYkQ3XZjjvfdyzCz8J9sDkGb8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694597504; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eKbeAfeEWeYWq6ZMSQ2gP4OMkhbj3lmxF1/S1lGxkFI=; b=kRHFWEPB+mX/EFonD0QW3yeYOo+G42/o3XGMxMlAb6JHXjLQ/4BqudaCki9Zf9KthwEIa4yY/TdeY24l/qAvq6CmbE1ijHcdQSRuGWvMicn8za2quLF29ov7NWQYg5/BwOzb/JS5KsWoBU3xshu4R/Zfkv52/gs/LrUYDLYCsw8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694597504929238.31770663639668; Wed, 13 Sep 2023 02:31:44 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IFygu3BAr+7UcI3dOenQQ5WxeefjdnW+wv88rHPugEcR1Z+feWe0l1BCnKAc2a9M86WKXr2Zg== 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=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=20Mathieu-Daud=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694597506565100001 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=C3=A9 --- 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(Erro= r **errp) return cpu_list; } =20 -#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, u= int32_t index, } } =20 +#else /* CONFIG_USER_ONLY */ + +uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, + bool migratable_only) +{ + FeatureWordInfo *wi =3D &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 =3D 0; + *ebx =3D 0; + *ecx =3D 0; + *edx =3D 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 =3D 0; + *ebx =3D 0; + *ecx =3D 0; + *edx =3D 0; +} + +#endif /* !CONFIG_USER_ONLY */ + /* * Only for builtin_x86_defs models initialized with x86_register_cpudef_t= ypes. */ @@ -6918,7 +6948,6 @@ static void x86_cpu_enable_xsave_components(X86CPU *c= pu) CPUX86State *env =3D &cpu->env; int i; uint64_t mask; - static bool request_perm; =20 if (!(env->features[FEAT_1_ECX] & CPUID_EXT_XSAVE)) { env->features[FEAT_XSAVE_XCR0_LO] =3D 0; @@ -6934,11 +6963,15 @@ static void x86_cpu_enable_xsave_components(X86CPU = *cpu) } } =20 +#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 =3D true; } +#endif /* !CONFIG_USER_ONLY */ =20 env->features[FEAT_XSAVE_XCR0_LO] =3D mask & CPUID_XSTATE_XCR0_MASK; env->features[FEAT_XSAVE_XCR0_HI] =3D mask >> 32; @@ -7119,9 +7152,11 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **er= rp) env->cpuid_xlevel2 =3D env->cpuid_min_xlevel2; } =20 +#ifndef CONFIG_USER_ONLY if (kvm_enabled() && !kvm_hyperv_expand_features(cpu, errp)) { return; } +#endif /* !CONFIG_USER_ONLY */ } =20 /* --=20 2.41.0 From nobody Mon May 13 00:10:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1694597523; cv=none; d=zohomail.com; s=zohoarc; b=XGj7fvFMnPQyzTKPOtK9xb9MhbSLq+bFHL501B8nVGCGTxuHF/lMQtJvz7J6FjeKI7hTNT6gBwx6GzHxnTOC3FydgR1wXBAY7IHMw8mbKX55zd+AChM1wB8BhO4Qzgc4+Eq7eEWOqEI/sUDTeL1pnucW6PqNKAZc3UD7IH8lIH4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694597523; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jtT3ML1tHJnWRfmIXQrD6YCHmxZTPOtervgh4drQU7s=; b=NwfENRTMuS/qECGkpmq1ImML7Kitsh8zzcbjKv5bmnkwd+BgXy0IxhdP4ivZ41rG9ErRI6wj1qllXjmmxCJdCZB64tdB5kn+3Xgcrf77TGHhwUU51j8jeX2ypwCcQksMjiMj2Suf41dl3aDYr2wzjE+S0AMJmIvbOCnPr5q8HV8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694597523419463.76978465085926; Wed, 13 Sep 2023 02:32:03 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IGD2WPDLCyweINrRoQof3jTKC1mX87q6WXI/fyFE1kXJNwVQRZhwnclukg8a31JArVaogLfzA== 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=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=20Mathieu-Daud=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694597524267100001 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=C3=A9 --- 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 @@ =20 #include "sysemu/kvm.h" =20 +#ifdef CONFIG_USER_ONLY +#error Cannot include kvm_i386.h from user emulation +#endif + #ifdef CONFIG_KVM =20 #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 =20 #include "disas/capstone.h" --=20 2.41.0