Skip to content

Commit

Permalink
kmdb in guest panics without debug register emulation
Browse files Browse the repository at this point in the history
  • Loading branch information
jclulow committed Sep 11, 2011
1 parent c5a4e18 commit 4196b23
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions kvm_emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2184,6 +2184,26 @@ kvm_emulate_pio_string(struct kvm_vcpu *vcpu, int in, int size,
return (ret);
}

int
emulator_get_dr(struct x86_emulate_ctxt *ctxt, int dr, unsigned long *dest)
{
if (!kvm_x86_ops->get_dr)
return (-1);

return (kvm_x86_ops->get_dr(ctxt->vcpu, dr, dest));
}

int
emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr, unsigned long value)
{
unsigned long mask = (ctxt->mode == X86EMUL_MODE_PROT64) ? ~0ULL : ~0U;

if (!kvm_x86_ops->set_dr)
return (-1);

return (kvm_x86_ops->set_dr(ctxt->vcpu, dr, value & mask));
}

int
emulate_clts(struct kvm_vcpu *vcpu)
{
Expand Down Expand Up @@ -2869,13 +2889,9 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
case 0x21: /* mov from dr to reg */
if (c->modrm_mod != 3)
goto cannot_emulate;
#ifdef XXX
rc = emulator_get_dr(ctxt, c->modrm_reg, &c->regs[c->modrm_rm]);
if (rc)
goto cannot_emulate;
#else
XXX_KVM_PROBE;
#endif
c->dst.type = OP_NONE; /* no writeback */
break;
case 0x22: /* mov reg, cr */
Expand All @@ -2888,13 +2904,9 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
case 0x23: /* mov from reg to dr */
if (c->modrm_mod != 3)
goto cannot_emulate;
#ifdef XXX
rc = emulator_set_dr(ctxt, c->modrm_reg, c->regs[c->modrm_rm]);
if (rc)
goto cannot_emulate;
#else
XXX_KVM_PROBE;
#endif
c->dst.type = OP_NONE; /* no writeback */
break;
case 0x30:
Expand Down

0 comments on commit 4196b23

Please sign in to comment.