MFC: Clear invalid bits in SSE mxcsr register.

This commit is contained in:
davidxu 2006-07-01 00:57:56 +00:00
parent 5e60f60f14
commit b0faec3bf7
6 changed files with 21 additions and 5 deletions

View File

@ -87,6 +87,7 @@ char cpu_vendor[20] = ""; /* CPU Origin code */
#ifdef CPU_ENABLE_SSE
u_int cpu_fxsr; /* SSE enabled */
u_int cpu_mxcsr_mask; /* valid bits in mxcsr */
#endif
#ifdef I486_CPU

View File

@ -2666,6 +2666,10 @@ set_fpcontext(struct thread *td, const mcontext_t *mcp)
bcopy(&mcp->mc_fpstate, addr, sizeof(mcp->mc_fpstate));
}
#ifdef DEV_NPX
#ifdef CPU_ENABLE_SSE
if (cpu_fxsr)
addr->sv_xmm.sv_env.en_mxcsr &= cpu_mxcsr_mask;
#endif
/*
* XXX we violate the dubious requirement that npxsetregs()
* be called with interrupts disabled.

View File

@ -45,20 +45,21 @@ int
cpu_ptrace(struct thread *td, int req, void *addr, int data)
{
#ifdef CPU_ENABLE_SSE
struct savexmm *fpstate;
int error;
if (!cpu_fxsr)
return (EINVAL);
fpstate = &td->td_pcb->pcb_save.sv_xmm;
switch (req) {
case PT_GETXMMREGS:
error = copyout(&td->td_pcb->pcb_save.sv_xmm, addr,
sizeof(td->td_pcb->pcb_save.sv_xmm));
error = copyout(fpstate, addr, sizeof(*fpstate));
break;
case PT_SETXMMREGS:
error = copyin(addr, &td->td_pcb->pcb_save.sv_xmm,
sizeof(td->td_pcb->pcb_save.sv_xmm));
error = copyin(addr, fpstate, sizeof(*fpstate));
fpstate->sv_env.en_mxcsr &= cpu_mxcsr_mask;
break;
default:

View File

@ -52,6 +52,7 @@ extern u_int amd_feature2;
extern u_int cpu_fxsr;
extern u_int cpu_high;
extern u_int cpu_id;
extern u_int cpu_mxcsr_mask;
extern u_int cpu_procinfo;
extern u_int cpu_procinfo2;
extern char cpu_vendor[];

View File

@ -93,7 +93,7 @@ struct envxmm {
u_int16_t en_fos; /* floating operand segment selector */
u_int16_t en_pad1; /* padding */
u_int32_t en_mxcsr; /* SSE sontorol/status register */
u_int32_t en_pad2; /* padding */
u_int32_t en_mxcsr_mask; /* valid bits in mxcsr */
};
/* Contents of each SSE extended accumulator */

View File

@ -418,6 +418,15 @@ npx_attach(dev)
stop_emulating();
fpusave(&npx_cleanstate);
start_emulating();
#ifdef CPU_ENABLE_SSE
if (cpu_fxsr) {
if (npx_cleanstate.sv_xmm.sv_env.en_mxcsr_mask)
cpu_mxcsr_mask =
npx_cleanstate.sv_xmm.sv_env.en_mxcsr_mask;
else
cpu_mxcsr_mask = 0xFFBF;
}
#endif
npx_cleanstate_ready = 1;
intr_restore(s);
}