]> err.no Git - linux-2.6/blobdiff - drivers/kvm/x86_emulate.c
sysctl: for irda update sysctl_checks list of binary paths
[linux-2.6] / drivers / kvm / x86_emulate.c
index e4ce34c52ba1e55182bdfccf63fa9c83d3f1e5fd..9737c3b2f48c1a2006cd6420ce192f04a323c7e3 100644 (file)
@@ -111,8 +111,12 @@ static u8 opcode_table[256] = {
        0, 0, ImplicitOps|Mov, 0,
        SrcNone  | ByteOp  | ImplicitOps, SrcNone  | ImplicitOps, /* insb, insw/insd */
        SrcNone  | ByteOp  | ImplicitOps, SrcNone  | ImplicitOps, /* outsb, outsw/outsd */
-       /* 0x70 - 0x7F */
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       /* 0x70 - 0x77 */
+       ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
+       ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
+       /* 0x78 - 0x7F */
+       ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
+       ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
        /* 0x80 - 0x87 */
        ByteOp | DstMem | SrcImm | ModRM, DstMem | SrcImm | ModRM,
        ByteOp | DstMem | SrcImm | ModRM, DstMem | SrcImmByte | ModRM,
@@ -121,9 +125,9 @@ static u8 opcode_table[256] = {
        /* 0x88 - 0x8F */
        ByteOp | DstMem | SrcReg | ModRM | Mov, DstMem | SrcReg | ModRM | Mov,
        ByteOp | DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov,
-       0, 0, 0, DstMem | SrcNone | ModRM | Mov,
+       0, ModRM | DstReg, 0, DstMem | SrcNone | ModRM | Mov,
        /* 0x90 - 0x9F */
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ImplicitOps, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ImplicitOps, ImplicitOps, 0, 0,
        /* 0xA0 - 0xA7 */
        ByteOp | DstReg | SrcMem | Mov, DstReg | SrcMem | Mov,
        ByteOp | DstMem | SrcReg | Mov, DstMem | SrcReg | Mov,
@@ -188,7 +192,10 @@ static u16 twobyte_table[256] = {
        /* 0x70 - 0x7F */
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        /* 0x80 - 0x8F */
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
+       ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
+       ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
+       ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
        /* 0x90 - 0x9F */
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        /* 0xA0 - 0xA7 */
@@ -479,6 +486,41 @@ static int read_descriptor(struct x86_emulate_ctxt *ctxt,
        return rc;
 }
 
+static int test_cc(unsigned int condition, unsigned int flags)
+{
+       int rc = 0;
+
+       switch ((condition & 15) >> 1) {
+       case 0: /* o */
+               rc |= (flags & EFLG_OF);
+               break;
+       case 1: /* b/c/nae */
+               rc |= (flags & EFLG_CF);
+               break;
+       case 2: /* z/e */
+               rc |= (flags & EFLG_ZF);
+               break;
+       case 3: /* be/na */
+               rc |= (flags & (EFLG_CF|EFLG_ZF));
+               break;
+       case 4: /* s */
+               rc |= (flags & EFLG_SF);
+               break;
+       case 5: /* p/pe */
+               rc |= (flags & EFLG_PF);
+               break;
+       case 7: /* le/ng */
+               rc |= (flags & EFLG_ZF);
+               /* fall through */
+       case 6: /* l/nge */
+               rc |= (!(flags & EFLG_SF) != !(flags & EFLG_OF));
+               break;
+       }
+
+       /* Odd condition identifiers (lsb == 1) have inverted sense. */
+       return (!!rc ^ (condition & 1));
+}
+
 int
 x86_emulate_memop(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
 {
@@ -785,6 +827,7 @@ done_prefixes:
              srcmem_common:
                src.type = OP_MEM;
                src.ptr = (unsigned long *)cr2;
+               src.val = 0;
                if ((rc = ops->read_emulated((unsigned long)src.ptr,
                                             &src.val, src.bytes, ctxt->vcpu)) != 0)
                        goto done;
@@ -849,6 +892,7 @@ done_prefixes:
                dst.type = OP_MEM;
                dst.ptr = (unsigned long *)cr2;
                dst.bytes = (d & ByteOp) ? 1 : op_bytes;
+               dst.val = 0;
                if (d & BitOp) {
                        unsigned long mask = ~(dst.bytes * 8 - 1);
 
@@ -980,6 +1024,9 @@ push:
                break;
        case 0x88 ... 0x8b:     /* mov */
                goto mov;
+       case 0x8d: /* lea r16/r32, m */
+               dst.val = modrm_val;
+               break;
        case 0x8f:              /* pop (sole member of Grp1a) */
                /* 64-bit mode: POP always pops a 64-bit operand. */
                if (mode == X86EMUL_MODE_PROT64)
@@ -1103,6 +1150,12 @@ push:
                case 1: /* dec */
                        emulate_1op("dec", dst, _eflags);
                        break;
+               case 4: /* jmp abs */
+                       if (b == 0xff)
+                               _eip = dst.val;
+                       else
+                               goto cannot_emulate;
+                       break;
                case 6: /* push */
                        /* 64-bit mode: PUSH always pushes a 64-bit operand. */
                        if (mode == X86EMUL_MODE_PROT64) {
@@ -1230,9 +1283,19 @@ special_insn:
                                ) == 0)
                        return -1;
                return 0;
+       case 0x70 ... 0x7f: /* jcc (short) */ {
+               int rel = insn_fetch(s8, 1, _eip);
+
+               if (test_cc(b, _eflags))
+               JMP_REL(rel);
+               break;
+       }
        case 0x9c: /* pushf */
                src.val =  (unsigned long) _eflags;
                goto push;
+       case 0x9d: /* popf */
+               dst.ptr = (unsigned long *) &_eflags;
+               goto pop_instruction;
        case 0xc3: /* ret */
                dst.ptr = &_eip;
                goto pop_instruction;
@@ -1486,6 +1549,27 @@ twobyte_special_insn:
                }
                rc = X86EMUL_CONTINUE;
                break;
+       case 0x80 ... 0x8f: /* jnz rel, etc*/ {
+               long int rel;
+
+               switch (op_bytes) {
+               case 2:
+                       rel = insn_fetch(s16, 2, _eip);
+                       break;
+               case 4:
+                       rel = insn_fetch(s32, 4, _eip);
+                       break;
+               case 8:
+                       rel = insn_fetch(s64, 8, _eip);
+                       break;
+               default:
+                       DPRINTF("jnz: Invalid op_bytes\n");
+                       goto cannot_emulate;
+               }
+               if (test_cc(b, _eflags))
+                       JMP_REL(rel);
+               break;
+       }
        case 0xc7:              /* Grp9 (cmpxchg8b) */
                {
                        u64 old, new;