aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/emulate.c
Commit message (Collapse)AuthorAge
...
* KVM: x86 emulator: simplify exception generationAvi Kivity2011-01-12
| | | | | | | | Immediately after we generate an exception, we want a X86EMUL_PROPAGATE_FAULT constant, so return it from the generation functions. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: tighen up ->read_std() and ->write_std() error checksAvi Kivity2011-01-12
| | | | | | | | Instead of checking for X86EMUL_PROPAGATE_FAULT, check for any error, making the callers more reliable. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: drop dead pf injection in emulate_popf()Avi Kivity2011-01-12
| | | | | | | If rc == X86EMUL_PROPAGATE_FAULT, we would have returned earlier. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: make emulator memory callbacks return full exceptionAvi Kivity2011-01-12
| | | | | | | This way, they can return #GP, not just #PF. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: introduce struct x86_exception to communicate faultsAvi Kivity2011-01-12
| | | | | | | | Introduce a structure that can contain an exception to be passed back to main kvm code. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: do not perform address calculations on linear addressesAvi Kivity2011-01-12
| | | | | | | | Linear addresses are supposed to already have segment checks performed on them; if we play with these addresses the checks become invalid. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: preserve an operand's segment identityAvi Kivity2011-01-12
| | | | | | | | | | | | | Currently the x86 emulator converts the segment register associated with an operand into a segment base which is added into the operand address. This loss of information results in us not doing segment limit checks properly. Replace struct operand's addr.mem field by a segmented_address structure which holds both the effetive address and segment. This will allow us to do the limit check at the point of access. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: drop DPRINTF()Avi Kivity2011-01-12
| | | | | | | Failed emulation is reported via a tracepoint; the cmps printk is pointless. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: drop unused #ifndef __KERNEL__Avi Kivity2011-01-12
| | | | | Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: fix typo in copyright noticeNicolas Kaiser2010-10-24
| | | | | | | 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-24
| | | | | | | | | | | 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-24
| | | | | | | | | 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-24
| | | | | | | | | | | | | | | | | | 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-24
| | | | | | | | | | | | 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-24
| | | | | | These are all undefined. Signed-off-by: Avi Kivity <avi@redhat.com>
* 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>