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)
committerMarcelo Tosatti <mtosatti@redhat.com>
Mon, 1 Mar 2010 15:36:13 +0000 (12:36 -0300)
Inject #UD if guest attempts to do so. This is in accordance to Intel
SDM.

Cc: stable@kernel.org (2.6.33, 2.6.32)
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/emulate.c

index c280c2352f7e818ce2195ec48e9db974734a9eaa..2db760ff887c04a250ec2dde056f717dd3413716 100644 (file)
@@ -2126,6 +2126,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);