KVM: x86 emulator: Forbid modifying CS segment register by mov instruction
authorGleb Natapov <gleb@redhat.com>
Thu, 18 Feb 2010 10:14:59 +0000 (12:14 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 15 Mar 2010 15:50:15 +0000 (08:50 -0700)
commit 8b9f44140bc4afd2698413cd9960c3912168ee91 upstream.

Inject #UD if guest attempts to do so. This is in accordance to Intel
SDM.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/kvm/emulate.c

index 5ca9556f221e0cc9e6a5615cadbbc6b5723f169e..e9604420b778f521c35cf0f7bfe4517e2d91ee54 100644 (file)
@@ -1875,6 +1875,12 @@ special_insn:
                int err;
 
                sel = c->src.val;
+
+               if (c->modrm_reg == VCPU_SREG_CS) {
+                       kvm_queue_exception(ctxt->vcpu, UD_VECTOR);
+                       goto done;
+               }
+
                if (c->modrm_reg == VCPU_SREG_SS)
                        toggle_interruptibility(ctxt, X86_SHADOW_INT_MOV_SS);