(I'm not sure if the first sentence is true in the code, but if not it is a bug thatFor the implementation, KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) always return kvm->vcpus[0]->arch.guest_fpu.uabi_size.
has to be fixed :)).
Do you want to change it to below?
If (kvm->vcpus[0]->arch.guest_fpu.uabi_size < 4096)
return 0;
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)