提交 35aa5375 编写于 作者: G Gleb Natapov 提交者: Avi Kivity

KVM: x86 emulator: add (set|get)_dr callbacks to x86_emulate_ops

Add (set|get)_dr callbacks to x86_emulate_ops instead of calling
them directly.
Signed-off-by: NGleb Natapov <gleb@redhat.com>
Signed-off-by: NAvi Kivity <avi@redhat.com>
上级 414e6277
...@@ -137,6 +137,8 @@ struct x86_emulate_ops { ...@@ -137,6 +137,8 @@ struct x86_emulate_ops {
void (*set_cr)(int cr, ulong val, struct kvm_vcpu *vcpu); void (*set_cr)(int cr, ulong val, struct kvm_vcpu *vcpu);
int (*cpl)(struct kvm_vcpu *vcpu); int (*cpl)(struct kvm_vcpu *vcpu);
void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags); void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags);
int (*get_dr)(int dr, unsigned long *dest, struct kvm_vcpu *vcpu);
int (*set_dr)(int dr, unsigned long value, struct kvm_vcpu *vcpu);
}; };
/* Type, address-of, and value of an instruction's operand. */ /* Type, address-of, and value of an instruction's operand. */
......
...@@ -591,10 +591,6 @@ void kvm_emulate_cpuid(struct kvm_vcpu *vcpu); ...@@ -591,10 +591,6 @@ void kvm_emulate_cpuid(struct kvm_vcpu *vcpu);
int kvm_emulate_halt(struct kvm_vcpu *vcpu); int kvm_emulate_halt(struct kvm_vcpu *vcpu);
int emulate_invlpg(struct kvm_vcpu *vcpu, gva_t address); int emulate_invlpg(struct kvm_vcpu *vcpu, gva_t address);
int emulate_clts(struct kvm_vcpu *vcpu); int emulate_clts(struct kvm_vcpu *vcpu);
int emulator_get_dr(struct x86_emulate_ctxt *ctxt, int dr,
unsigned long *dest);
int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr,
unsigned long value);
void kvm_get_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg); void kvm_get_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg);
int kvm_load_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, int seg); int kvm_load_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, int seg);
......
...@@ -3132,7 +3132,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) ...@@ -3132,7 +3132,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
kvm_queue_exception(ctxt->vcpu, UD_VECTOR); kvm_queue_exception(ctxt->vcpu, UD_VECTOR);
goto done; goto done;
} }
emulator_get_dr(ctxt, c->modrm_reg, &c->regs[c->modrm_rm]); ops->get_dr(c->modrm_reg, &c->regs[c->modrm_rm], ctxt->vcpu);
c->dst.type = OP_NONE; /* no writeback */ c->dst.type = OP_NONE; /* no writeback */
break; break;
case 0x22: /* mov reg, cr */ case 0x22: /* mov reg, cr */
...@@ -3145,7 +3145,10 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) ...@@ -3145,7 +3145,10 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
kvm_queue_exception(ctxt->vcpu, UD_VECTOR); kvm_queue_exception(ctxt->vcpu, UD_VECTOR);
goto done; goto done;
} }
emulator_set_dr(ctxt, c->modrm_reg, c->regs[c->modrm_rm]);
ops->set_dr(c->modrm_reg,c->regs[c->modrm_rm] &
((ctxt->mode == X86EMUL_MODE_PROT64) ? ~0ULL : ~0U),
ctxt->vcpu);
c->dst.type = OP_NONE; /* no writeback */ c->dst.type = OP_NONE; /* no writeback */
break; break;
case 0x30: case 0x30:
......
...@@ -3620,16 +3620,14 @@ int emulate_clts(struct kvm_vcpu *vcpu) ...@@ -3620,16 +3620,14 @@ int emulate_clts(struct kvm_vcpu *vcpu)
return X86EMUL_CONTINUE; return X86EMUL_CONTINUE;
} }
int emulator_get_dr(struct x86_emulate_ctxt *ctxt, int dr, unsigned long *dest) int emulator_get_dr(int dr, unsigned long *dest, struct kvm_vcpu *vcpu)
{ {
return kvm_get_dr(ctxt->vcpu, dr, dest); return kvm_get_dr(vcpu, dr, dest);
} }
int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr, unsigned long value) int emulator_set_dr(int dr, unsigned long value, struct kvm_vcpu *vcpu)
{ {
unsigned long mask = (ctxt->mode == X86EMUL_MODE_PROT64) ? ~0ULL : ~0U; return kvm_set_dr(vcpu, dr, value);
return kvm_set_dr(ctxt->vcpu, dr, value & mask);
} }
void kvm_report_emulation_failure(struct kvm_vcpu *vcpu, const char *context) void kvm_report_emulation_failure(struct kvm_vcpu *vcpu, const char *context)
...@@ -3811,6 +3809,8 @@ static struct x86_emulate_ops emulate_ops = { ...@@ -3811,6 +3809,8 @@ static struct x86_emulate_ops emulate_ops = {
.set_cr = emulator_set_cr, .set_cr = emulator_set_cr,
.cpl = emulator_get_cpl, .cpl = emulator_get_cpl,
.set_rflags = emulator_set_rflags, .set_rflags = emulator_set_rflags,
.get_dr = emulator_get_dr,
.set_dr = emulator_set_dr,
}; };
static void cache_all_regs(struct kvm_vcpu *vcpu) static void cache_all_regs(struct kvm_vcpu *vcpu)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册