kvm: x86: Exclude unpermitted xfeatures at KVM_GET_SUPPORTED_CPUID
authorJing Liu <jing2.liu@intel.com>
Wed, 5 Jan 2022 12:35:15 +0000 (04:35 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 7 Jan 2022 18:33:04 +0000 (13:33 -0500)
commit445ecdf79be0c71ca248f7611aeefceaea3ec59f
treede6de4d866343a9cddb7e1f0715e359f587eb211
parentcc04b6a21d431359eceeec0d812b492088b04af5
kvm: x86: Exclude unpermitted xfeatures at KVM_GET_SUPPORTED_CPUID

KVM_GET_SUPPORTED_CPUID should not include any dynamic xstates in
CPUID[0xD] if they have not been requested with prctl. Otherwise
a process which directly passes KVM_GET_SUPPORTED_CPUID to
KVM_SET_CPUID2 would now fail even if it doesn't intend to use a
dynamically enabled feature. Userspace must know that prctl is
required and allocate >4K xstate buffer before setting any dynamic
bit.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jing Liu <jing2.liu@intel.com>
Signed-off-by: Yang Zhong <yang.zhong@intel.com>
Message-Id: <20220105123532.12586-5-yang.zhong@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Documentation/virt/kvm/api.rst
arch/x86/kvm/cpuid.c