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: 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>,
	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>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/2] x86/kvm/fpu: Mask guest fpstate->xfeatures with guest_supported_xcr0
Date: Mon, 7 Feb 2022 23:59:45 +0100	[thread overview]
Message-ID: <2b1d142e-e06c-3f38-32f5-d14de7dca289@redhat.com> (raw)
In-Reply-To: <CAJ6HWG5sD06=ZMtrcSJ+O3ZH0xVeR7gC8+9o5hq+evXh43Vn_w@mail.gmail.com>

On 2/7/22 23:45, Leonardo Bras Soares Passos wrote:
> On Mon, Feb 7, 2022 at 6:00 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
>>
>> On 2/7/22 21:24, Leonardo Bras Soares Passos wrote:
>>>> With this patch,
>>>> we have to reason about the effect of calling KVM_SET_CPUID2 twice calls
>>>> back to back.  I think an "&=" would be wrong in that case.
>>>
>>> So, you suggest something like this ?
>>>
>>> vcpu->arch.guest_fpu.fpstate->xfeatures =
>>>          fpu_user_cfg.default_features & vcpu->arch.guest_supported_xcr0;
>>>
>>
>> Yes, but you need to change user_xfeatures instead of xfeatures.
>> KVM_GET_XSAVE and KVM_SET_XSAVE will take it into account automatically:
>>
>> - KVM_GET_XSAVE: fpu_copy_guest_fpstate_to_uabi -> __copy_xstate_to_uabi_buf
>>
>> - KVM_SET_XSAVE: fpu_copy_uabi_to_guest_fpstate ->
>> copy_uabi_from_kernel_to_xstate -> copy_uabi_to_xstate ->
>> validate_user_xstate_buffer
> 
> 
> Ok, I understand how this replaces patch 2/2, so no issue on that.
> 
> About patch 1/2,  you suggest that instead of fixing what we save in
> the regs buffer, we fix only what we want to return to the user when
> they call KVM_GET_XSAVE, is that correct?

Yes, exactly.

Paolo


  reply	other threads:[~2022-02-08  1:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-05  8:16 [PATCH v1 0/2] x86/kvm/fpu: Fix guest migration bugs that can crash guest Leonardo Bras
2022-02-05  8:16 ` [PATCH v1 1/2] x86/kvm/fpu: Mask guest fpstate->xfeatures with guest_supported_xcr0 Leonardo Bras
2022-02-07 13:30   ` Paolo Bonzini
2022-02-07 20:24     ` Leonardo Bras Soares Passos
2022-02-07 21:00       ` Paolo Bonzini
2022-02-07 22:45         ` Leonardo Bras Soares Passos
2022-02-07 22:59           ` Paolo Bonzini [this message]
2022-02-08  2:14             ` Leonardo Bras Soares Passos
2022-02-05  8:16 ` [PATCH v1 2/2] x86/kvm/fpu: Limit setting guest fpu features based on guest_supported_xcr0 Leonardo Bras

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=2b1d142e-e06c-3f38-32f5-d14de7dca289@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.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=mingo@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    /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®