KVM: x86 emulator: fix cli/sti instruction emulation
authorWei Yongjun <yjwei@cn.fujitsu.com>
Tue, 6 Jul 2010 08:54:19 +0000 (16:54 +0800)
committerAvi Kivity <avi@redhat.com>
Mon, 2 Aug 2010 03:40:26 +0000 (06:40 +0300)
If IOPL check fail, the cli/sti emulate GP and then we should
skip writeback since the default write OP is OP_REG.

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

index 8337567..286572a 100644 (file)
@@ -2979,17 +2979,19 @@ special_insn:
                c->dst.type = OP_NONE;  /* Disable writeback. */
                break;
        case 0xfa: /* cli */
-               if (emulator_bad_iopl(ctxt, ops))
+               if (emulator_bad_iopl(ctxt, ops)) {
                        emulate_gp(ctxt, 0);
-               else {
+                       goto done;
+               } else {
                        ctxt->eflags &= ~X86_EFLAGS_IF;
                        c->dst.type = OP_NONE;  /* Disable writeback. */
                }
                break;
        case 0xfb: /* sti */
-               if (emulator_bad_iopl(ctxt, ops))
+               if (emulator_bad_iopl(ctxt, ops)) {
                        emulate_gp(ctxt, 0);
-               else {
+                       goto done;
+               } else {
                        ctxt->interruptibility = KVM_X86_SHADOW_INT_STI;
                        ctxt->eflags |= X86_EFLAGS_IF;
                        c->dst.type = OP_NONE;  /* Disable writeback. */