summaryrefslogtreecommitdiff
path: root/arch/x86/kvm/x86_emulate.c
AgeCommit message (Collapse)Author
2009-09-10KVM: Rename x86_emulate.c to emulate.cAvi Kivity
We're in arch/x86, what could we possibly be emulating? Signed-off-by: Avi Kivity <avi@redhat.com>
2009-09-10KVM: x86 emulator: Add sysexit emulationAndre Przywara
Handle #UD intercept of the sysexit instruction in 64bit mode returning to 32bit compat mode on an AMD host. Setup the segment descriptors for CS and SS and the EIP/ESP registers according to the manual. Signed-off-by: Christoph Egger <christoph.egger@amd.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Andre Przywara <andre.przywara@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2009-09-10KVM: x86 emulator: Add sysenter emulationAndre Przywara
Handle #UD intercept of the sysenter instruction in 32bit compat mode on an AMD host. Setup the segment descriptors for CS and SS and the EIP/ESP registers according to the manual. Signed-off-by: Christoph Egger <christoph.egger@amd.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Andre Przywara <andre.przywara@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2009-09-10KVM: x86 emulator: add syscall emulationAndre Przywara
Handle #UD intercept of the syscall instruction in 32bit compat mode on an Intel host. Setup the segment descriptors for CS and SS and the EIP/ESP registers according to the manual. Save the RIP and EFLAGS to the correct registers. [avi: fix build on i386 due to missing R11] Signed-off-by: Christoph Egger <christoph.egger@amd.com> Signed-off-by: Andre Przywara <andre.przywara@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2009-09-10KVM: x86 emulator: Prepare for emulation of syscall instructionsAndre Przywara
Add the flags needed for syscall, sysenter and sysexit to the opcode table. Catch (but for now ignore) the opcodes in the emulation switch/case. Signed-off-by: Andre Przywara <andre.przywara@amd.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Christoph Egger <christoph.egger@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2009-09-10KVM: x86 emulator: Add missing EFLAGS bit definitionsAndre Przywara
Signed-off-by: Christoph Egger <christoph.egger@amd.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Andre Przywara <andre.przywara@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2009-09-10KVM: x86 emulator: fix jmp far decoding (opcode 0xea)Avi Kivity
The jump target should not be sign extened; use an unsigned decode flag. Cc: stable@kernel.org Signed-off-by: Avi Kivity <avi@redhat.com>
2009-09-10KVM: x86 emulator: Implement zero-extended immediate decodingAvi Kivity
Absolute jumps use zero extended immediate operands. Cc: stable@kernel.org Signed-off-by: Avi Kivity <avi@redhat.com>
2009-06-28KVM: kvm/x86_emulate.c toggle_interruptibility() should be staticJaswinder Singh Rajput
toggle_interruptibility() is used only by same file, it should be static. Fixed following sparse warning : arch/x86/kvm/x86_emulate.c:1364:6: warning: symbol 'toggle_interruptibility' was not declared. Should it be static? Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2009-06-10KVM: Deal with interrupt shadow state for emulated instructionsGlauber Costa
We currently unblock shadow interrupt state when we skip an instruction, but failing to do so when we actually emulate one. This blocks interrupts in key instruction blocks, in particular sti; hlt; sequences If the instruction emulated is an sti, we have to block shadow interrupts. The same goes for mov ss. pop ss also needs it, but we don't currently emulate it. Without this patch, I cannot boot gpxe option roms at vmx machines. This is described at https://bugzilla.redhat.com/show_bug.cgi?id=494469 Signed-off-by: Glauber Costa <glommer@redhat.com> CC: H. Peter Anvin <hpa@zytor.com> CC: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2009-06-10KVM: x86 emulator: Decode soft interrupt instructionsGleb Natapov
Do not emulate them yet. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2009-06-10KVM: x86 emulator: Completely decode in/out at decoding stageGleb Natapov
Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2009-06-10KVM: x86 emulator: Add unsigned byte immediate decodeGleb Natapov
Extend "Source operand type" opcode description field to 4 bites to accommodate new option. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2009-06-10KVM: x86 emulator: Complete decoding of call near in decode stageGleb Natapov
Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2009-06-10KVM: x86 emulator: Complete short/near jcc decoding in decode stageGleb Natapov
Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2009-06-10KVM: x86 emulator: Complete ljmp decoding at decode stageGleb Natapov
Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2009-06-10KVM: x86 emulator: Add lcall decodingGleb Natapov
No emulation yet. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2009-06-10KVM: x86 emulator: Add decoding of 16bit second immediate argumentGleb Natapov
Such as segment number in lcall/ljmp Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2009-06-10KVM: x86 emulator: fix call near emulationGleb Natapov
The length of pushed on to the stack return address depends on operand size not address size. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2009-03-24KVM: x86 emulator: implement 'ret far' instruction (opcode 0xcb)Avi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com>
2009-03-24KVM: x86 emulator: Make emulate_pop() a little more genericAvi Kivity
Allow emulate_pop() to read into arbitrary memory rather than just the source operand. Needed for complicated instructions like far returns. Signed-off-by: Avi Kivity <avi@redhat.com>
2009-03-24KVM: Fix vmload and friends misinterpreted as lidtAvi Kivity
The AMD SVM instruction family all overload the 0f 01 /3 opcode, further multiplexing on the three r/m bits. But the code decided that anything that isn't a vmmcall must be an lidt (which shares the 0f 01 /3 opcode, for the case that mod = 3). Fix by aborting emulation if this isn't a vmmcall. Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: x86 emulator: Fix handling of VMMCALL instructionAmit Shah
The VMMCALL instruction doesn't get recognised and isn't processed by the emulator. This is seen on an Intel host that tries to execute the VMMCALL instruction after a guest live migrates from an AMD host. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: x86 emulator: add the emulation of shld and shrd instructionsGuillaume Thouvenin
Add emulation of shld and shrd instructions Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net> Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: x86 emulator: add the assembler code for three operandsGuillaume Thouvenin
Add the assembler code for instruction with three operands and one operand is stored in ECX register Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net> Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: x86 emulator: add a new "implied 1" Src decode typeGuillaume Thouvenin
Add SrcOne operand type when we need to decode an implied '1' like with regular shift instruction Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net> Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: x86 emulator: add Src2 decode setGuillaume Thouvenin
Instruction like shld has three operands, so we need to add a Src2 decode set. We start with Src2None, Src2CL, and Src2ImmByte, Src2One to support shld/shrd and we will expand it later. Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net> Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: x86 emulator: Extend the opcode descriptorGuillaume Thouvenin
Extend the opcode descriptor to 32 bits. This is needed by the introduction of a new Src2 operand type. Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net> Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: Remove extraneous semicolon after do/whileAvi Kivity
Notices by Guillaume Thouvenin. Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: x86 emulator: fix popf emulationAvi Kivity
Set operand type and size to get correct writeback behavior. Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: x86 emulator: fix ret emulationAvi Kivity
'ret' did not set the operand type or size for the destination, so writeback ignored it. Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: x86 emulator: switch 'pop reg' instruction to emulate_pop()Avi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: x86 emulator: allow pop from mmioAvi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: x86 emulator: Extract 'pop' sequence into a functionAvi Kivity
Switch 'pop r/m' instruction to use the new function. Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: x86 emulator: consolidate emulation of two operand instructionsAvi Kivity
No need to repeat the same assembly block over and over. Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: x86 emulator: reduce duplication in one operand emulation thunksAvi Kivity
Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: allow emulator to adjust rip for emulated pio instructionsGuillaume Thouvenin
If we call the emulator we shouldn't call skip_emulated_instruction() in the first place, since the emulator already computes the next rip for us. Thus we move ->skip_emulated_instruction() out of kvm_emulate_pio() and into handle_io() (and the svm equivalent). We also replaced "return 0" by "break" in the "do_io:" case because now the shadow register state needs to be committed. Otherwise eip will never be updated. Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net> Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: x86 emulator: Add decode entries for 0x04 and 0x05 opcodes (add acc, imm)Guillaume Thouvenin
Add decode entries for 0x04 and 0x05 (ADD) opcodes, execution is already implemented. Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net> Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31KVM: x86 emulator: consolidate push regGuillaume Thouvenin
This patch consolidate the emulation of push reg instruction. Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@bull.net> Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net> Signed-off-by: Avi Kivity <avi@redhat.com>
2008-10-15KVM: x86 emulator: Use DstAcc for 'and'Guillaume Thouvenin
For instruction 'and al,imm' we use DstAcc instead of doing the emulation directly into the instruction's opcode. Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-10-15KVM: x86 emulator: Add cmp al, imm and cmp ax, imm instructions (ocodes 3c, 3d)Guillaume Thouvenin
Add decode entries for these opcodes; execution is already implemented. Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-10-15KVM: x86 emulator: Add DstAcc operand typeGuillaume Thouvenin
Add DstAcc operand type. That means that there are 4 bits now for DstMask. "In the good old days cpus would have only one register that was able to fully participate in arithmetic operations, typically called A for Accumulator. The x86 retains this tradition by having special, shorter encodings for the A register (like the cmp opcode), and even some instructions that only operate on A (like mul). SrcAcc and DstAcc would accommodate these instructions by decoding A into the corresponding 'struct operand'." -- Avi Kivity Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-10-15KVM: x86 emulator: fix jmp r/m64 instructionAvi Kivity
jmp r/m64 doesn't require the rex.w prefix to indicate the operand size is 64 bits. Set the Stack attribute (even though it doesn't involve the stack, really) to indicate this. Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-10-15KVM: x86 emulator: Add call near absolute instruction (opcode 0xff/2)Mohammed Gamal
Add call near absolute instruction. Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-10-15KVM: x86 emulator: Add in/out instructions (opcodes 0xe4-0xe7, 0xec-0xef)Mohammed Gamal
The patch adds in/out instructions to the x86 emulator. The instruction was encountered while running the BIOS while using the invalid guest state emulation patch. Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-10-15KVM: x86 emulator: Add std and cld instructions (opcodes 0xfc-0xfd)Mohammed Gamal
This adds the std and cld instructions to the emulator. Encountered while running the BIOS with invalid guest state emulation enabled. Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-10-15KVM: x86 emulator: Add mov r, imm instructions (opcodes 0xb0-0xbf)Mohammed Gamal
The emulator only supported one instance of mov r, imm instruction (opcode 0xb8), this adds the rest of these instructions. Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-10-15KVM: x86 emulator: remove bad ByteOp specifier from NEG descriptorAvi Kivity
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-10-15KVM: x86 emulator: remove duplicate SrcImmroel kluin
Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-10-15KVM: x86: accessors for guest registersMarcelo Tosatti
As suggested by Avi, introduce accessors to read/write guest registers. This simplifies the ->cache_regs/->decache_regs interface, and improves register caching which is important for VMX, where the cost of vmcs_read/vmcs_write is significant. [avi: fix warnings] Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@qumranet.com>