KVM: cleanup DR6/DR7 reserved bits checks
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 13 Nov 2020 13:31:09 +0000 (08:31 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 4 Feb 2021 10:27:37 +0000 (05:27 -0500)
kvm_dr6_valid and kvm_dr7_valid check that bits 63:32 are zero.  Using
them makes it easier to review the code for inconsistencies.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c

index 39f01a05186844aac18213ef7fa922855e6b64a0..a28068075f8b3d90353d044405e1369f6c102b44 100644 (file)
@@ -4422,9 +4422,9 @@ static int kvm_vcpu_ioctl_x86_set_debugregs(struct kvm_vcpu *vcpu,
        if (dbgregs->flags)
                return -EINVAL;
 
-       if (dbgregs->dr6 & ~0xffffffffull)
+       if (!kvm_dr6_valid(dbgregs->dr6))
                return -EINVAL;
-       if (dbgregs->dr7 & ~0xffffffffull)
+       if (!kvm_dr7_valid(dbgregs->dr7))
                return -EINVAL;
 
        memcpy(vcpu->arch.db, dbgregs->db, sizeof(vcpu->arch.db));