On 8/17/22 05:29, Leonardo Brás wrote:
QEMU always calls kvm_put_xsave, even on this combination because
KVM_CAP_CHECK_EXTENSION_VM always returns true for KVM_CAP_XSAVE.
Any particular reason why it always returns true for KVM_CAP_XSAVE, even when
the CPU does not support it?
IIUC, if it returns false to this capability, kvm_put_xsave() should never be
called, and thus it can avoid bug reproduction.
Because it allows userspace to have a single path for saving/restoring
FPU state. See for example the "migration" code in
tools/testing/selftests/kvm/lib/x86_64/processor.c (the vcpu_save_state
and vcpu_load_state functions).
In fact, the QEMU code that uses KVM_GET_FPU/KVM_SET_FPU in x86 is
obsolete, because it's not been used since Linux 2.6.36.
Paolo