@@ -60,6 +60,11 @@ u32 xstate_required_size(u64 xstate_bv, bool compacted)
return ret;
}
+u64 kvm_permitted_xcr0(void)
+{
+ return kvm_caps.supported_xcr0 & xstate_get_guest_group_perm();
+}
+
/*
* This one is tied to SSB in the user API, and not
* visible in /proc/cpuinfo.
@@ -981,7 +986,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
entry->eax = entry->ebx = entry->ecx = 0;
break;
case 0xd: {
- u64 permitted_xcr0 = kvm_caps.supported_xcr0 & xstate_get_guest_group_perm();
+ u64 permitted_xcr0 = kvm_permitted_xcr0();
u64 permitted_xss = kvm_caps.supported_xss;
entry->eax &= permitted_xcr0;
@@ -33,6 +33,7 @@ bool kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx,
u32 *ecx, u32 *edx, bool exact_only);
u32 xstate_required_size(u64 xstate_bv, bool compacted);
+u64 kvm_permitted_xcr0(void);
int cpuid_query_maxphyaddr(struct kvm_vcpu *vcpu);
u64 kvm_vcpu_reserved_gpa_bits_raw(struct kvm_vcpu *vcpu);
@@ -4519,9 +4519,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
r = 0;
break;
case KVM_CAP_XSAVE2: {
- u64 guest_perm = xstate_get_guest_group_perm();
-
- r = xstate_required_size(kvm_caps.supported_xcr0 & guest_perm, false);
+ r = xstate_required_size(kvm_permitted_xcr0(), false);
if (r < sizeof(struct kvm_xsave))
r = sizeof(struct kvm_xsave);
break;
Add the helper, kvm_permitted_xcr0(), to make it easier to filter the supported XCR0 before using it. No functional changes intended. Signed-off-by: Aaron Lewis <aaronlewis@google.com> --- arch/x86/kvm/cpuid.c | 7 ++++++- arch/x86/kvm/cpuid.h | 1 + arch/x86/kvm/x86.c | 4 +--- 3 files changed, 8 insertions(+), 4 deletions(-)