Message ID | 20221125040604.5051-10-weijiang.yang@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3796988wrr; Thu, 24 Nov 2022 22:11:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf65DAvBYFTmrOXpmEaxKJcicEgYpPBrqPQw1pH2p8o1ZVV8+OZ1jLlbXPe4YW5i3xEctasg X-Received: by 2002:aa7:9f0d:0:b0:56b:e16d:b08 with SMTP id g13-20020aa79f0d000000b0056be16d0b08mr17055865pfr.70.1669356691759; Thu, 24 Nov 2022 22:11:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669356691; cv=none; d=google.com; s=arc-20160816; b=grAwdpkiM2xjAjNq1C5UWop/pDXlah+AhHyeCSNGFOh7DpG4WmOQBLlG/CNECQdxDK W+iKGogVzpMlhL2fQi3mvE3L2aHREmj1wnapVla42B3xC6plviHu5mEdl7D1qaDSV+07 7JdD04SHjBci6+FFJmKvHMBuzNOLuWeQ6hQpaiHV6UZVDmDckY+iK2qcf+r/6/oP2lQ8 u5fWImiQDS6ozBbrQYPyZijFGgv7mz55302p8GGHb+D6lk5JHalSL5ehMavfZ9hsSdTY EbrbV/vs0/4GefyhkT/QwtNAJDvVAb9NsCsvBdx+pqiRdnR1emgLIrHNjs5luREWqFQN lzRw== 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=6mZJl0fRfCQELADKxoCc2M2kYvpfFGvIkMOD6HZY30Y=; b=IppCU5pEu7zJH+lQyHkuSmCHZnJ0MYjfvmWUj3P9Qav0p2lRjV+eT+38HLiGyDtTQw blKsFtzy4sGEmaOoOsBWFBwX5ydoiJfw6l23Mem3NrYbbN8dD45DBAUSSU10dJygA+XU R75avymg14i2i9LUFSOT/U9X8Saxk7DDIwDi48enLGhIoCwBbTY/cr4/E/XO07Tqu9tJ DJ/D4Y0qW1OQvzB/gb7sypKLzNiA4cUUMpSrL96e7oQMnUZpIKp1QfQ/2VAVQHMTC+FE aIfJ143NaWwR6Hzc1b41XknG+xUrEBv57deF8ghTCNS6klGbUBoMXDoQ0b7lvsgABDoM 785w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mBQKPIQQ; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g8-20020a636b08000000b0045466821a09si3380690pgc.371.2022.11.24.22.11.18; Thu, 24 Nov 2022 22:11:31 -0800 (PST) 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=mBQKPIQQ; 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 S229726AbiKYGKa (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Fri, 25 Nov 2022 01:10:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229694AbiKYGKL (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 25 Nov 2022 01:10:11 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B33A41FFB6; Thu, 24 Nov 2022 22:10:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669356610; x=1700892610; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=b0HflqpockXVYHP3iADSezT3+7UDyiWMjXkwdZSqFCg=; b=mBQKPIQQCPtGFRuenM7zc53TkNMuXdWh+SdA050qvxUm4KTSn58S0sJu EOxh3b+BghG/X7E674OOzi3YA8rSuZZrSgV2llcStjYnE7hLh4jXNiYzt tvquV/ZgwQFRIZHVHMsgJActubZ79p6lt5xaRAZ67T4zSxooo35pQdkXH jKL9Sfo5HWOSW0oK/KnwfP0c3Hb0qryUXLDJQywrkYchFBlxQrYOhOW+L TMsq2NZLIhA8vdOUohfXzQXmmvmF8V39Nsx0e2tsI9JNinl1uWZ+CjeO/ 11k3AyhtFhA4Y3+HK1XGKJ3o/9HAQyQchG3gyU4xgFXo9rFw9TPKVCaLK g==; X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="313116824" X-IronPort-AV: E=Sophos;i="5.96,192,1665471600"; d="scan'208";a="313116824" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2022 22:10:06 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="784838490" X-IronPort-AV: E=Sophos;i="5.96,192,1665471600"; d="scan'208";a="784838490" Received: from embargo.jf.intel.com ([10.165.9.183]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2022 22:10:06 -0800 From: Yang Weijiang <weijiang.yang@intel.com> To: seanjc@google.com, pbonzini@redhat.com, jmattson@google.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: like.xu.linux@gmail.com, kan.liang@linux.intel.com, wei.w.wang@intel.com, weijiang.yang@intel.com Subject: [PATCH v2 09/15] KVM: x86: Refine the matching and clearing logic for supported_xss Date: Thu, 24 Nov 2022 23:05:58 -0500 Message-Id: <20221125040604.5051-10-weijiang.yang@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221125040604.5051-1-weijiang.yang@intel.com> References: <20221125040604.5051-1-weijiang.yang@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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750447362631167165?= X-GMAIL-MSGID: =?utf-8?q?1750447362631167165?= |
Series |
Introduce Architectural LBR for vPMU
|
|
Commit Message
Yang, Weijiang
Nov. 25, 2022, 4:05 a.m. UTC
From: Paolo Bonzini <pbonzini@redhat.com> Refine the code path of the existing clearing of supported_xss in this way: initialize the supported_xss with the filter of KVM_SUPPORTED_XSS mask and update its value in a bit clear manner (rather than bit setting). Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Like Xu <like.xu@linux.intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Yang Weijiang <weijiang.yang@intel.com> --- arch/x86/kvm/vmx/vmx.c | 5 +++-- arch/x86/kvm/x86.c | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-)
Comments
On Thu, Nov 24, 2022, Yang Weijiang wrote: > From: Paolo Bonzini <pbonzini@redhat.com> > > Refine the code path of the existing clearing of supported_xss in this way: > initialize the supported_xss with the filter of KVM_SUPPORTED_XSS mask and > update its value in a bit clear manner (rather than bit setting). > > Suggested-by: Sean Christopherson <seanjc@google.com> > Signed-off-by: Like Xu <like.xu@linux.intel.com> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > Signed-off-by: Yang Weijiang <weijiang.yang@intel.com> > --- > arch/x86/kvm/vmx/vmx.c | 5 +++-- > arch/x86/kvm/x86.c | 6 +++++- > 2 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index 9bd52ad3bbf4..2ab4c33b5008 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -7738,9 +7738,10 @@ static __init void vmx_set_cpu_caps(void) > kvm_cpu_cap_set(X86_FEATURE_UMIP); > > /* CPUID 0xD.1 */ > - kvm_caps.supported_xss = 0; This needs to stay until VMX actually supports something. > - if (!cpu_has_vmx_xsaves()) > + if (!cpu_has_vmx_xsaves()) { > kvm_cpu_cap_clear(X86_FEATURE_XSAVES); > + kvm_caps.supported_xss = 0; This is already handled in common KVM. > + } > > /* CPUID 0x80000001 and 0x7 (RDPID) */ > if (!cpu_has_vmx_rdtscp()) { > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 74c858eaa1ea..889be0c9176d 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -217,6 +217,8 @@ static struct kvm_user_return_msrs __percpu *user_return_msrs; > | XFEATURE_MASK_BNDCSR | XFEATURE_MASK_AVX512 \ > | XFEATURE_MASK_PKRU | XFEATURE_MASK_XTILE) > > +#define KVM_SUPPORTED_XSS 0 > + > u64 __read_mostly host_efer; > EXPORT_SYMBOL_GPL(host_efer); > > @@ -11999,8 +12001,10 @@ int kvm_arch_hardware_setup(void *opaque) > > rdmsrl_safe(MSR_EFER, &host_efer); > > - if (boot_cpu_has(X86_FEATURE_XSAVES)) > + if (boot_cpu_has(X86_FEATURE_XSAVES)) { > rdmsrl(MSR_IA32_XSS, host_xss); > + kvm_caps.supported_xss = host_xss & KVM_SUPPORTED_XSS; > + } > > kvm_init_pmu_capability(); > > -- > 2.27.0 >
On 1/28/2023 5:46 AM, Sean Christopherson wrote: > On Thu, Nov 24, 2022, Yang Weijiang wrote: >> From: Paolo Bonzini <pbonzini@redhat.com> >> >> Refine the code path of the existing clearing of supported_xss in this way: >> initialize the supported_xss with the filter of KVM_SUPPORTED_XSS mask and >> update its value in a bit clear manner (rather than bit setting). >> >> Suggested-by: Sean Christopherson <seanjc@google.com> >> Signed-off-by: Like Xu <like.xu@linux.intel.com> >> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> >> Signed-off-by: Yang Weijiang <weijiang.yang@intel.com> >> --- >> arch/x86/kvm/vmx/vmx.c | 5 +++-- >> arch/x86/kvm/x86.c | 6 +++++- >> 2 files changed, 8 insertions(+), 3 deletions(-) >> >> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c >> index 9bd52ad3bbf4..2ab4c33b5008 100644 >> --- a/arch/x86/kvm/vmx/vmx.c >> +++ b/arch/x86/kvm/vmx/vmx.c >> @@ -7738,9 +7738,10 @@ static __init void vmx_set_cpu_caps(void) >> kvm_cpu_cap_set(X86_FEATURE_UMIP); >> >> /* CPUID 0xD.1 */ >> - kvm_caps.supported_xss = 0; > This needs to stay until VMX actually supports something. Will modify this patch. > >> - if (!cpu_has_vmx_xsaves()) >> + if (!cpu_has_vmx_xsaves()) { >> kvm_cpu_cap_clear(X86_FEATURE_XSAVES); >> + kvm_caps.supported_xss = 0; > This is already handled in common KVM. > >> + } >> >> /* CPUID 0x80000001 and 0x7 (RDPID) */ >> if (!cpu_has_vmx_rdtscp()) { >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >> index 74c858eaa1ea..889be0c9176d 100644 >> --- a/arch/x86/kvm/x86.c >> +++ b/arch/x86/kvm/x86.c >> @@ -217,6 +217,8 @@ static struct kvm_user_return_msrs __percpu *user_return_msrs; >> | XFEATURE_MASK_BNDCSR | XFEATURE_MASK_AVX512 \ >> | XFEATURE_MASK_PKRU | XFEATURE_MASK_XTILE) >> >> +#define KVM_SUPPORTED_XSS 0 >> + >> u64 __read_mostly host_efer; >> EXPORT_SYMBOL_GPL(host_efer); >> >> @@ -11999,8 +12001,10 @@ int kvm_arch_hardware_setup(void *opaque) >> >> rdmsrl_safe(MSR_EFER, &host_efer); >> >> - if (boot_cpu_has(X86_FEATURE_XSAVES)) >> + if (boot_cpu_has(X86_FEATURE_XSAVES)) { >> rdmsrl(MSR_IA32_XSS, host_xss); >> + kvm_caps.supported_xss = host_xss & KVM_SUPPORTED_XSS; >> + } >> >> kvm_init_pmu_capability(); >> >> -- >> 2.27.0 >>
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 9bd52ad3bbf4..2ab4c33b5008 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7738,9 +7738,10 @@ static __init void vmx_set_cpu_caps(void) kvm_cpu_cap_set(X86_FEATURE_UMIP); /* CPUID 0xD.1 */ - kvm_caps.supported_xss = 0; - if (!cpu_has_vmx_xsaves()) + if (!cpu_has_vmx_xsaves()) { kvm_cpu_cap_clear(X86_FEATURE_XSAVES); + kvm_caps.supported_xss = 0; + } /* CPUID 0x80000001 and 0x7 (RDPID) */ if (!cpu_has_vmx_rdtscp()) { diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 74c858eaa1ea..889be0c9176d 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -217,6 +217,8 @@ static struct kvm_user_return_msrs __percpu *user_return_msrs; | XFEATURE_MASK_BNDCSR | XFEATURE_MASK_AVX512 \ | XFEATURE_MASK_PKRU | XFEATURE_MASK_XTILE) +#define KVM_SUPPORTED_XSS 0 + u64 __read_mostly host_efer; EXPORT_SYMBOL_GPL(host_efer); @@ -11999,8 +12001,10 @@ int kvm_arch_hardware_setup(void *opaque) rdmsrl_safe(MSR_EFER, &host_efer); - if (boot_cpu_has(X86_FEATURE_XSAVES)) + if (boot_cpu_has(X86_FEATURE_XSAVES)) { rdmsrl(MSR_IA32_XSS, host_xss); + kvm_caps.supported_xss = host_xss & KVM_SUPPORTED_XSS; + } kvm_init_pmu_capability();