summaryrefslogtreecommitdiff
path: root/arch/x86/kvm/emulate.c
AgeCommit message (Collapse)Author
2011-03-17KVM: emulator: Fix permission checking in io permission bitmapGleb Natapov
Currently if io port + len crosses 8bit boundary in io permission bitmap the check may allow IO that otherwise should not be allowed. The patch fixes that. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2011-03-17KVM: emulator: Fix io permission checking for 64bit guestGleb Natapov
Current implementation truncates upper 32bit of TR base address during IO permission bitmap check. The patch fixes this. Reported-and-tested-by: Francis Moreau <francis.moro@gmail.com> Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2011-03-17KVM: x86 emulator: vendor specific instructionsAvi Kivity
Mark some instructions as vendor specific, and allow the caller to request emulation only of vendor specific instructions. This is useful in some circumstances (responding to a #UD fault). Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-01-12KVM: SVM: copy instruction bytes from VMCBAndre Przywara
In case of a nested page fault or an intercepted #PF newer SVM implementations provide a copy of the faulting instruction bytes in the VMCB. Use these bytes to feed the instruction emulator and avoid the costly guest instruction fetch in this case. Signed-off-by: Andre Przywara <andre.przywara@amd.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-01-12KVM: x86 emulator: simplify exception generationAvi Kivity
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>
2011-01-12KVM: x86 emulator: tighen up ->read_std() and ->write_std() error checksAvi Kivity
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>
2011-01-12KVM: x86 emulator: drop dead pf injection in emulate_popf()Avi Kivity
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>
2011-01-12KVM: x86 emulator: make emulator memory callbacks return full exceptionAvi Kivity
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>
2011-01-12KVM: x86 emulator: introduce struct x86_exception to communicate faultsAvi Kivity
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>
2011-01-12KVM: x86 emulator: do not perform address calculations on linear addressesAvi Kivity
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>
2011-01-12KVM: x86 emulator: preserve an operand's segment identityAvi Kivity
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>
2011-01-12KVM: x86 emulator: drop DPRINTF()Avi Kivity
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>
2011-01-12KVM: x86 emulator: drop unused #ifndef __KERNEL__Avi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
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>