On Wed, 27 Sep 2023 17:19:51 -0700, Sean Christopherson wrote:
Rework how KVM limits guest-unsupported xfeatures to effectively hide only when saving state for userspace (KVM_GET_XSAVE), i.e. to let userspace load all host-supported xfeatures (via KVM_SET_XSAVE) irrespective of what features have been exposed to the guest.
The effect on KVM_SET_XSAVE was knowingly done by commit ad856280ddea ("x86/kvm/fpu: Limit guest user_xfeatures to supported bits of XCR0"):
[...]
Applied to kvm-x86 fpu, even though there is still ongoing discussion. I want to get this exposure in -next sooner than later. I'll keep this in its own branch so it'll be easier to rewrite/discard if necessary.
[1/5] x86/fpu: Allow caller to constrain xfeatures when copying to uabi buffer https://github.com/kvm-x86/linux/commit/2d287ec65e79 [2/5] KVM: x86: Constrain guest-supported xfeatures only at KVM_GET_XSAVE{2} https://github.com/kvm-x86/linux/commit/27526efb5cff [3/5] KVM: selftests: Touch relevant XSAVE state in guest for state test https://github.com/kvm-x86/linux/commit/ff0654c71fb6 [4/5] KVM: selftests: Load XSAVE state into untouched vCPU during state test https://github.com/kvm-x86/linux/commit/d7b8762ec4a3 [5/5] KVM: selftests: Force load all supported XSAVE state in state test https://github.com/kvm-x86/linux/commit/afb2c7e27a7f