KVM: x86: Move the check for upper 32 reserved bits of DR6 to separate function
authorKrish Sadhukhan <krish.sadhukhan@oracle.com>
Fri, 22 May 2020 22:19:51 +0000 (18:19 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 Jul 2020 20:21:40 +0000 (16:21 -0400)
Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Message-Id: <20200522221954.32131-2-krish.sadhukhan@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c
arch/x86/kvm/x86.h

index ec9aba1..82f457f 100644 (file)
@@ -1133,7 +1133,7 @@ static int __kvm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long val)
        case 4:
                /* fall through */
        case 6:
-               if (val & 0xffffffff00000000ULL)
+               if (!kvm_dr6_valid(val))
                        return -1; /* #GP */
                vcpu->arch.dr6 = (val & DR6_VOLATILE) | kvm_dr6_fixed(vcpu);
                break;
index 8d42dd0..31928bf 100644 (file)
@@ -360,6 +360,11 @@ static inline bool kvm_dr7_valid(u64 data)
        /* Bits [63:32] are reserved */
        return !(data >> 32);
 }
+static inline bool kvm_dr6_valid(u64 data)
+{
+       /* Bits [63:32] are reserved */
+       return !(data >> 32);
+}
 
 void kvm_load_guest_xsave_state(struct kvm_vcpu *vcpu);
 void kvm_load_host_xsave_state(struct kvm_vcpu *vcpu);