Messages in this thread | | | Date | Mon, 18 Oct 2021 13:55:53 +0200 | Subject | Re: [patch 3/4] x86/kvm: Convert FPU handling to a single swap buffer | From | Paolo Bonzini <> |
| |
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
| |