mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Leonardo Bras Soares Passos <leobras@redhat.com>
Cc: David Edmondson <david.edmondson@oracle.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Sean Christopherson <seanjc@google.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	"Chang S. Bae" <chang.seok.bae@intel.com>,
	Yang Zhong <yang.zhong@intel.com>,
	Andy Lutomirski <luto@kernel.org>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH v3 1/1] x86/kvm/fpu: Mask guest fpstate->xfeatures with guest_supported_xcr0
Date: Wed, 16 Feb 2022 12:45:41 +0100	[thread overview]
Message-ID: <9b1d925c-1e6a-8a06-ada5-941adb5b349f@redhat.com> (raw)
In-Reply-To: <CAJ6HWG6RB6NS8vx0vWdgRhO54B+NqHyBvpg7dRjd_78TRnJ9eg@mail.gmail.com>

On 2/16/22 08:48, Leonardo Bras Soares Passos wrote:
> On Mon, Feb 14, 2022 at 6:56 AM Paolo Bonzini <pbonzini@redhat.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


  reply	other threads:[~2022-02-16 11:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11  6:07 Leonardo Bras
2022-02-12 11:02 ` Paolo Bonzini
2022-02-14  9:43   ` David Edmondson
2022-02-14  9:56     ` Paolo Bonzini
2022-02-16  7:48       ` Leonardo Bras Soares Passos
2022-02-16 11:45         ` Paolo Bonzini [this message]
2022-02-17  4:16           ` Leonardo Bras Soares Passos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9b1d925c-1e6a-8a06-ada5-941adb5b349f@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=bp@alien8.de \
    --cc=chang.seok.bae@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=david.edmondson@oracle.com \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=leobras@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    --cc=yang.zhong@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®