From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Chao Gao <chao.gao@intel.com>, kvm@vger.kernel.org
Cc: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: x86: Track supported ARCH_CAPABILITIES in kvm_caps
Date: Thu, 18 May 2023 17:32:31 +0800 [thread overview]
Message-ID: <b472b58d-0469-8a55-985c-1d966ce66419@intel.com> (raw)
In-Reply-To: <20230506030435.80262-1-chao.gao@intel.com>
On 5/6/2023 11:04 AM, Chao Gao wrote:
> to avoid computing the supported value at runtime every time.
>
> No functional change intended.
the value of kvm_get_arch_capabilities() can be changed due to
if (l1tf_vmx_mitigation != VMENTER_L1D_FLUSH_NEVER)
data |= ARCH_CAP_SKIP_VMENTRY_L1DFLUSH;
and l1tf_vmx_mitigation can be runtime changed by vmentry_l1d_flush
module param.
We need a detailed analysis that in no real case can
ARCH_CAP_SKIP_VMENTRY_L1DFLUSH bit change runtime.
> Signed-off-by: Chao Gao <chao.gao@intel.com>
> ---
>
> A new call site of kvm_get_arch_capabilities() is added by [1]. It should be
> replaced with the cached value in kvm_caps.
>
> [1] https://lore.kernel.org/all/20230504181827.130532-1-mizhang@google.com/
>
>
> arch/x86/kvm/x86.c | 5 +++--
> arch/x86/kvm/x86.h | 1 +
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 523c39a03c00..94aa70ec169c 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -1670,7 +1670,7 @@ static int kvm_get_msr_feature(struct kvm_msr_entry *msr)
> {
> switch (msr->index) {
> case MSR_IA32_ARCH_CAPABILITIES:
> - msr->data = kvm_get_arch_capabilities();
> + msr->data = kvm_caps.supported_arch_cap;
> break;
> case MSR_IA32_PERF_CAPABILITIES:
> msr->data = kvm_caps.supported_perf_cap;
> @@ -9523,6 +9523,7 @@ static int __kvm_x86_vendor_init(struct kvm_x86_init_ops *ops)
> kvm_caps.max_guest_tsc_khz = max;
> }
> kvm_caps.default_tsc_scaling_ratio = 1ULL << kvm_caps.tsc_scaling_ratio_frac_bits;
> + kvm_caps.supported_arch_cap = kvm_get_arch_capabilities();
> kvm_init_msr_lists();
> return 0;
>
> @@ -11879,7 +11880,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
> if (r)
> goto free_guest_fpu;
>
> - vcpu->arch.arch_capabilities = kvm_get_arch_capabilities();
> + vcpu->arch.arch_capabilities = kvm_caps.supported_arch_cap;
> vcpu->arch.msr_platform_info = MSR_PLATFORM_INFO_CPUID_FAULT;
> kvm_xen_init_vcpu(vcpu);
> kvm_vcpu_mtrr_init(vcpu);
> diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
> index c544602d07a3..d3e524bcc169 100644
> --- a/arch/x86/kvm/x86.h
> +++ b/arch/x86/kvm/x86.h
> @@ -29,6 +29,7 @@ struct kvm_caps {
> u64 supported_xcr0;
> u64 supported_xss;
> u64 supported_perf_cap;
> + u64 supported_arch_cap;
> };
>
> void kvm_spurious_fault(void);
>
> base-commit: b3c98052d46948a8d65d2778c7f306ff38366aac
next prev parent reply other threads:[~2023-05-18 9:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-06 3:04 Chao Gao
2023-05-18 9:32 ` Xiaoyao Li [this message]
2023-05-18 17:33 ` Sean Christopherson
2023-05-19 8:40 ` Chao Gao
2023-05-19 15:25 ` Sean Christopherson
2023-05-20 1:02 ` Pawan Gupta
2023-05-22 17:43 ` Sean Christopherson
2023-05-22 19:31 ` Xiaoyao Li
2023-05-22 21:23 ` Pawan Gupta
2023-05-23 1:00 ` Xiaoyao Li
2023-05-23 3:34 ` Pawan Gupta
2023-05-25 15:42 ` Xiaoyao Li
2023-05-25 20:33 ` Pawan Gupta
2023-05-22 20:54 ` Pawan Gupta
2023-05-23 4:47 ` Pawan Gupta
2023-05-22 14:23 ` Dave Hansen
2023-05-22 16:37 ` Sean Christopherson
2023-05-29 3:35 ` Chao Gao
2023-06-06 16:54 ` Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b472b58d-0469-8a55-985c-1d966ce66419@intel.com \
--to=xiaoyao.li@intel.com \
--cc=bp@alien8.de \
--cc=chao.gao@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®