summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/emulate.c
diff options
context:
space:
mode:
authorAvi Kivity2010-01-21 14:31:48 +0100
committerMarcelo Tosatti2010-03-01 16:36:04 +0100
commit3eeb3288bcbf64da90afc26389b8844df7c34912 (patch)
tree1b7bc55641015605da0b415a928ecf39aac64a2e /arch/x86/kvm/emulate.c
parentKVM: Activate fpu on clts (diff)
downloadkernel-qcow2-linux-3eeb3288bcbf64da90afc26389b8844df7c34912.tar.gz
kernel-qcow2-linux-3eeb3288bcbf64da90afc26389b8844df7c34912.tar.xz
kernel-qcow2-linux-3eeb3288bcbf64da90afc26389b8844df7c34912.zip
KVM: Add a helper for checking if the guest is in protected mode
Signed-off-by: Avi Kivity <avi@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.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 48c7f9f8a08f..6a429eefc533 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -32,6 +32,7 @@
#include <linux/module.h>
#include <asm/kvm_emulate.h>
+#include "x86.h"
#include "mmu.h" /* for is_long_mode() */
/*
@@ -1515,7 +1516,7 @@ emulate_syscall(struct x86_emulate_ctxt *ctxt)
/* syscall is not available in real mode */
if (c->lock_prefix || ctxt->mode == X86EMUL_MODE_REAL
- || !kvm_read_cr0_bits(ctxt->vcpu, X86_CR0_PE))
+ || !is_protmode(ctxt->vcpu))
return -1;
setup_syscalls_segments(ctxt, &cs, &ss);
@@ -1568,8 +1569,7 @@ emulate_sysenter(struct x86_emulate_ctxt *ctxt)
return -1;
/* inject #GP if in real mode or paging is disabled */
- if (ctxt->mode == X86EMUL_MODE_REAL ||
- !kvm_read_cr0_bits(ctxt->vcpu, X86_CR0_PE)) {
+ if (ctxt->mode == X86EMUL_MODE_REAL || !is_protmode(ctxt->vcpu)) {
kvm_inject_gp(ctxt->vcpu, 0);
return -1;
}
@@ -1634,8 +1634,7 @@ emulate_sysexit(struct x86_emulate_ctxt *ctxt)
return -1;
/* inject #GP if in real mode or paging is disabled */
- if (ctxt->mode == X86EMUL_MODE_REAL
- || !kvm_read_cr0_bits(ctxt->vcpu, X86_CR0_PE)) {
+ if (ctxt->mode == X86EMUL_MODE_REAL || !is_protmode(ctxt->vcpu)) {
kvm_inject_gp(ctxt->vcpu, 0);
return -1;
}