Skip to content

Commit

Permalink
FPU: Keep SSE state in backends even if it doesn't change.
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoldeman committed Jan 27, 2023
1 parent f587481 commit 99071c3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
10 changes: 4 additions & 6 deletions src/base/emu-i386/do_vm86.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,17 +487,15 @@ static int true_vm86(union vm86_union *x)

void true_vm86_set_fpu_state(const emu_fpstate *fpstate)
{
if (config.cpufxsr)
true_vm86_fxsave = *fpstate;
else
true_vm86_fxsave = *fpstate;
if (!config.cpufxsr)
fxsave_to_fsave(fpstate, &true_vm86_fsave);
}

void true_vm86_get_fpu_state(emu_fpstate *fpstate)
{
if (config.cpufxsr)
*fpstate = true_vm86_fxsave;
else
*fpstate = true_vm86_fxsave;
if (!config.cpufxsr)
fsave_to_fxsave(&true_vm86_fsave, fpstate);
}
#endif
Expand Down
7 changes: 3 additions & 4 deletions src/base/emu-i386/simx86/cpu-emu.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,24 +583,23 @@ void Cpu2Reg (void)

void e_set_fpu_state(const emu_fpstate *fpstate)
{
TheCPU._fpstate = *fpstate;
if (CONFIG_CPUSIM)
fp87_load_fpstate(fpstate);
else {
// unmasked exception settings are emulated
TheCPU.fpuc = fpstate->cwd;
TheCPU._fpstate = *fpstate;
TheCPU._fpstate.cwd |= 0x3f;
}
}

void e_get_fpu_state(emu_fpstate *fpstate)
{
*fpstate = TheCPU._fpstate;
if (CONFIG_CPUSIM)
fp87_save_fpstate(fpstate);
else {
*fpstate = TheCPU._fpstate;
else
fpstate->cwd = (fpstate->cwd & ~0x3f) | (TheCPU.fpuc & 0x3f);
}
}

/* ======================================================================= */
Expand Down
14 changes: 9 additions & 5 deletions src/dosext/dpmi/dnative/dnative.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ static void convert_from_fxsr(fpregset_t fptr,
"size mismatch");
fxsave_to_fsave(fxsave, (struct emu_fsave *)fptr);
}

/* since the kernel may not be able to keep SSE state, keep it here */
static struct emu_fpxstate fxsave_state_holder_i386;
#endif

static void copy_to_dpmi(sigcontext_t *scp, cpuctx_t *s)
Expand Down Expand Up @@ -119,9 +122,10 @@ void native_dpmi_set_fpu_state(const emu_fpstate *fpstate)
#else
/* i386: convert fxsave state to fsave state */
convert_from_fxsr(scp_fpregs, fpstate);
if ((scp_fpregs->status >> 16) != EMU_X86_FXSR_MAGIC)
return;
fpregs = &scp_fpregs->status + 1;
if ((scp_fpregs->status >> 16) == EMU_X86_FXSR_MAGIC)
fpregs = &scp_fpregs->status + 1;
else
fpregs = &fxsave_state_holder_i386;
#endif
memcpy(fpregs, fpstate, sizeof(*fpstate));
}
Expand Down Expand Up @@ -163,8 +167,8 @@ void native_dpmi_get_fpu_state(emu_fpstate *fpstate)
if ((scp_fpregs->status >> 16) == EMU_X86_FXSR_MAGIC)
fpregs = &scp_fpregs->status + 1;
else {
fsave_to_fxsave(fpregs, &vm86_fpu_state);
return;
fsave_to_fxsave(fpregs, &fxsave_state_holder_i386);
fpregs = &fxsave_state_holder_i386;
}
#endif
memcpy(fpstate, fpregs, sizeof(*fpstate));
Expand Down
2 changes: 1 addition & 1 deletion src/dosext/dpmi/dpmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ static void print_ldt(void)

static void dpmi_set_pm(int pm)
{
static emu_fpstate fpstate;
emu_fpstate fpstate;
assert(pm <= 1);
if (pm == dpmi_pm) {
if (!pm)
Expand Down

0 comments on commit 99071c3

Please sign in to comment.