[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b1c49069-437c-7aa6-531d-6651dad72015@redhat.com>
Date: Mon, 18 Oct 2021 13:55:53 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: Thomas Gleixner <tglx@...utronix.de>,
LKML <linux-kernel@...r.kernel.org>
Cc: x86@...nel.org, "Liu, Jing2" <jing2.liu@...el.com>,
"Bae, Chang Seok" <chang.seok.bae@...el.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Arjan van de Ven <arjan@...ux.intel.com>,
kvm@...r.kernel.org, "Nakajima, Jun" <jun.nakajima@...el.com>,
Sean Christopherson <seanjc@...gle.com>
Subject: Re: [patch 3/4] x86/kvm: Convert FPU handling to a single swap buffer
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
Powered by blists - more mailing lists