summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/emulate.c
Commit message (Collapse)AuthorAgeFilesLines
* KVM: x86 emulator: fix Src2CL decodeAvi Kivity2011-09-251-1/+1
| | | | | | | | | | Src2CL decode (used for double width shifts) erronously decodes only bit 3 of %rcx, instead of bits 7:0. Fix by decoding %cl in its entirety. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: fold decode_cache into x86_emulate_ctxtAvi Kivity2011-07-121-693/+586
| | | | | | | This saves a lot of pointless casts x86_emulate_ctxt and decode_cache. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: rename decode_cache::eip to _eipAvi Kivity2011-07-121-60/+60
| | | | | | | | | | | The name eip conflicts with a field of the same name in x86_emulate_ctxt, which we plan to fold decode_cache into. The name _eip is unfortunate, but what's really needed is a refactoring here, not a better name. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Use opcode::execute for CLI/STI(FA/FB)Takuya Yoshikawa2011-07-121-17/+21
| | | | | Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Use opcode::execute for LOOP/JCXZTakuya Yoshikawa2011-07-121-11/+24
| | | | | | | | LOOP/LOOPcc : E0-E2 JCXZ/JECXZ/JRCXZ : E3 Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Clean up INT n/INTO/INT 3(CC/CD/CE)Takuya Yoshikawa2011-07-121-10/+5
| | | | | | | Call emulate_int() directly to avoid spaghetti goto's. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Use opcode::execute for MOV(8C/8E)Takuya Yoshikawa2011-07-121-28/+31
| | | | | | | Different functions for those which take segment register operands. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Use opcode::execute for RET(C3)Takuya Yoshikawa2011-07-121-7/+11
| | | | | Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Use opcode::execute for XCHG(86/87)Takuya Yoshikawa2011-07-121-14/+17
| | | | | | | In addition, replace one "goto xchg" with an em_xchg() call. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Use opcode::execute for TEST(84/85, A8/A9)Takuya Yoshikawa2011-07-121-8/+11
| | | | | Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Use opcode::execute for some instructionsTakuya Yoshikawa2011-07-121-29/+8
| | | | | | | | | | | | | | | | Move the following functions to the opcode tables: RET (Far return) : CB IRET : CF JMP (Jump far) : EA SYSCALL : 0F 05 CLTS : 0F 06 SYSENTER : 0F 34 SYSEXIT : 0F 35 Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Rename emulate_xxx() to em_xxx()Takuya Yoshikawa2011-07-121-10/+10
| | | | | | | The next patch will change these to be called by opcode::execute. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Use the pointers ctxt and c consistentlyTakuya Yoshikawa2011-07-121-3/+3
| | | | | | | | | We should use the local variables ctxt and c when the emulate_ctxt and decode appears many times. At least, we need to be consistent about how we use these in a function. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: fix uninitialized warningXiao Guangrong2011-07-121-1/+1
| | | | | | | | | | Fix: warning: ‘cs_sel’ may be used uninitialized in this function warning: ‘ss_sel’ may be used uninitialized in this function Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Stop passing ctxt->ops as arg of emul functionsTakuya Yoshikawa2011-07-121-143/+116
| | | | | | | | | | | | Dereference it in the actual users. This not only cleans up the emulator but also makes it easy to convert the old emulation functions to the new em_xxx() form later. Note: Remove some inline keywords to let the compiler decide inlining. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Stop passing ctxt->ops as arg of decode helpersTakuya Yoshikawa2011-07-121-15/+8
| | | | | | | | | Dereference it in the actual users: only do_insn_fetch_byte(). This is consistent with the way __linearize() dereferences it. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Place insn_fetch helpers togetherTakuya Yoshikawa2011-07-121-19/+19
| | | | | | | | | | | | | | | | The two macros need special care to use: Assume rc, ctxt, ops and done exist outside of them. Can goto outside. Considering the fact that these are used only in decode functions, moving these right after do_insn_fetch() seems to be a right thing to improve the readability. We also rename do_fetch_insn_byte() to do_insn_fetch_byte() to be consistent. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: fix %rip-relative addressing with immediate source operandAvi Kivity2011-06-291-5/+7
| | | | | | | | | | | %rip-relative addressing is relative to the first byte of the next instruction, so we need to add %rip only after we've fetched any immediate bytes. Based on original patch by Li Xin <xin.li@intel.com>. Signed-off-by: Avi Kivity <avi@redhat.com> Acked-by: Li Xin <xin.li@intel.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86: use proper port value when checking io instruction permissionMarcelo Tosatti2011-06-061-35/+47
| | | | | | | | | | | | Commit f6511935f42 moved the permission check for io instructions to the ->check_perm callback. It failed to copy the port value from RDX register for string and "in,out ax,dx" instructions. Fix it by reading RDX register at decode stage when appropriate. Fixes FC8.32 installation. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: Make jmp far emulation into a separate functionTakuya Yoshikawa2011-05-221-14/+22
| | | | | | | | | | We introduce em_jmp_far(). We also call this from em_grp45() to stop treating modrm_reg == 5 case separately in the group 5 emulation. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Rename emulate_grpX() to em_grpX()Takuya Yoshikawa2011-05-221-16/+15
| | | | | | | | | The prototypes are changed appropriately. We also replaces "goto grp45;" with simple em_grp45() call. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Remove unused arg from emulate_pop()Takuya Yoshikawa2011-05-221-15/+13
| | | | | | | The opt of emulate_grp1a() is also removed. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Remove unused arg from writeback()Takuya Yoshikawa2011-05-221-3/+2
| | | | | | | Remove inline at this chance. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Remove unused arg from read_descriptor()Takuya Yoshikawa2011-05-221-5/+3
| | | | | Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Remove unused arg from seg_override()Takuya Yoshikawa2011-05-221-4/+3
| | | | | | | | In addition, one comma at the end of a statement is replaced with a semicolon. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: consolidate segment accessorsAvi Kivity2011-05-221-53/+69
| | | | | | | Instead of separate accessors for the segment selector and cached descriptor, use one accessor for both. This simplifies the code somewhat. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: emulator: Propagate fault in far jump emulationGleb Natapov2011-05-221-1/+2
| | | | | Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: consolidate group handlingAvi Kivity2011-05-221-40/+40
| | | | | | | Move all groups into a single field and handle them in a single place. This saves bits when we add more group types (3 bits -> 7 groups types). Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Use opcode::execute for PUSHF/POPF (9C/9D)Takuya Yoshikawa2011-05-221-11/+20
| | | | | | | For this, em_pushf/popf() are introduced. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Use opcode::execute for PUSHA/POPA (60/61)Takuya Yoshikawa2011-05-221-11/+5
| | | | | | | For this, emulate_pusha/popa() are converted to em_pusha/popa(). Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Use opcode::execute for POP reg (58-5F)Takuya Yoshikawa2011-05-221-6/+10
| | | | | | | | In addition, the RET emulation is changed to call em_pop() to remove the pop_instruction label. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Use opcode::execute for Group 1, CMPS and SCASTakuya Yoshikawa2011-05-221-72/+89
| | | | | | | | | | | | | | | The following instructions are changed to use opcode::execute. Group 1 (80-83) ADD (00-05), OR (08-0D), ADC (10-15), SBB (18-1D), AND (20-25), SUB (28-2D), XOR (30-35), CMP (38-3D) CMPS (A6-A7), SCAS (AE-AF) The last two do the same as CMP in the emulator, so em_cmp() is used. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Use opcode::execute for 0F 01 opcodeAvi Kivity2011-05-221-43/+13
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Don't force #UD for 0F 01 /5Avi Kivity2011-05-221-3/+0
| | | | | | | While it isn't defined, no need to force a #UD. If it becomes defined in the future this can cause wierd problems for the guest. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: move 0F 01 sub-opcodes into their own functionsAvi Kivity2011-05-221-47/+99
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: fix const value warning on i386 in svm insn RAX checkRandy Dunlap2011-05-221-1/+1
| | | | | | | arch/x86/kvm/emulate.c:2598: warning: integer constant is too large for 'long' type Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: avoid calling wbinvd() macroClemens Noss2011-05-221-1/+1
| | | | | | | | | | | | | | | | | Commit 0b56652e33c72092956c651ab6ceb9f0ad081153 fails to build: CC [M] arch/x86/kvm/emulate.o arch/x86/kvm/emulate.c: In function 'x86_emulate_insn': arch/x86/kvm/emulate.c:4095:25: error: macro "wbinvd" passed 1 arguments, but takes just 0 arch/x86/kvm/emulate.c:4095:3: warning: statement with no effect make[2]: *** [arch/x86/kvm/emulate.o] Error 1 make[1]: *** [arch/x86/kvm] Error 2 make: *** [arch/x86] Error 2 Work around this for now. Signed-off-by: Clemens Noss <cnoss@gmx.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: add new ->wbinvd() callbackAvi Kivity2011-05-221-1/+1
| | | | | | Instead of calling kvm_emulate_wbinvd() directly. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: add ->fix_hypercall() callbackAvi Kivity2011-05-221-2/+2
| | | | | | Artificial, but needed to remove direct calls to KVM. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: add new ->halt() callbackAvi Kivity2011-05-221-1/+1
| | | | | | Instead of reaching into vcpu internals. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: make emulate_invlpg() an emulator callbackAvi Kivity2011-05-221-1/+1
| | | | | | Removing direct calls to KVM. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: emulate CLTS internallyAvi Kivity2011-05-221-1/+11
| | | | | | | | | Avoid using ctxt->vcpu; we can do everything with ->get_cr() and ->set_cr(). A side effect is that we no longer activate the fpu on emulated CLTS; but that should be very rare. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Replace calls to is_pae() and is_paging with ->get_cr()Avi Kivity2011-05-221-2/+2
| | | | | | Avoid use of ctxt->vcpu. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: drop use of is_long_mode()Avi Kivity2011-05-221-7/+12
| | | | | | | Requires ctxt->vcpu, which is to be abolished. Replace with open calls to get_msr(). Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: add and use new callbacks set_idt(), set_gdt()Avi Kivity2011-05-221-7/+7
| | | | | | Replacing direct calls to realmode_lgdt(), realmode_lidt(). Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: avoid using ctxt->vcpu in check_perm() callbacksAvi Kivity2011-05-221-2/+2
| | | | | | Unneeded for register access. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: drop vcpu argument from intercept callbackAvi Kivity2011-05-221-1/+1
| | | | | | Making the emulator caller agnostic. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: drop vcpu argument from cr/dr/cpl/msr callbacksAvi Kivity2011-05-221-42/+42
| | | | | | Making the emulator caller agnostic. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: drop vcpu argument from segment/gdt/idt callbacksAvi Kivity2011-05-221-56/+56
| | | | | | | | | Making the emulator caller agnostic. [Takuya Yoshikawa: fix typo leading to LDT failures] Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: drop vcpu argument from pio callbacksAvi Kivity2011-05-111-3/+3
| | | | | | Making the emulator caller agnostic. Signed-off-by: Avi Kivity <avi@redhat.com>
OpenPOWER on IntegriCloud