summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/emulate.c
Commit message (Collapse)AuthorAgeFilesLines
* KVM: fix typo in copyright noticeNicolas Kaiser2010-10-241-1/+1
| | | | | | | Fix typo in copyright notice. Signed-off-by: Nicolas Kaiser <nikai@nikai.net> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Eliminate compilation warning in x86_decode_insn()Sheng Yang2010-10-241-1/+1
| | | | | | | | | | | Eliminate: arch/x86/kvm/emulate.c:801: warning: ‘sv’ may be used uninitialized in this function on gcc 4.1.2 Signed-off-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: X86: Propagate fetch faultsJoerg Roedel2010-10-241-0/+3
| | | | | | | | | KVM currently ignores fetch faults in the instruction emulator. With nested-npt we could have such faults. This patch adds the code to handle these. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: Track page fault data in struct vcpuJoerg Roedel2010-10-241-16/+14
| | | | | | | | | | | | | | | | | | This patch introduces a struct with two new fields in vcpu_arch for x86: * fault.address * fault.error_code This will be used to correctly propagate page faults back into the guest when we could have either an ordinary page fault or a nested page fault. In the case of a nested page fault the fault-address is different from the original address that should be walked. So we need to keep track about the real fault-address. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: clean up control flow in x86_emulate_insn()Avi Kivity2010-10-241-57/+7
| | | | | | | | | | | | x86_emulate_insn() is full of things like if (rc != X86EMUL_CONTINUE) goto done; break; consolidate all of those at the end of the switch statement. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: fix group 11 decoding for reg != 0Avi Kivity2010-10-241-1/+5
| | | | | | These are all undefined. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: use single stage decoding for mov instructionsAvi Kivity2010-10-241-24/+18
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: simplify ALU opcode block decode furtherAvi Kivity2010-10-241-18/+14
| | | | | | | | | | 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-241-4/+16
| | | | | 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-241-0/+43
| | | | | | | 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-241-2/+2
| | | | | | | 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-241-4/+2
| | | | | | | 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-241-4/+3
| | | | | | | 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-241-3/+3
| | | | | | | 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-241-4/+3
| | | | | | | 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-241-7/+6
| | | | | | | 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-241-24/+16
| | | | | | | 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-241-0/+6
| | | | | | | | 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-241-0/+5
| | | | | | | | 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-241-24/+19
| | | | | | | | 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-241-13/+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-241-3/+3
| | | | | 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-241-1/+1
| | | | | 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-241-1/+5
| | | | | | | | 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-241-4/+46
| | | | | | | | 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-241-1/+14
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: implement IMUL REG, R/M, IMM (opcode 69)Avi Kivity2010-10-241-1/+2
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: add Src2Imm decodingAvi Kivity2010-10-241-0/+4
| | | | | | Needed for 3-operand IMUL. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: consolidate immediate decode into a functionAvi Kivity2010-10-241-45/+64
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: implement RDTSC (opcode 0F 31)Avi Kivity2010-10-241-1/+18
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: remove SrcImplicitAvi Kivity2010-10-241-2/+1
| | | | | | Useless. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: implement IMUL REG, R/M (opcode 0F AF)Avi Kivity2010-10-241-3/+10
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: implement IMUL REG, R/M, imm8 (opcode 6B)Avi Kivity2010-10-241-1/+11
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: implement RET imm16 (opcode C2)Avi Kivity2010-10-241-1/+18
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: add SrcImmU16 operand typeAvi Kivity2010-10-241-3/+9
| | | | | | Used for RET NEAR instructions. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: implement CALL FAR (FF /3)Avi Kivity2010-10-241-1/+36
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: implement DAS (opcode 2F)Avi Kivity2010-10-241-1/+41
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Use a register for ____emulate_2op() destinationAvi Kivity2010-10-241-1/+1
| | | | | | | | | 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-241-6/+6
| | | | | | 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-241-1/+7
| | | | | | | 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-241-1/+8
| | | | | | | | 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-241-21/+20
| | | | | | 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-241-3/+2
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: fix INTn emulation not pushing EFLAGS and CSAvi Kivity2010-10-241-1/+12
| | | | | | | 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-241-20/+4
| | | | | 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-241-7/+8
| | | | | | | | 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-241-0/+7
| | | | | | | | 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-241-5/+1
| | | | | 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-241-1/+4
| | | | | | | 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-241-1/+8
| | | | | | | 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>
OpenPOWER on IntegriCloud