[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJ6HWG6RB6NS8vx0vWdgRhO54B+NqHyBvpg7dRjd_78TRnJ9eg@mail.gmail.com>
Date: Wed, 16 Feb 2022 04:48:02 -0300
From: Leonardo Bras Soares Passos <leobras@...hat.com>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: David Edmondson <david.edmondson@...cle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>,
Sean Christopherson <seanjc@...gle.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>,
"Chang S. Bae" <chang.seok.bae@...el.com>,
Yang Zhong <yang.zhong@...el.com>,
Andy Lutomirski <luto@...nel.org>,
linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Subject: Re: [PATCH v3 1/1] x86/kvm/fpu: Mask guest fpstate->xfeatures with guest_supported_xcr0
Hello Paolo, thanks for the feedback!
On Mon, Feb 14, 2022 at 6:56 AM Paolo Bonzini <pbonzini@...hat.com> 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
Powered by blists - more mailing lists