Re: [PATCH v2 18/23] kvm: x86: Get/set expanded xstate buffer

From: Paolo Bonzini
Date: Tue Dec 21 2021 - 04:30:57 EST


On 12/21/21 10:06, Wang, Wei W wrote:
(I'm not sure if the first sentence is true in the code, but if not it is a bug that
has to be fixed :)).
For the implementation, KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) always return kvm->vcpus[0]->arch.guest_fpu.uabi_size.
Do you want to change it to below?

If (kvm->vcpus[0]->arch.guest_fpu.uabi_size < 4096)
return 0;

return 4096;

since the minimum size of struct kvm_xsave2 (with no extra) is 4096.

Paolo

else
return kvm->vcpus[0]->arch.guest_fpu.uabi_size;

If the size is less than 4096 (e.g. no dynamic xfeatures enabled),
userspace should use the old KVM_GET_XSAVE (instead of KVM_GET_XSAVE2)?
(KVM_GET_XSAVE2 supports to work with size less than 4096, so I think this isn't necessary)