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]

 



Hello Paolo, thanks for the feedback!

On Mon, Feb 14, 2022 at 6:56 AM Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:
>
> On 2/14/22 10:43, David Edmondson wrote:
> > Sorry if this is a daft question:
> >
> > In what situations will there be bits set in
> > vcpu->arch.guest_supported_xcr0 that are not set in
> > vcpu->arch.guest_fpu.fpstate->xfeatures ?
> >
> > guest_supported_xcr0 is filtered based on supported_xcr0, which I would
> > expect to weed out all bits that are not set in ->xfeatures.
>
> Good point, so we can do just
>
>         vcpu->arch.guest_fpu.fpstate->user_xfeatures =
>                 vcpu->arch.guest_supported_xcr0;

Updated for v4.

>
> 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() ?)

> 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/ )

>
> 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)

>
> Thanks,
>
> Paolo
>

Thank you!

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