[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aK8fmMGH0rB2LuA9@google.com>
Date: Wed, 27 Aug 2025 08:09:12 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Xin Li <xin@...or.com>
Cc: Chao Gao <chao.gao@...el.com>, kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
bp@...en8.de, dave.hansen@...ux.intel.com, hpa@...or.com, john.allen@....com,
mingo@...hat.com, minipli@...ecurity.net, mlevitsk@...hat.com,
pbonzini@...hat.com, rick.p.edgecombe@...el.com, tglx@...utronix.de,
weijiang.yang@...el.com, x86@...nel.org
Subject: Re: [PATCH v13 05/21] KVM: x86: Load guest FPU state when access
XSAVE-managed MSRs
On Tue, Aug 26, 2025, Xin Li wrote:
> On 8/21/2025 6:30 AM, Chao Gao wrote:
> > diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
> > index eb3088684e8a..d90f1009ac10 100644
> > --- a/arch/x86/kvm/x86.h
> > +++ b/arch/x86/kvm/x86.h
> > @@ -701,4 +701,28 @@ int ____kvm_emulate_hypercall(struct kvm_vcpu *vcpu, int cpl,
> > int kvm_emulate_hypercall(struct kvm_vcpu *vcpu);
> > +/*
> > + * Lock and/or reload guest FPU and access xstate MSRs. For accesses initiated
> > + * by host, guest FPU is loaded in __msr_io(). For accesses initiated by guest,
> > + * guest FPU should have been loaded already.
> > + */
> > +
> > +static inline void kvm_get_xstate_msr(struct kvm_vcpu *vcpu,
> > + struct msr_data *msr_info)
> > +{
> > + KVM_BUG_ON(!vcpu->arch.guest_fpu.fpstate->in_use, vcpu->kvm);
> > + kvm_fpu_get();
> > + rdmsrl(msr_info->index, msr_info->data);
>
> s/rdmsrl/rdmsrq/
>
> > + kvm_fpu_put();
> > +}
> > +
> > +static inline void kvm_set_xstate_msr(struct kvm_vcpu *vcpu,
> > + struct msr_data *msr_info)
> > +{
> > + KVM_BUG_ON(!vcpu->arch.guest_fpu.fpstate->in_use, vcpu->kvm);
> > + kvm_fpu_get();
> > + wrmsrl(msr_info->index, msr_info->data);
>
> s/wrmsrl/wrmsrq/
>
>
> Perhaps it's time to remove rdmsrl() and wrmsrl(), as keeping them around
> won't trigger any errors when the old APIs are still being used.
Yeah, we should bite the bullet and force in-flight code to adapt. I was _this_
close to making the same goof in the mediated PMU series, and IIRC it was only
some random conflict that alerted me to using the old/wrong APIs.
Powered by blists - more mailing lists