aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/emulate.c
Commit message (Collapse)AuthorAge
...
* KVM: x86 emulator: use single stage decoding for mov instructionsAvi Kivity2010-10-24
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: simplify ALU opcode block decode furtherAvi Kivity2010-10-24
| | | | | | | | | | The ALU opcode block is very regular; introduce D6ALU() to define decode flags for 6 instructions at a time. Suggested by Paolo Bonzini. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: trap and propagate #DE from DIV and IDIVAvi Kivity2010-10-24
| | | | | Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: add macros for executing instructions that may trapAvi Kivity2010-10-24
| | | | | | | Like DIV and IDIV. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: simplify instruction decode flags for opcodes 0F 00-FFAvi Kivity2010-10-24
| | | | | | | Use the new byte/word dual opcode decode. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: simplify instruction decode flags for opcodes E0-FFAvi Kivity2010-10-24
| | | | | | | Use the new byte/word dual opcode decode. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: simplify instruction decode flags for opcodes C0-DFAvi Kivity2010-10-24
| | | | | | | Use the new byte/word dual opcode decode. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: simplify instruction decode flags for opcodes A0-AFAvi Kivity2010-10-24
| | | | | | | Use the new byte/word dual opcode decode. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: simplify instruction decode flags for opcodes 80-8FAvi Kivity2010-10-24
| | | | | | | Use the new byte/word dual opcode decode. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: simplify string instruction decode flagsAvi Kivity2010-10-24
| | | | | | | Use the new byte/word dual opcode decode. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: simplify ALU block (opcodes 00-3F) decode flagsAvi Kivity2010-10-24
| | | | | | | Use the new byte/word dual opcode decode. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: support byte/word opcode pairsAvi Kivity2010-10-24
| | | | | | | | Many x86 instructions come in byte and word variants distinguished with bit 0 of the opcode. Add macros to aid in defining them. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: refuse SrcMemFAddr (e.g. LDS) with register operandAvi Kivity2010-10-24
| | | | | | | | SrcMemFAddr is not defined with the modrm operand designating a register instead of a memory address. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: get rid of "restart" in emulation context.Gleb Natapov2010-10-24
| | | | | | | | x86_emulate_insn() will return 1 if instruction can be restarted without re-entering a guest. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: move string instruction completion check into separate ↵Gleb Natapov2010-10-24
| | | | | | | function Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Rename variable that shadows another local variable.Gleb Natapov2010-10-24
| | | | | Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: add CALL FAR instruction emulation (opcode 9a)Wei Yongjun2010-10-24
| | | | | Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: add JrCXZ instruction emulationWei Yongjun2010-10-24
| | | | | | | | Add JrCXZ instruction emulation (opcode 0xe3) Used by FreeBSD boot loader. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: add LDS/LES/LFS/LGS/LSS instruction emulationWei Yongjun2010-10-24
| | | | | | | | Add LDS/LES/LFS/LGS/LSS instruction emulation. (opcode 0xc4, 0xc5, 0x0f 0xb2, 0x0f 0xb4~0xb5) Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: implement CWD (opcode 99)Avi Kivity2010-10-24
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: implement IMUL REG, R/M, IMM (opcode 69)Avi Kivity2010-10-24
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: add Src2Imm decodingAvi Kivity2010-10-24
| | | | | | Needed for 3-operand IMUL. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: consolidate immediate decode into a functionAvi Kivity2010-10-24
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: implement RDTSC (opcode 0F 31)Avi Kivity2010-10-24
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: remove SrcImplicitAvi Kivity2010-10-24
| | | | | | Useless. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: implement IMUL REG, R/M (opcode 0F AF)Avi Kivity2010-10-24
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: implement IMUL REG, R/M, imm8 (opcode 6B)Avi Kivity2010-10-24
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: implement RET imm16 (opcode C2)Avi Kivity2010-10-24
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: add SrcImmU16 operand typeAvi Kivity2010-10-24
| | | | | | Used for RET NEAR instructions. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: implement CALL FAR (FF /3)Avi Kivity2010-10-24
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: implement DAS (opcode 2F)Avi Kivity2010-10-24
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Use a register for ____emulate_2op() destinationAvi Kivity2010-10-24
| | | | | | | | | Most x86 two operand instructions allow the destination to be a memory operand, but IMUL (for example) requires that the destination be a register. Change ____emulate_2op() to take a register for both source and destination so we can invoke IMUL. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: pass destination type to ____emulate_2op()Avi Kivity2010-10-24
| | | | | | We'll need it later so we can use a register for the destination. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: add LOOP/LOOPcc instruction emulationWei Yongjun2010-10-24
| | | | | | | 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>
* KVM: x86 emulator: add CBW/CWDE/CDQE instruction emulationWei Yongjun2010-10-24
| | | | | | | | Add CBW/CWDE/CDQE instruction emulation.(opcode 0x98) Used by FreeBSD's boot loader. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* 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>