mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	LKML <linux-kernel@vger.kernel.org>
Cc: x86@kernel.org, "Liu, Jing2" <jing2.liu@intel.com>,
	"Bae, Chang Seok" <chang.seok.bae@intel.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Arjan van de Ven <arjan@linux.intel.com>,
	kvm@vger.kernel.org, "Nakajima, Jun" <jun.nakajima@intel.com>,
	Sean Christopherson <seanjc@google.com>
Subject: Re: [patch 3/4] x86/kvm: Convert FPU handling to a single swap buffer
Date: Mon, 18 Oct 2021 13:55:53 +0200	[thread overview]
Message-ID: <b1c49069-437c-7aa6-531d-6651dad72015@redhat.com> (raw)
In-Reply-To: <20211017152048.666354328@linutronix.de>

On 17/10/21 19:03, Thomas Gleixner wrote:
>   	 */
> -	fpu_swap_kvm_fpu(vcpu->arch.user_fpu, vcpu->arch.guest_fpu,
> -			 ~XFEATURE_MASK_PKRU);
> +	fpu_swap_kvm_fpstate(&vcpu->arch.guest_fpu, true, ~XFEATURE_MASK_PKRU);
>   	trace_kvm_fpu(1);
>   }
>   
>   /* When vcpu_run ends, restore user space FPU context. */
>   static void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
>   {
> -	/*
> -	 * Guests with protected state have guest_fpu == NULL which makes
> -	 * swap only restore the host state.
> -	 */
> -	fpu_swap_kvm_fpu(vcpu->arch.guest_fpu, vcpu->arch.user_fpu, ~0ULL);
> +	fpu_swap_kvm_fpstate(&vcpu->arch.guest_fpu, false, ~0ULL);

The restore mask can be ~XFEATURE_MASK_PKRU in this case tool this way 
it's constant and you can drop the third argument to the function.

Also perhaps it could be useful to add an

if (WARN_ON_ONCE(cur_fps->is_guest == enter_guest))
	return;

at the top of fpu_swap_kvm_fpstate, since the is_guest member (at least 
for now?) is only used for such kind of assertion.

Paolo


  reply	other threads:[~2021-10-18 11:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-17 17:03 [patch 0/4] x86/fpu/kvm: Sanitize the FPU guest/user handling Thomas Gleixner
2021-10-17 17:03 ` [patch 1/4] x86/fpu: Prepare for sanitizing KVM FPU code Thomas Gleixner
2021-10-17 17:03 ` [patch 2/4] x86/fpu: Provide infrastructure for KVM FPU cleanup Thomas Gleixner
2021-10-17 17:03 ` [patch 3/4] x86/kvm: Convert FPU handling to a single swap buffer Thomas Gleixner
2021-10-18 11:55   ` Paolo Bonzini [this message]
2021-10-17 17:03 ` [patch 4/4] x86/fpu: Remove old KVM FPU interface Thomas Gleixner
2021-10-19 19:43 ` [patch 0/4] x86/fpu/kvm: Sanitize the FPU guest/user handling Bae, Chang Seok
2021-10-20  9:19   ` Paolo Bonzini

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=b1c49069-437c-7aa6-531d-6651dad72015@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=arjan@linux.intel.com \
    --cc=chang.seok.bae@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=jing2.liu@intel.com \
    --cc=jun.nakajima@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --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®