]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
KVM: x86 emulator: add LOOP/LOOPcc instruction emulation
authorWei Yongjun <yjwei@cn.fujitsu.com>
Wed, 18 Aug 2010 08:38:21 +0000 (16:38 +0800)
committerAvi Kivity <avi@redhat.com>
Sun, 24 Oct 2010 08:51:11 +0000 (10:51 +0200)
Add LOOP/LOOPcc instruction emulation (opcode 0xe0~0xe2).

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

index 312dda57f93b227b5040c1de8e2049a994647950..2f816edfe31e86a3adf6794e5a542f03cb8f170a 100644 (file)
@@ -2330,7 +2330,7 @@ static struct opcode opcode_table[256] = {
        /* 0xD8 - 0xDF */
        N, N, N, N, N, N, N, N,
        /* 0xE0 - 0xE7 */
-       N, N, N, N,
+       X3(D(SrcImmByte)), N,
        D(ByteOp | SrcImmUByte | DstAcc), D(SrcImmUByte | DstAcc),
        D(ByteOp | SrcAcc | DstImmUByte), D(SrcAcc | DstImmUByte),
        /* 0xE8 - 0xEF */
@@ -3084,6 +3084,12 @@ special_insn:
                c->src.val = c->regs[VCPU_REGS_RCX];
                emulate_grp2(ctxt);
                break;
+       case 0xe0 ... 0xe2:     /* loop/loopz/loopnz */
+               register_address_increment(c, &c->regs[VCPU_REGS_RCX], -1);
+               if (address_mask(c, c->regs[VCPU_REGS_RCX]) != 0 &&
+                   (c->b == 0xe2 || test_cc(c->b ^ 0x5, ctxt->eflags)))
+                       jmp_rel(c, c->src.val);
+               break;
        case 0xe4:      /* inb */
        case 0xe5:      /* in */
                goto do_io_in;