From: Sean Christopherson <seanjc@google.com>
To: Like Xu <like.xu.linux@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Joerg Roedel <joro@8bytes.org>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] KVM: x86: Sync the states size with the XCR0/IA32_XSS at any time
Date: Fri, 21 Jan 2022 15:41:53 +0000 [thread overview]
Message-ID: <YerUQa+SN/xWMhvB@google.com> (raw)
In-Reply-To: <eacf3f83-96f5-301e-de54-8a0f6c8f9fe5@gmail.com>
On Fri, Jan 21, 2022, Like Xu wrote:
> From: Like Xu <likexu@tencent.com>
>
> XCR0 is reset to 1 by RESET but not INIT and IA32_XSS is zeroed by
> both RESET and INIT. The kvm_set_msr_common()'s handling of MSR_IA32_XSS
> also needs to update kvm_update_cpuid_runtime(). In the above cases, the
> size in bytes of the XSAVE area containing all states enabled by XCR0 or
> (XCRO | IA32_XSS) needs to be updated.
>
> For simplicity and consistency, legacy helpers are used to write values
s/legacy/existing
"legacy" refers to something that is outdated/deprecated, which isn't what you
intend here.
> and call kvm_update_cpuid_runtime(), and it's not exactly a fast path.
>
> Fixes: a554d207dc46 ("KVM: X86: Processor States following Reset or INIT")
> Signed-off-by: Like Xu <likexu@tencent.com>
> ---
> v1 -> v2 Changelog:
> - Strongly prefer that use the helpers to write the values; (Sean)
> - Postpone IA32_XSS test cases once non-zero values are supported; (Paolo)
> - User space may call SET_CPUID2 after kvm_vcpu_reset(init_event=false); (Paolo)
>
> arch/x86/kvm/x86.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 55518b7d3b96..22d4b1d15e94 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -11256,7 +11256,7 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
>
> vcpu->arch.msr_misc_features_enables = 0;
>
> - vcpu->arch.xcr0 = XFEATURE_MASK_FP;
> + __kvm_set_xcr(vcpu, 0, XFEATURE_MASK_FP);
> }
>
> /* All GPRs except RDX (handled below) are zeroed on RESET/INIT. */
> @@ -11273,7 +11273,7 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
> cpuid_0x1 = kvm_find_cpuid_entry(vcpu, 1, 0);
> kvm_rdx_write(vcpu, cpuid_0x1 ? cpuid_0x1->eax : 0x600);
>
> - vcpu->arch.ia32_xss = 0;
> + __kvm_set_msr(vcpu, MSR_IA32_XSS, 0, true);
This relies on a prep patch to invoke kvm_update_cpuid_runtime() in kvm_set_msr_common()
for MSR_IA32_XSS, no?
> static_call(kvm_x86_vcpu_reset)(vcpu, init_event);
>
> --
> 2.33.1
>
>
next prev parent reply other threads:[~2022-01-21 15:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-17 8:26 [PATCH] KVM: x86: Update the states size cpuid even if XCR0/IA32_XSS is reset Like Xu
2022-01-17 17:32 ` Paolo Bonzini
2022-01-21 4:09 ` [PATCH v2] KVM: x86: Sync the states size with the XCR0/IA32_XSS at any time Like Xu
2022-01-21 15:41 ` Sean Christopherson [this message]
2022-01-23 4:37 ` [PATCH v3] KVM: x86: Sync the states size with the XCR0/IA32_XSS at, " Like Xu
2022-01-26 16:37 ` Sean Christopherson
2022-01-26 17:08 ` Paolo Bonzini
2022-01-18 18:30 ` [PATCH] KVM: x86: Update the states size cpuid even if XCR0/IA32_XSS is reset Sean Christopherson
2022-01-19 7:25 ` Like Xu
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=YerUQa+SN/xWMhvB@google.com \
--to=seanjc@google.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=like.xu.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
/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
Powered by JetHome