aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/include/asm/kvm_emulate.h1
-rw-r--r--arch/x86/kvm/emulate.c12
-rw-r--r--arch/x86/kvm/x86.c3
3 files changed, 10 insertions, 6 deletions
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h
index 9b697c2735d9..784d7c586d8e 100644
--- a/arch/x86/include/asm/kvm_emulate.h
+++ b/arch/x86/include/asm/kvm_emulate.h
@@ -168,6 +168,7 @@ struct x86_emulate_ctxt {
168 168
169/* Execution mode, passed to the emulator. */ 169/* Execution mode, passed to the emulator. */
170#define X86EMUL_MODE_REAL 0 /* Real mode. */ 170#define X86EMUL_MODE_REAL 0 /* Real mode. */
171#define X86EMUL_MODE_VM86 1 /* Virtual 8086 mode. */
171#define X86EMUL_MODE_PROT16 2 /* 16-bit protected mode. */ 172#define X86EMUL_MODE_PROT16 2 /* 16-bit protected mode. */
172#define X86EMUL_MODE_PROT32 4 /* 32-bit protected mode. */ 173#define X86EMUL_MODE_PROT32 4 /* 32-bit protected mode. */
173#define X86EMUL_MODE_PROT64 8 /* 64-bit (long) mode. */ 174#define X86EMUL_MODE_PROT64 8 /* 64-bit (long) mode. */
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 45a4f7c1bb0b..e4e2df3b6038 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -899,6 +899,7 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
899 899
900 switch (mode) { 900 switch (mode) {
901 case X86EMUL_MODE_REAL: 901 case X86EMUL_MODE_REAL:
902 case X86EMUL_MODE_VM86:
902 case X86EMUL_MODE_PROT16: 903 case X86EMUL_MODE_PROT16:
903 def_op_bytes = def_ad_bytes = 2; 904 def_op_bytes = def_ad_bytes = 2;
904 break; 905 break;
@@ -1525,7 +1526,7 @@ emulate_syscall(struct x86_emulate_ctxt *ctxt)
1525 1526
1526 /* syscall is not available in real mode */ 1527 /* syscall is not available in real mode */
1527 if (c->lock_prefix || ctxt->mode == X86EMUL_MODE_REAL 1528 if (c->lock_prefix || ctxt->mode == X86EMUL_MODE_REAL
1528 || !is_protmode(ctxt->vcpu)) 1529 || ctxt->mode == X86EMUL_MODE_VM86)
1529 return -1; 1530 return -1;
1530 1531
1531 setup_syscalls_segments(ctxt, &cs, &ss); 1532 setup_syscalls_segments(ctxt, &cs, &ss);
@@ -1577,8 +1578,8 @@ emulate_sysenter(struct x86_emulate_ctxt *ctxt)
1577 if (c->lock_prefix) 1578 if (c->lock_prefix)
1578 return -1; 1579 return -1;
1579 1580
1580 /* inject #GP if in real mode or paging is disabled */ 1581 /* inject #GP if in real mode */
1581 if (ctxt->mode == X86EMUL_MODE_REAL || !is_protmode(ctxt->vcpu)) { 1582 if (ctxt->mode == X86EMUL_MODE_REAL) {
1582 kvm_inject_gp(ctxt->vcpu, 0); 1583 kvm_inject_gp(ctxt->vcpu, 0);
1583 return -1; 1584 return -1;
1584 } 1585 }
@@ -1642,8 +1643,9 @@ emulate_sysexit(struct x86_emulate_ctxt *ctxt)
1642 if (c->lock_prefix) 1643 if (c->lock_prefix)
1643 return -1; 1644 return -1;
1644 1645
1645 /* inject #GP if in real mode or paging is disabled */ 1646 /* inject #GP if in real mode or Virtual 8086 mode */
1646 if (ctxt->mode == X86EMUL_MODE_REAL || !is_protmode(ctxt->vcpu)) { 1647 if (ctxt->mode == X86EMUL_MODE_REAL ||
1648 ctxt->mode == X86EMUL_MODE_VM86) {
1647 kvm_inject_gp(ctxt->vcpu, 0); 1649 kvm_inject_gp(ctxt->vcpu, 0);
1648 return -1; 1650 return -1;
1649 } 1651 }
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index b2f91b9af00d..a28379507d30 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3348,8 +3348,9 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
3348 vcpu->arch.emulate_ctxt.vcpu = vcpu; 3348 vcpu->arch.emulate_ctxt.vcpu = vcpu;
3349 vcpu->arch.emulate_ctxt.eflags = kvm_get_rflags(vcpu); 3349 vcpu->arch.emulate_ctxt.eflags = kvm_get_rflags(vcpu);
3350 vcpu->arch.emulate_ctxt.mode = 3350 vcpu->arch.emulate_ctxt.mode =
3351 (!is_protmode(vcpu)) ? X86EMUL_MODE_REAL :
3351 (vcpu->arch.emulate_ctxt.eflags & X86_EFLAGS_VM) 3352 (vcpu->arch.emulate_ctxt.eflags & X86_EFLAGS_VM)
3352 ? X86EMUL_MODE_REAL : cs_l 3353 ? X86EMUL_MODE_VM86 : cs_l
3353 ? X86EMUL_MODE_PROT64 : cs_db 3354 ? X86EMUL_MODE_PROT64 : cs_db
3354 ? X86EMUL_MODE_PROT32 : X86EMUL_MODE_PROT16; 3355 ? X86EMUL_MODE_PROT32 : X86EMUL_MODE_PROT16;
3355 3356