Skip to content
Permalink
Browse files
KVM: x86/cpuid: Exclude unpermitted xfeatures sizes at KVM_GET_SUPPOR…
…TED_CPUID

With the help of xstate_get_guest_group_perm(), KVM can exclude unpermitted
xfeatures in cpuid.0xd.0.eax, in which case the corresponding xfeatures
sizes should also be matched to the permitted xfeatures.

Fixing this inconsistency by introducing a local variable with the same
name also helps to fix cpuid.0xd.1.ebx and later leaf-by-leaf queries.

Fixes: 445ecdf ("kvm: x86: Exclude unpermitted xfeatures at KVM_GET_SUPPORTED_CPUID")
Signed-off-by: Like Xu <likexu@tencent.com>
  • Loading branch information
Like Xu authored and intel-lab-lkp committed Jan 24, 2022
1 parent e2e83a7 commit b29c71ea177d9a2225208d501987598610261749
Showing 1 changed file with 3 additions and 3 deletions.
@@ -887,12 +887,12 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
}
break;
case 0xd: {
u64 guest_perm = xstate_get_guest_group_perm();
u64 supported_xcr0 = supported_xcr0 & xstate_get_guest_group_perm();

entry->eax &= supported_xcr0 & guest_perm;
entry->eax &= supported_xcr0;
entry->ebx = xstate_required_size(supported_xcr0, false);
entry->ecx = entry->ebx;
entry->edx &= (supported_xcr0 & guest_perm) >> 32;
entry->edx &= supported_xcr0 >> 32;
if (!supported_xcr0)
break;

0 comments on commit b29c71e

Please sign in to comment.