KVM/x86: Move X86_CR4_OSXSAVE check into kvm_valid_sregs()
PATCH RESEND 1/1 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]>
--- arch/x86/kvm/x86.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/kvm/x86.c +4 -4
@@ -8045,6 +8045,10 @@ EXPORT_SYMBOL_GPL(kvm_task_switch);static int kvm_valid_sregs (struct kvm_vcpu *vcpu,struct kvm_sregs *sregs) { +if (!guest_cpuid_has (vcpu,X86_FEATURE_XSAVE ) && + (sregs->cr4 &X86_CR4_OSXSAVE )) +return -EINVAL ; +if ((sregs->efer &EFER_LME ) && (sregs->cr0 &X86_CR0_PG )) {/* * When EFER.LME and CR0.PG are set, the processor is in
@@ -8075,10 +8079,6 @@ static int __set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs)struct desc_ptr dt;int ret = -EINVAL ; -if (!guest_cpuid_has (vcpu,X86_FEATURE_XSAVE ) && - (sregs->cr4 &X86_CR4_OSXSAVE )) - goto out; -if (kvm_valid_sregs (vcpu, sregs)) goto out;
Signature · 1 line
2.14.3
Quoted 25 lines · Tianyu Lan
X86_CR4_OSXSAVEcheck belongs to sregs check and so move intokvm_valid_sregs().Signed-off-by Lan Tianyu <[email protected]>--- arch/x86/kvm/x86.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)arch/x86/kvm/x86.c +4
-0@@ -8045,6 +8045,10 @@ EXPORT_SYMBOL_GPL(kvm_task_switch);static int kvm_valid_sregs (struct kvm_vcpu *vcpu,struct kvm_sregs *sregs) { +if (!guest_cpuid_has (vcpu,X86_FEATURE_XSAVE ) && + (sregs->cr4 &X86_CR4_OSXSAVE )) +return -EINVAL ; +if ((sregs->efer &EFER_LME ) && (sregs->cr0 &X86_CR0_PG )) {/* * When EFER.LME and CR0.PG are set, the processor is in
arch/x86/kvm/x86.c static int __set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) · line 8084
Quoted 10 lines
arch/x86/kvm/x86.c +0
-4@@ -8075,10 +8079,6 @@ static int __set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs)struct desc_ptr dt;int ret = -EINVAL ; -if (!guest_cpuid_has (vcpu,X86_FEATURE_XSAVE ) && - (sregs->cr4 &X86_CR4_OSXSAVE )) - goto out; -if (kvm_valid_sregs (vcpu, sregs)) goto out;
Queued, thanks.
Paolo