Browse Source

KVM: x86 emulator: Forbid modifying CS segment register by mov instruction

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>
Gleb Natapov 15 years ago
parent
commit
8b9f44140b
1 changed files with 6 additions and 0 deletions
  1. 6 0
      arch/x86/kvm/emulate.c

+ 6 - 0
arch/x86/kvm/emulate.c

@@ -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);