[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9b1d925c-1e6a-8a06-ada5-941adb5b349f@redhat.com>
Date: Wed, 16 Feb 2022 12:45:41 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Leonardo Bras Soares Passos <leobras@...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
On 2/16/22 08:48, Leonardo Bras Soares Passos wrote:
> On Mon, Feb 14, 2022 at 6:56 AM Paolo Bonzini <pbonzini@...hat.com> 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.
>> 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
Powered by blists - more mailing lists