Skip to content

Commit 74fec5b

Browse files
Tianyu Lanbonzini
authored andcommitted
KVM/x86: Move X86_CR4_OSXSAVE check into kvm_valid_sregs()
X86_CR4_OSXSAVE check belongs to sregs check and so move into kvm_valid_sregs(). Signed-off-by: Lan Tianyu <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent ee6268b commit 74fec5b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/x86/kvm/x86.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8049,6 +8049,10 @@ EXPORT_SYMBOL_GPL(kvm_task_switch);
80498049

80508050
static int kvm_valid_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs)
80518051
{
8052+
if (!guest_cpuid_has(vcpu, X86_FEATURE_XSAVE) &&
8053+
(sregs->cr4 & X86_CR4_OSXSAVE))
8054+
return -EINVAL;
8055+
80528056
if ((sregs->efer & EFER_LME) && (sregs->cr0 & X86_CR0_PG)) {
80538057
/*
80548058
* When EFER.LME and CR0.PG are set, the processor is in
@@ -8079,10 +8083,6 @@ static int __set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs)
80798083
struct desc_ptr dt;
80808084
int ret = -EINVAL;
80818085

8082-
if (!guest_cpuid_has(vcpu, X86_FEATURE_XSAVE) &&
8083-
(sregs->cr4 & X86_CR4_OSXSAVE))
8084-
goto out;
8085-
80868086
if (kvm_valid_sregs(vcpu, sregs))
80878087
goto out;
80888088

0 commit comments

Comments
 (0)