summaryrefslogtreecommitdiff
path: root/arch/x86/kvm/emulate.c
AgeCommit message (Collapse)Author
2010-10-24KVM: fix typo in copyright noticeNicolas Kaiser
Fix typo in copyright notice. Signed-off-by: Nicolas Kaiser <nikai@nikai.net> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-10-24KVM: x86 emulator: Eliminate compilation warning in x86_decode_insn()Sheng Yang
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>
2010-10-24KVM: X86: Propagate fetch faultsJoerg Roedel
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>
2010-10-24KVM: MMU: Track page fault data in struct vcpuJoerg Roedel
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>
2010-10-24KVM: x86 emulator: clean up control flow in x86_emulate_insn()Avi Kivity
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>
2010-10-24KVM: x86 emulator: fix group 11 decoding for reg != 0Avi Kivity
These are all undefined. Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: use single stage decoding for mov instructionsAvi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: simplify ALU opcode block decode furtherAvi Kivity
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>
2010-10-24KVM: x86 emulator: trap and propagate #DE from DIV and IDIVAvi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-10-24KVM: x86 emulator: add macros for executing instructions that may trapAvi Kivity
Like DIV and IDIV. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-10-24KVM: x86 emulator: simplify instruction decode flags for opcodes 0F 00-FFAvi Kivity
Use the new byte/word dual opcode decode. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-10-24KVM: x86 emulator: simplify instruction decode flags for opcodes E0-FFAvi Kivity
Use the new byte/word dual opcode decode. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-10-24KVM: x86 emulator: simplify instruction decode flags for opcodes C0-DFAvi Kivity
Use the new byte/word dual opcode decode. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-10-24KVM: x86 emulator: simplify instruction decode flags for opcodes A0-AFAvi Kivity
Use the new byte/word dual opcode decode. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-10-24KVM: x86 emulator: simplify instruction decode flags for opcodes 80-8FAvi Kivity
Use the new byte/word dual opcode decode. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-10-24KVM: x86 emulator: simplify string instruction decode flagsAvi Kivity
Use the new byte/word dual opcode decode. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-10-24KVM: x86 emulator: simplify ALU block (opcodes 00-3F) decode flagsAvi Kivity
Use the new byte/word dual opcode decode. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-10-24KVM: x86 emulator: support byte/word opcode pairsAvi Kivity
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>
2010-10-24KVM: x86 emulator: refuse SrcMemFAddr (e.g. LDS) with register operandAvi Kivity
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>
2010-10-24KVM: x86 emulator: get rid of "restart" in emulation context.Gleb Natapov
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>
2010-10-24KVM: x86 emulator: move string instruction completion check into separate ↵Gleb Natapov
function Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-10-24KVM: x86 emulator: Rename variable that shadows another local variable.Gleb Natapov
Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-10-24KVM: x86 emulator: add CALL FAR instruction emulation (opcode 9a)Wei Yongjun
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-10-24KVM: x86 emulator: add JrCXZ instruction emulationWei Yongjun
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>
2010-10-24KVM: x86 emulator: add LDS/LES/LFS/LGS/LSS instruction emulationWei Yongjun
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>
2010-10-24KVM: x86 emulator: implement CWD (opcode 99)Avi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: implement IMUL REG, R/M, IMM (opcode 69)Avi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: add Src2Imm decodingAvi Kivity
Needed for 3-operand IMUL. Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: consolidate immediate decode into a functionAvi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: implement RDTSC (opcode 0F 31)Avi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: remove SrcImplicitAvi Kivity
Useless. Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: implement IMUL REG, R/M (opcode 0F AF)Avi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: implement IMUL REG, R/M, imm8 (opcode 6B)Avi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: implement RET imm16 (opcode C2)Avi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: add SrcImmU16 operand typeAvi Kivity
Used for RET NEAR instructions. Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: implement CALL FAR (FF /3)Avi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: implement DAS (opcode 2F)Avi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: Use a register for ____emulate_2op() destinationAvi Kivity
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>
2010-10-24KVM: x86 emulator: pass destination type to ____emulate_2op()Avi Kivity
We'll need it later so we can use a register for the destination. Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: add LOOP/LOOPcc instruction emulationWei Yongjun
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>
2010-10-24KVM: x86 emulator: add CBW/CWDE/CDQE instruction emulationWei Yongjun
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>
2010-10-24KVM: x86 emulator: fix REPZ/REPNZ termination conditionAvi Kivity
EFLAGS.ZF needs to be checked after each iteration, not before. Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: implement SCAS (opcodes AE, AF)Avi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: fix INTn emulation not pushing EFLAGS and CSAvi Kivity
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>
2010-10-24KVM: x86 emulator: remove dup code of in/out instructionWei Yongjun
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: change OUT instruction to use dst instead of srcWei Yongjun
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>
2010-10-24KVM: x86 emulator: introduce DstImmUByte for dst operand decodeWei Yongjun
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>
2010-10-24KVM: x86 emulator: remove useless label from x86_emulate_insn()Wei Yongjun
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2010-10-24KVM: x86 emulator: add setcc instruction emulationWei Yongjun
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>
2010-10-24KVM: x86 emulator: add XADD instruction emulationWei Yongjun
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>