aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/emulate.c
Commit message (Collapse)AuthorAge
...
* KVM: x86 emulator: fix REPZ/REPNZ termination conditionAvi Kivity2010-10-24
| | | | | | EFLAGS.ZF needs to be checked after each iteration, not before. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: implement SCAS (opcodes AE, AF)Avi Kivity2010-10-24
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: fix INTn emulation not pushing EFLAGS and CSAvi Kivity2010-10-24
| | | | | | | emulate_push() only schedules a push; it doesn't actually push anything. Call writeback() to flush out the write. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: remove dup code of in/out instructionWei Yongjun2010-10-24
| | | | | Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: change OUT instruction to use dst instead of srcWei Yongjun2010-10-24
| | | | | | | | Change OUT instruction to use dst instead of src, so we can reuse those code for all out instructions. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: introduce DstImmUByte for dst operand decodeWei Yongjun2010-10-24
| | | | | | | | Introduce DstImmUByte for dst operand decode, which will be used for out instruction. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: remove useless label from x86_emulate_insn()Wei Yongjun2010-10-24
| | | | | Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: add setcc instruction emulationWei Yongjun2010-10-24
| | | | | | | Add setcc instruction emulation (opcode 0x0f 0x90~0x9f) Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: add XADD instruction emulationWei Yongjun2010-10-24
| | | | | | | Add XADD instruction emulation (opcode 0x0f 0xc0~0xc1) Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: put register operand write back to a functionWei Yongjun2010-10-24
| | | | | | | | Introduce function write_register_operand() to write back the register operand. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: add bsf/bsr instruction emulationWei Yongjun2010-10-24
| | | | | | | Add bsf/bsr instruction emulation (opcode 0x0f 0xbc~0xbd) Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Fix emulate_grp3 return valuesMohammed Gamal2010-10-24
| | | | | | | | This patch lets emulate_grp3() return X86EMUL_* return codes instead of hardcoded ones. Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Add unary mul, imul, div, and idiv instructionsMohammed Gamal2010-10-24
| | | | | | | This adds unary mul, imul, div, and idiv instructions (group 3 r/m 4-7). Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: mask group 8 instruction as BitOpWei Yongjun2010-10-24
| | | | | | | | | Mask group 8 instruction as BitOp, so we can share the code for adjust the source operand. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: do not adjust the address for immediate sourceWei Yongjun2010-10-24
| | | | | | | | | adjust the dst address for a register source but not adjust the address for an immediate source. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: fix negative bit offset BitOp instruction emulationWei Yongjun2010-10-24
| | | | | | | | | If bit offset operands is a negative number, BitOp instruction will return wrong value. This patch fix it. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Add stc instruction (opcode 0xf9)Mohammed Gamal2010-10-24
| | | | | Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: using SrcOne for instruction d0/d1 decodingWei Yongjun2010-10-24
| | | | | | | Using SrcOne for instruction d0/d1 decoding. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: disable writeback when decode dest operandWei Yongjun2010-10-24
| | | | | | | | This patch change to disable writeback when decode dest operand if the dest type is ImplicitOps or not specified. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: use SrcAcc to simplify stos decodingWei Yongjun2010-10-24
| | | | | | | Use SrcAcc to simplify stos decoding. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Add into, int, and int3 instructions (opcodes 0xcc-0xce)Mohammed Gamal2010-10-24
| | | | | | | This adds support for int instructions to the emulator. Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: simplify two-byte opcode checkWei Yongjun2010-10-24
| | | | | | | | Two-byte opcode always start with 0x0F and the decode flags of opcode 0xF0 is always 0, so remove dup check. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Fix nop emulationMohammed Gamal2010-10-24
| | | | | | | | If a nop instruction is encountered, we jump directly to the done label. This skip updating rip. Break from the switch case instead Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Decode memory operands directly into a 'struct operand'Avi Kivity2010-10-24
| | | | | | | Since modrm operand can be either register or memory, decoding it into a 'struct operand', which can represent both, is simpler. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: change invlpg emulation to use src.mem.addrAvi Kivity2010-10-24
| | | | | | Instead of using modrm_ea, which will soon be gone. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: switch LEA to use SrcMem decodingAvi Kivity2010-10-24
| | | | | | The NoAccess flag will prevent memory from being accessed. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: add NoAccess flag for memory instructions that skip accessAvi Kivity2010-10-24
| | | | | | Use for INVLPG, which accesses the tlb, not memory. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: use struct operand for mov reg,dr and mov dr,reg for reg opAvi Kivity2010-10-24
| | | | | | | This is an ordinary modrm source or destination; use the standard structure representing it. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: use struct operand for mov reg,cr and mov cr,reg for reg opAvi Kivity2010-10-24
| | | | | | | This is an ordinary modrm source or destination; use the standard structure representing it. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: mark mov cr and mov dr as 64-bit instructions in long modeAvi Kivity2010-10-24
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: introduce Op3264 for mov cr and mov dr instructionsAvi Kivity2010-10-24
| | | | | | | The operands for these instructions are 32 bits or 64 bits, depending on long mode, and ignoring REX prefixes, or the operand size prefix. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: simplify REX.W checkAvi Kivity2010-10-24
| | | | | | (x && (x & y)) == (x & y) Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: drop use_modrm_eaAvi Kivity2010-10-24
| | | | | | Unused (and has never been). Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: put register operand fetch into a functionAvi Kivity2010-10-24
| | | | | | The code is repeated three times, put it into fetch_register_operand() Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: use SrcAcc to simplify xchg decodingAvi Kivity2010-10-24
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: simplify xchg decode tablesAvi Kivity2010-10-24
| | | | | | Use X8() to avoid repetition. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: use correct type for memory address in operandsAvi Kivity2010-10-24
| | | | | | | | | | Currently we use a void pointer for memory addresses. That's wrong since these are guest virtual addresses which are not directly dereferencable by the host. Use the correct type, unsigned long. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: push segment override out of decode_modrm()Avi Kivity2010-10-24
| | | | | | Let it compute modrm_seg instead, and have the caller apply it. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: check io permissions only once for string pioGleb Natapov2010-10-24
| | | | | | | Do not recheck io permission on every iteration. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: fix LMSW able to clear cr0.peAvi Kivity2010-10-24
| | | | | | LMSW is documented not to be able to clear cr0.pe; make it so. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: convert some push instructions to direct decodeAvi Kivity2010-10-24
| | | | | Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: allow repeat macro arguments to contain commasAvi Kivity2010-10-24
| | | | | | | Needed for repeating instructions with execution functions. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: move decode tables downwardsAvi Kivity2010-10-24
| | | | | | | So they can reference execution functions. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: move x86_decode_insn() downwardsAvi Kivity2010-10-24
| | | | | | | No code changes. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: allow storing emulator execution function in decode tablesAvi Kivity2010-10-24
| | | | | | | | Instead of looking up the opcode twice (once for decode flags, once for the big execution switch) look up both flags and function in the decode tables. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: store x86_emulate_ops in emulation contextAvi Kivity2010-10-24
| | | | | | | It doesn't ever change, so we don't need to pass it around everywhere. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: move ByteOp and Dst back to bits 0:3Avi Kivity2010-10-24
| | | | | | | Now that the group index no longer exists, the space is free. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: drop support for old-style groupsAvi Kivity2010-10-24
| | | | | Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: convert group 9 to new styleAvi Kivity2010-10-24
| | | | | Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: convert group 8 to new styleAvi Kivity2010-10-24
| | | | | Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>