aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/x86_emulate.c
Commit message (Collapse)AuthorAgeFilesLines
* x86: save/restore only partial register state where possibleJan Beulich2012-10-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | ... and make restore conditional not only upon having saved the state, but also upon whether saved state was actually modified (and register values are known to have been preserved). Note that RBP is unconditionally considered a volatile register (i.e. irrespective of CONFIG_FRAME_POINTER), since the RBP handling would become overly complicated due to the need to save/restore it on the compat mode hypercall path [6th argument]. Note further that for compat mode code paths, saving/restoring R8...R15 is entirely unnecessary - we don't allow those guests to enter 64-bit mode, and hence they have no way of seeing these registers' contents (and there consequently also is no information leak, except if the context saving domctl would be considered such). Finally, note that this may not properly deal with gdbstub's needs, yet (but if so, I can't really suggest adjustments, as I don't know that code). Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
* x86/emulator: workaround for AMD erratum 573Jan Beulich2011-12-161-0/+6
| | | | | | | | | | | | | | | | | The only cases where we might end up emulating fsincos (as any other x87 operations without memory operands) are - when a HVM guest is in real mode (not applicable on AMD) - between two half page table updates in PAE mode (unlikely, and not doing the emulation here does affect only performance, not correctness) - when a guest maliciously (or erroneously) modifies an (MMIO or page table update) instruction under emulation (unspecified behavior) Hence, in order to avoid the erratum to cause harm to the entire host, don't emulate fsincos on the affected AMD CPU families. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
* Update my email address to long-term stable address.Keir Fraser2011-01-071-1/+1
| | | | Signed-off-by: Keir Fraser <keir@xen.org>
* x86_emulate: Implement a more dynamic interface for handling FPUKeir Fraser2008-04-161-17/+1
| | | | | | exceptions, which will allow emulation stubs to be built dynamically in a future patch. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Remove environment-specific definitions from coreKeir Fraser2008-03-311-3452/+7
| | | | | emulator source files. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Check I/O port accesses.Keir Fraser2008-03-271-8/+57
| | | | | | | Implements both CPL/IOPL and TSS-bitmap checks. Requires changes to read/write callback hooks to disable user-access checks when walking pagetables on behalf of GDT/LDT/TSS accesses. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Remove the CPL and IOPL check in the I/O handling code.Keir Fraser2008-03-191-3/+0
| | | | | | | The check is already carried out by the processor during VMEXIT, where that is required. Signed-off-by: Xu Dongxiao <dongxiao.xu@intel.com>
* x86_emulate: Return X86EMUL_UNHANDLEABLE if mode_iopl() orKeir Fraser2008-03-191-4/+18
| | | | | | mode_ring0() checks cannot be carried out. Also fix handling of EFLAGS.IF in iret and popf. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86: check ModR/M mod bits for CR/DR access insnsKeir Fraser2008-03-181-1/+1
| | | | | Signed-off-by: Jan Beulich <jbeulich@novell.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Load FPU context before FWAIT.Keir Fraser2008-03-041-0/+2
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Emit emulated forms of most FPU instructions as '.byteKeir Fraser2008-03-041-20/+20
| | | | | | | | | xx,yy'. This is arguably clearer than using the mnemonic opcode, since it is more clearly the instruction we have just decoded. Furthermore, gas likes to reverse FPU operands on some two-operand FPU instructions for historical reasons. Finally, 'byte xx,yy' is potentially more amenable to further macro-isation down the road. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: More FPU instructions.Keir Fraser2008-03-031-8/+83
| | | | | | | | Enables booting OS/2 as a HVM guest on Intel/VT hardware with full real-mode emulation (no vmxassist). Signed-off-by: Trolle Selander <trolle.selander@gmail.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: INS/OUTS need Mov attribute to force writeback (sinceKeir Fraser2008-03-031-3/+1
| | | | | | | | | dst.orig_val is not initialised). Also, Mov attribute on cmpxchg is not necessary -- when destination is memory (i.e., successful cmpxchg) then dst.orig_val is already correctly filled in. In case that dst.orig_val == dst.val then the instruction linearises at the point we first read the destination (and initialised dst.orig_val). Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Fix FNSTCW/FNSTSW modrm range check.Keir Fraser2008-02-261-2/+2
| | | | Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* hvm: More emulation changes: push some of the realmode or HVM-emulateKeir Fraser2008-02-221-81/+80
| | | | | specific stuff into core x86_emulate(). Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* hvm: Remove lots of custom trap-and-emulate code and defer toKeir Fraser2008-02-211-0/+18
| | | | | handle_mmio()->hvm_emulate_one()->x86_emulate(). Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Allow writeback-avoidance optimisation to be defeated byKeir Fraser2008-02-211-1/+3
| | | | | | | | | | the caller. This is used in cases where the writeback may be to an MMIO region with side effects (the APIC EOI register is the main example of this). Also fix up build of the x86_emulate user-space test harness. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Fix IMUL r/m8 emulation.Keir Fraser2008-02-071-0/+1
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Handle rep_ins, rep_outs, rep_movs hook failure and fallKeir Fraser2008-02-071-12/+15
| | | | | back to slow path. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Fix MUL emulation.Keir Fraser2008-02-071-0/+4
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: fix side-effect macro call.Keir Fraser2008-02-051-3/+6
| | | | Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* vmx realmode: Emulate protected-mode transition while CS and SS haveKeir Fraser2008-02-051-13/+154
| | | | | | | | | bad selector values (bottom two bits non-zero). Allows opensuse 10.3 install CD to boot. Unfortunately SUSE Linux 10.1 install CD still fails to work... Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Fix SAHF emulation.Keir Fraser2008-02-051-1/+1
| | | | | Signed-off-by: Xiaohui Xin <xiaohui.xin@intel.com> Signed-off-by: Kevin Tian <kevin.tian@intel.com>
* x86_emulate: Emulate FNINIT, FNSTCW, FNSTSW x87 instructions.Keir Fraser2008-01-231-2/+32
| | | | | | Provide new hook ->load_fpu_ctxt() to ensure emulated environment's FPU state is loaded onto the local processor. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Fix CLTS emulation.Keir Fraser2008-01-231-1/+1
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Provide callbacks for faster emulation of:Keir Fraser2008-01-221-44/+115
| | | | | REP MOVS, REP INS, REP OUTS. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Fix near CALL/JMP <reg,mem>. Broken by c/s 16491.Keir Fraser2008-01-101-1/+1
| | | | | Thanks to AMD for narrowing this one down. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Certain opcodes are only valid with a memory operand.Keir Fraser2008-01-101-0/+4
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Fix handling of RIP-relative addressing.Keir Fraser2008-01-091-2/+2
| | | | | | The handling of SHLD/SHRD introduced in 16696:b5b3e27f1af3f7 was incorrect; thanks to Gary Grebus @ Virtual Iron for spotting it. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Correct RIP-relative addressing offset for SHLD/SHRD withKeir Fraser2008-01-091-0/+3
| | | | | immediate byte third operand. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* Fix x86_emulate() handling of imul with immediate operands.Keir Fraser2008-01-091-8/+11
| | | | | | | This fixes a repeatable crash in RHEL 4.2 ext2 filesystem during boot. Signed-off-by: Gary Grebus <ggrebus@virtualiron.com> Signed-off-by: Ben Guthro <bguthro@virtualiron.com>
* x86_emulate: EFLAGS.PF only reflects least-significant byte of result,Keir Fraser2007-12-051-8/+11
| | | | | so even_parity() can return to its original prototype. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Fix SHLD/SHRD emulation -- cannot rely on dst.orig_valKeir Fraser2007-12-041-1/+1
| | | | | | being already initialised. From: Dexuan Cui <dexuan.cui@intel.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Fix POPA. Few other cleanups.Keir Fraser2007-11-291-7/+17
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Emulate SHLD and SHRD instructions.Keir Fraser2007-11-281-16/+44
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Emulate RDTSC instruction.Keir Fraser2007-11-281-2/+24
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Emulate ENTER and LEAVE instructions.Keir Fraser2007-11-281-1/+58
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Fix use-before-initialise warning.Keir Fraser2007-11-271-1/+1
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Emulate LMSW and SMSW.Keir Fraser2007-11-261-3/+28
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Emulate RETF and RETF imm16.Keir Fraser2007-11-261-1/+16
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Emulate CPUID and HLT.Keir Fraser2007-11-261-2/+21
| | | | | | | vmx realmode: Fix decode & emulate loop, add hooks for CPUID, HLT and WBINVD. Also do not hook realmode entry off of vmentry failure any more. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Emulate LDS/LES/LFS/LGS/LSS.Keir Fraser2007-11-261-3/+35
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Emulate CMPS and SCAS string-compare instructions.Keir Fraser2007-11-251-3/+48
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Emulate IRET.Keir Fraser2007-11-251-1/+28
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Decode and emulate PUSHF/POPF.Keir Fraser2007-11-251-12/+42
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Allow emulated injection of exceptions and interrupts.Keir Fraser2007-11-251-5/+41
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Emulate far call/jmp. This completes emulation of Grp5.Keir Fraser2007-11-251-1/+53
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* vmx realmode: Support privileged EFLAGS updates in emulated realmode.Keir Fraser2007-11-251-7/+4
| | | | | | Also tweak debug tracing to be much less noisy. We can emulates tens of thousands of instructions in rombios now. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* vmx realmode: Plumb through I/O port accesses in emulated realmode.Keir Fraser2007-11-251-4/+30
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_emulate: Support most common segment load/save instructions.Keir Fraser2007-11-241-9/+214
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>