KVM: x86 emulator: fix LIDT/LGDT in long mode
authorAvi Kivity <avi@redhat.com>
Thu, 7 Jun 2012 14:04:36 +0000 (17:04 +0300)
committerAvi Kivity <avi@redhat.com>
Mon, 9 Jul 2012 11:19:01 +0000 (14:19 +0300)
The operand size for these instructions is 8 bytes in long mode, even without
a REX prefix.  Set it explicitly.

Triggered while booting Linux with emulate_invalid_guest_state=1.

Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/emulate.c

index fe4340f621371ded86a56c534cb507975577aaa3..24c84251648b2306b7b4f383c0bc33768c199fb8 100644 (file)
@@ -2997,6 +2997,8 @@ static int em_lgdt(struct x86_emulate_ctxt *ctxt)
        struct desc_ptr desc_ptr;
        int rc;
 
+       if (ctxt->mode == X86EMUL_MODE_PROT64)
+               ctxt->op_bytes = 8;
        rc = read_descriptor(ctxt, ctxt->src.addr.mem,
                             &desc_ptr.size, &desc_ptr.address,
                             ctxt->op_bytes);
@@ -3024,6 +3026,8 @@ static int em_lidt(struct x86_emulate_ctxt *ctxt)
        struct desc_ptr desc_ptr;
        int rc;
 
+       if (ctxt->mode == X86EMUL_MODE_PROT64)
+               ctxt->op_bytes = 8;
        rc = read_descriptor(ctxt, ctxt->src.addr.mem,
                             &desc_ptr.size, &desc_ptr.address,
                             ctxt->op_bytes);