aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/emulate.c
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2010-03-18 09:20:11 -0400
committerAvi Kivity <avi@redhat.com>2010-05-17 05:16:06 -0400
commit1e470be5a10801cb1c5c145f2cd9e0f5ebaf4f2e (patch)
tree1a3d013bc5f990e42ab2195b6fa9d5af8a4b78a7 /arch/x86/kvm/emulate.c
parent6aebfa6ea75f9a02a0339e733090dd40d6f2edfd (diff)
KVM: x86 emulator: fix mov dr to inject #UD when needed.
If CR4.DE=1 access to registers DR4/DR5 cause #UD. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/emulate.c')
-rw-r--r--arch/x86/kvm/emulate.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 836e97ba45da..5afddcfa1a7e 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2531,9 +2531,12 @@ twobyte_insn:
2531 c->dst.type = OP_NONE; /* no writeback */ 2531 c->dst.type = OP_NONE; /* no writeback */
2532 break; 2532 break;
2533 case 0x21: /* mov from dr to reg */ 2533 case 0x21: /* mov from dr to reg */
2534 if (emulator_get_dr(ctxt, c->modrm_reg, &c->regs[c->modrm_rm])) 2534 if ((ops->get_cr(4, ctxt->vcpu) & X86_CR4_DE) &&
2535 goto cannot_emulate; 2535 (c->modrm_reg == 4 || c->modrm_reg == 5)) {
2536 rc = X86EMUL_CONTINUE; 2536 kvm_queue_exception(ctxt->vcpu, UD_VECTOR);
2537 goto done;
2538 }
2539 emulator_get_dr(ctxt, c->modrm_reg, &c->regs[c->modrm_rm]);
2537 c->dst.type = OP_NONE; /* no writeback */ 2540 c->dst.type = OP_NONE; /* no writeback */
2538 break; 2541 break;
2539 case 0x22: /* mov reg, cr */ 2542 case 0x22: /* mov reg, cr */
@@ -2541,9 +2544,12 @@ twobyte_insn:
2541 c->dst.type = OP_NONE; 2544 c->dst.type = OP_NONE;
2542 break; 2545 break;
2543 case 0x23: /* mov from reg to dr */ 2546 case 0x23: /* mov from reg to dr */
2544 if (emulator_set_dr(ctxt, c->modrm_reg, c->regs[c->modrm_rm])) 2547 if ((ops->get_cr(4, ctxt->vcpu) & X86_CR4_DE) &&
2545 goto cannot_emulate; 2548 (c->modrm_reg == 4 || c->modrm_reg == 5)) {
2546 rc = X86EMUL_CONTINUE; 2549 kvm_queue_exception(ctxt->vcpu, UD_VECTOR);
2550 goto done;
2551 }
2552 emulator_set_dr(ctxt, c->modrm_reg, c->regs[c->modrm_rm]);
2547 c->dst.type = OP_NONE; /* no writeback */ 2553 c->dst.type = OP_NONE; /* no writeback */
2548 break; 2554 break;
2549 case 0x30: 2555 case 0x30: