# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1201098629 0
# Node ID 5f3a178a80fce61fd0f573e00b7faadbba993cc4
# Parent 7f940c605893749225a5605fb8a1fa38972bdeb6
x86_emulate: Emulate FNINIT, FNSTCW, FNSTSW x87 instructions.
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@xxxxxxxxxx>
---
xen/arch/x86/x86_emulate.c | 34 ++++++++++++++++++++++++++++++++--
xen/include/asm-x86/x86_emulate.h | 4 ++++
2 files changed, 36 insertions(+), 2 deletions(-)
diff -r 7f940c605893 -r 5f3a178a80fc xen/arch/x86/x86_emulate.c
--- a/xen/arch/x86/x86_emulate.c Wed Jan 23 13:59:24 2008 +0000
+++ b/xen/arch/x86/x86_emulate.c Wed Jan 23 14:30:29 2008 +0000
@@ -159,7 +159,7 @@ static uint8_t opcode_table[256] = {
ByteOp|DstMem|SrcImplicit|ModRM, DstMem|SrcImplicit|ModRM,
ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
/* 0xD8 - 0xDF */
- 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, ImplicitOps|ModRM, 0, ImplicitOps|ModRM, 0, ImplicitOps|ModRM, 0, 0,
/* 0xE0 - 0xE7 */
ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
@@ -864,7 +864,7 @@ x86_emulate(
struct cpu_user_regs _regs = *ctxt->regs;
uint8_t b, d, sib, sib_index, sib_base, twobyte = 0, rex_prefix = 0;
- uint8_t modrm, modrm_mod = 0, modrm_reg = 0, modrm_rm = 0;
+ uint8_t modrm = 0, modrm_mod = 0, modrm_reg = 0, modrm_rm = 0;
unsigned int op_bytes, def_op_bytes, ad_bytes, def_ad_bytes;
#define REPE_PREFIX 1
#define REPNE_PREFIX 2
@@ -2517,6 +2517,36 @@ x86_emulate(
break;
}
+ case 0xd9: /* FPU 0xd9 */
+ fail_if(ops->load_fpu_ctxt == NULL);
+ ops->load_fpu_ctxt(ctxt);
+ fail_if((modrm_reg & 7) != 7);
+ fail_if(modrm_reg >= 0xc0);
+ /* fnstcw m2byte */
+ ea.bytes = 2;
+ dst = ea;
+ asm volatile ( "fnstcw %0" : "=m" (dst.val) );
+ break;
+
+ case 0xdb: /* FPU 0xdb */
+ fail_if(ops->load_fpu_ctxt == NULL);
+ ops->load_fpu_ctxt(ctxt);
+ fail_if(modrm != 0xe3);
+ /* fninit */
+ asm volatile ( "fninit" );
+ break;
+
+ case 0xdd: /* FPU 0xdd */
+ fail_if(ops->load_fpu_ctxt == NULL);
+ ops->load_fpu_ctxt(ctxt);
+ fail_if((modrm_reg & 7) != 7);
+ fail_if(modrm_reg >= 0xc0);
+ /* fnstsw m2byte */
+ ea.bytes = 2;
+ dst = ea;
+ asm volatile ( "fnstsw %0" : "=m" (dst.val) );
+ break;
+
case 0xe0 ... 0xe2: /* loop{,z,nz} */ {
int rel = insn_fetch_type(int8_t);
int do_jmp = !(_regs.eflags & EFLG_ZF); /* loopnz */
diff -r 7f940c605893 -r 5f3a178a80fc xen/include/asm-x86/x86_emulate.h
--- a/xen/include/asm-x86/x86_emulate.h Wed Jan 23 13:59:24 2008 +0000
+++ b/xen/include/asm-x86/x86_emulate.h Wed Jan 23 14:30:29 2008 +0000
@@ -340,6 +340,10 @@ struct x86_emulate_ops
uint8_t vector,
uint8_t insn_len,
struct x86_emulate_ctxt *ctxt);
+
+ /* load_fpu_ctxt: Load emulated environment's FPU state onto processor. */
+ void (*load_fpu_ctxt)(
+ struct x86_emulate_ctxt *ctxt);
};
struct cpu_user_regs;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|