lkml.org 
[lkml]   [2021]   [Oct]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [patch 3/4] x86/kvm: Convert FPU handling to a single swap buffer
From
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

\
 
 \ /
  Last update: 2021-10-18 13:56    [W:0.885 / U:0.488 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site