Commit 29d6ca41 authored by Paolo Bonzini's avatar Paolo Bonzini

KVM: x86: reading DR cannot fail

kvm_get_dr and emulator_get_dr except an in-range value for the register
number so they cannot fail.  Change the return type to void.
Suggested-by: default avatarSean Christopherson <seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 6f7a3439
...@@ -1562,7 +1562,7 @@ int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3); ...@@ -1562,7 +1562,7 @@ int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3);
int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4); int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4);
int kvm_set_cr8(struct kvm_vcpu *vcpu, unsigned long cr8); int kvm_set_cr8(struct kvm_vcpu *vcpu, unsigned long cr8);
int kvm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long val); int kvm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long val);
int kvm_get_dr(struct kvm_vcpu *vcpu, int dr, unsigned long *val); void kvm_get_dr(struct kvm_vcpu *vcpu, int dr, unsigned long *val);
unsigned long kvm_get_cr8(struct kvm_vcpu *vcpu); unsigned long kvm_get_cr8(struct kvm_vcpu *vcpu);
void kvm_lmsw(struct kvm_vcpu *vcpu, unsigned long msw); void kvm_lmsw(struct kvm_vcpu *vcpu, unsigned long msw);
void kvm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l); void kvm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l);
......
...@@ -205,7 +205,7 @@ struct x86_emulate_ops { ...@@ -205,7 +205,7 @@ struct x86_emulate_ops {
ulong (*get_cr)(struct x86_emulate_ctxt *ctxt, int cr); ulong (*get_cr)(struct x86_emulate_ctxt *ctxt, int cr);
int (*set_cr)(struct x86_emulate_ctxt *ctxt, int cr, ulong val); int (*set_cr)(struct x86_emulate_ctxt *ctxt, int cr, ulong val);
int (*cpl)(struct x86_emulate_ctxt *ctxt); int (*cpl)(struct x86_emulate_ctxt *ctxt);
int (*get_dr)(struct x86_emulate_ctxt *ctxt, int dr, ulong *dest); void (*get_dr)(struct x86_emulate_ctxt *ctxt, int dr, ulong *dest);
int (*set_dr)(struct x86_emulate_ctxt *ctxt, int dr, ulong value); int (*set_dr)(struct x86_emulate_ctxt *ctxt, int dr, ulong value);
u64 (*get_smbase)(struct x86_emulate_ctxt *ctxt); u64 (*get_smbase)(struct x86_emulate_ctxt *ctxt);
void (*set_smbase)(struct x86_emulate_ctxt *ctxt, u64 smbase); void (*set_smbase)(struct x86_emulate_ctxt *ctxt, u64 smbase);
......
...@@ -5142,8 +5142,7 @@ static int handle_dr(struct kvm_vcpu *vcpu) ...@@ -5142,8 +5142,7 @@ static int handle_dr(struct kvm_vcpu *vcpu)
if (exit_qualification & TYPE_MOV_FROM_DR) { if (exit_qualification & TYPE_MOV_FROM_DR) {
unsigned long val; unsigned long val;
if (kvm_get_dr(vcpu, dr, &val)) kvm_get_dr(vcpu, dr, &val);
return 1;
kvm_register_write(vcpu, reg, val); kvm_register_write(vcpu, reg, val);
} else } else
if (kvm_set_dr(vcpu, dr, kvm_register_readl(vcpu, reg))) if (kvm_set_dr(vcpu, dr, kvm_register_readl(vcpu, reg)))
......
...@@ -1181,7 +1181,7 @@ int kvm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long val) ...@@ -1181,7 +1181,7 @@ int kvm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long val)
} }
EXPORT_SYMBOL_GPL(kvm_set_dr); EXPORT_SYMBOL_GPL(kvm_set_dr);
int kvm_get_dr(struct kvm_vcpu *vcpu, int dr, unsigned long *val) void kvm_get_dr(struct kvm_vcpu *vcpu, int dr, unsigned long *val)
{ {
size_t size = ARRAY_SIZE(vcpu->arch.db); size_t size = ARRAY_SIZE(vcpu->arch.db);
...@@ -1198,7 +1198,6 @@ int kvm_get_dr(struct kvm_vcpu *vcpu, int dr, unsigned long *val) ...@@ -1198,7 +1198,6 @@ int kvm_get_dr(struct kvm_vcpu *vcpu, int dr, unsigned long *val)
*val = vcpu->arch.dr7; *val = vcpu->arch.dr7;
break; break;
} }
return 0;
} }
EXPORT_SYMBOL_GPL(kvm_get_dr); EXPORT_SYMBOL_GPL(kvm_get_dr);
...@@ -6610,10 +6609,10 @@ static void emulator_wbinvd(struct x86_emulate_ctxt *ctxt) ...@@ -6610,10 +6609,10 @@ static void emulator_wbinvd(struct x86_emulate_ctxt *ctxt)
kvm_emulate_wbinvd_noskip(emul_to_vcpu(ctxt)); kvm_emulate_wbinvd_noskip(emul_to_vcpu(ctxt));
} }
static int emulator_get_dr(struct x86_emulate_ctxt *ctxt, int dr, static void emulator_get_dr(struct x86_emulate_ctxt *ctxt, int dr,
unsigned long *dest) unsigned long *dest)
{ {
return kvm_get_dr(emul_to_vcpu(ctxt), dr, dest); kvm_get_dr(emul_to_vcpu(ctxt), dr, dest);
} }
static int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr, static int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment