Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp120273rwe; Thu, 13 Apr 2023 23:28:58 -0700 (PDT) X-Google-Smtp-Source: AKy350aoTrWkk/4TXVb6fHUVsxg7RfTQD/cpspP+zVp8cFDRLIRHkQ/ehXAxsTMlKtft47hHX8CV X-Received: by 2002:a17:902:aa05:b0:1a6:9762:6eee with SMTP id be5-20020a170902aa0500b001a697626eeemr1275015plb.40.1681453738357; Thu, 13 Apr 2023 23:28:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681453738; cv=none; d=google.com; s=arc-20160816; b=1APQ/mWPyZvXYgNmslzFGidHGpPGWsS3uzX3JZNTTK4RhyX7ZftURDaf3hxo2yhX+I td4Zb/xM4QL87obXBhj09dE0ziEo+8Yv6nmXFduW9hluynkBuFDoDQIWJWo3qGlqPmHt wksNNMudt04R5nWMeH2oh8nStuhGOnKTJCXPmx7Ern/Qh3S10NjZnjLJauJMccWZ1xNE MdKeR0kB/1vTgHnmjLvj+j8LldjLEP3Y/k50qx8RoTivgG+hIQJ3E+9+Hb7kAtAiA7yX 2LPjBihAhaP5u6FqKxXPrdBMd0zPXDfUEtoV430vU1m2NoBje5H97T22HRLqB1q0pu1M ejnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uwab5G8uZ6qxNBBF63MyM9bTEfLDZz6encTXcaee7OY=; b=gOL83YasOnTLAnH6lEkmkCd3YNHVVFXs86aO7WtR+p9Z3kkEUGUN/q0CTgTG1DH4IU VrolD9cuD/Op4xF21wWUVfAtryF18AK/ctsKREvpro8G6RLVGkAQ3LuvYu4QkPEGcEU0 IXvgPcbEreNzLwIcghxQknbKdmXRbRm3SoKZVoc+pQyKUIcLmJD94986P/WoVbJ3Ic1g bdRekLnBCLOzwW/BrEk970ssTdljW3RK6Jis0bbNDQDMf6iZ0W5tVY4Q6unXSk0ILu7Z FR8ae2NaI+OK4ttPkHa/D+al90h/pTiZxy3UoAu3frmJ2ggKjFdGY95EoWgqqvU+xwQ9 WKbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a16edSFr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y16-20020a170902b49000b001a68ebc3e50si2557788plr.511.2023.04.13.23.28.46; Thu, 13 Apr 2023 23:28:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a16edSFr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230110AbjDNG0V (ORCPT + 99 others); Fri, 14 Apr 2023 02:26:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230030AbjDNG0S (ORCPT ); Fri, 14 Apr 2023 02:26:18 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 435C16A42; Thu, 13 Apr 2023 23:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681453577; x=1712989577; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3v96gRV+sEhmeJkt6bLopXdOVIbOcXfn+M8hUk0aLec=; b=a16edSFrIgSJnGu0rB6WQQoEpFaIdU3Dbi8O3EOEM1AzOhL3WX19EXDL MPolO9O5tK6yq6rEgEdw8EuGAEzdz3MkamWeQiiF562ZAzMpO1bcDICsa U8Uk099+EXKRUiGuyTtL9jTS6KkO25Uq8ydU1ltU8WmJqeP90C9GiCWzO qAf70liVPIUSSpvj+pz8s4rJkfRCO1PiSoIZw7W/UYguc+PNZ9Hf2K9ZH 4NxfkrTYFPgmeZhFc1fxClLgXifGjv4pxm5zFLRW413Bu2kNekcftoWEI V2Qs8zxl1H9t1hvL5xQw4Aafj6g1jeYZIG8kqg2BE9xfUtKqD7AzV8WA8 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10679"; a="341892723" X-IronPort-AV: E=Sophos;i="5.99,195,1677571200"; d="scan'208";a="341892723" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2023 23:26:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10679"; a="935885827" X-IronPort-AV: E=Sophos;i="5.99,195,1677571200"; d="scan'208";a="935885827" Received: from spr.sh.intel.com ([10.239.53.106]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2023 23:26:13 -0700 From: Chao Gao To: kvm@vger.kernel.org Cc: Jiaan Lu , Zhang Chen , Chao Gao , Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 03/11] KVM: x86: Advertise BHI_CTRL support Date: Fri, 14 Apr 2023 14:25:24 +0800 Message-Id: <20230414062545.270178-4-chao.gao@intel.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230414062545.270178-1-chao.gao@intel.com> References: <20230414062545.270178-1-chao.gao@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Chen Add 100% kvm-only feature for BHI_CTRL because the kernel doesn't use it at all. BHI_CTRL is enumerated by CPUID.7.2.EDX[4]. If supported, BHI_DIS_S (bit 10) of IA32_SPEC_CTRL MSR can be used to enable BHI_DIS_S behavior. Note that KVM does not intercept guests' IA32_SPEC_CTRL MSR accesses after a non-zero is written to the MSR. Therefore, guests can already toggle the BHI_DIS_S bit if the host supports BHI_CTRL, and no extra code is needed to allow guests to toggle the bit. Signed-off-by: Zhang Chen Signed-off-by: Chao Gao Tested-by: Jiaan Lu --- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/reverse_cpuid.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index f024c3ac2203..7cdd859d09a2 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -686,7 +686,7 @@ void kvm_set_cpu_caps(void) ); kvm_cpu_cap_init_kvm_defined(CPUID_7_2_EDX, - SF(RRSBA_CTRL) + SF(RRSBA_CTRL) | F(BHI_CTRL) ); kvm_cpu_cap_mask(CPUID_8000_0001_ECX, diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h index 72bad8314a9c..e7e70c9aa384 100644 --- a/arch/x86/kvm/reverse_cpuid.h +++ b/arch/x86/kvm/reverse_cpuid.h @@ -50,6 +50,7 @@ enum kvm_only_cpuid_leafs { /* Intel-defined sub-features, CPUID level 0x00000007:2 (EDX) */ #define KVM_X86_FEATURE_RRSBA_CTRL KVM_X86_FEATURE(CPUID_7_2_EDX, 2) +#define X86_FEATURE_BHI_CTRL KVM_X86_FEATURE(CPUID_7_2_EDX, 4) struct cpuid_reg { u32 function; -- 2.40.0