Re: [PATCH v3 1/1] x86/kvm/fpu: Mask guest fpstate->xfeatures with guest_supported_xcr0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 16, 2022 at 8:45 AM Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:
>
> On 2/16/22 08:48, Leonardo Bras Soares Passos wrote:
> > On Mon, Feb 14, 2022 at 6:56 AM Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:
> >> On top of this patch, we can even replace vcpu->arch.guest_supported_xcr0
> >> with vcpu->arch.guest_fpu.fpstate->user_xfeatures. Probably with local
> >> variables or wrapper functions though, so as to keep the code readable.
> >
> > You mean another patch (#2) removing guest_supported_xcr0 field from
> > kvm_vcpu_arch ?
> > (and introducing something like kvm_guest_supported_xcr() ?)
>
> Yes, introducing both kvm_guest_supported_xcr0() that just reads
> user_xfeatures, and kvm_guest_supported_xfd() as below.

Oh, I see. Thanks for clearing that up!

>
> >> For example:
> >>
> >> static inline u64 kvm_guest_supported_xfd()
> >> {
> >>          u64 guest_supported_xcr0 = vcpu->arch.guest_fpu.fpstate->user_xfeatures;
> >>
> >>          return guest_supported_xcr0 & XFEATURE_MASK_USER_DYNAMIC;
> >> }
> >
> > Not sure If I get the above.
> > Are you suggesting also removing fpstate->xfd and use a wrapper instead?
> > Or is the above just an example?
> > (s/xfd/xcr0/ & s/XFEATURE_MASK_USER_DYNAMIC/XFEATURE_MASK_USER_SUPPORTED/ )
>
> The above is an example of how even "indirect" uses as
> guest_supported_xcr0 can be changed to a function.
>
> >> Also, already in this patch fpstate_realloc should do
> >>
> >>           newfps->user_xfeatures = curfps->user_xfeatures | xfeatures;
> >>
> >> only if !guest_fpu.  In other words, the user_xfeatures of the guest FPU
> >> should be controlled exclusively by KVM_SET_CPUID2.
> >
> > Just to check, you suggest adding this on patch #2 ?
> > (I am failing to see how would that impact on #1)
>
> In patch 1.  Since KVM_SET_CPUID2 now changes newfps->user_xfeatures, it
> should be the only place where it's changed, and arch_prctl() should not
> change it anymore.
>
> Paolo
>

Oh, yeah, that makes sense to me. Thanks for pointing that out!
I will send a v4 shortly.

Best regards,
Leo




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux