Re: [patch 13/31] x86/fpu: Move KVMs FPU swapping to FPU core

From: Paolo Bonzini
Date: Fri Oct 15 2021 - 11:53:55 EST


On 15/10/21 16:24, Liu, Jing2 wrote:
fpu_swap_kvm_fpu(bool enter_guest, u64 guest_needs_features) {
possibly_reallocate(enter_guest, guest_needs_features);
When KVM traps guest wrmsr XFD in #NM, I think KVM need allocate
fpstate buffer for full features.

You mean XCR0 and XFD (not XFD in #NM), but yeah at the point of fpu_swap_kvm_fpu we are in atomic context.

Still, for now the first pass of AMX implementation doesn't need to do anything but swap the pointers, and it can simply allocate the full buffer at vCPU creation.

Paolo

Because in next vmexit, guest might have dynamic state and KVM
can be preempted before running fpu_swap_kvm_fpu().
Thus, here the current->thread.fpu.fpstate already has enough space
for saving guest.