summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2004-06-19 12:28:48 +0000
committerbde <bde@FreeBSD.org>2004-06-19 12:28:48 +0000
commitc2ef21d1d47765bcd116ff99740206a41bdaaf6d (patch)
tree3cc07ca0f3de12b1767fd141a86c22d8a626524d
parent3237babd8b5786ce6ea9b516c89f43c32f8c35b2 (diff)
downloadFreeBSD-src-c2ef21d1d47765bcd116ff99740206a41bdaaf6d.zip
FreeBSD-src-c2ef21d1d47765bcd116ff99740206a41bdaaf6d.tar.gz
Removed foot-shooting setting of CR0_TS in exec_setregs(). It is
unnecessary because cpu_setregs() and/or npxinit() always sets CR0_TS during system initialization, and CR0_TS is set in the next statement (fpstate_drop()) if necessary after system initialization. Setting it unnecessarily was less than a pessimization since it broke the invariant that the npx can be used without an npxdna() trap if fpucurthread is non-null. The broken invariant became harmful when I added an fnclex to npxdrop(). Removed setting of CR0_MP in exec_setregs(). This was similarly unnecessary but was harmless. Updated comments (mainly by removing them). Things are simpler now that we have cpu_setregs() and don't support a math emulator or pretend to support not having either a math emulator or an npx. Removed the ifdef for avoiding setting CR0_NE in the !SMP case in cpu_setregs(). npx_probe() should reverse the setting if it wants to force IRQ13 exception handling for testing.
-rw-r--r--sys/i386/i386/machdep.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index d1eb5c0..9fbc6f9 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -1143,27 +1143,8 @@ exec_setregs(td, entry, stack, ps_strings)
td->td_pcb->pcb_flags &= ~FP_SOFTFP;
/*
- * Arrange to trap the next npx or `fwait' instruction (see npx.c
- * for why fwait must be trapped at least if there is an npx or an
- * emulator). This is mainly to handle the case where npx0 is not
- * configured, since the npx routines normally set up the trap
- * otherwise. It should be done only at boot time, but doing it
- * here allows modifying `npx_exists' for testing the emulator on
- * systems with an npx.
- */
- load_cr0(rcr0() | CR0_MP | CR0_TS);
-
- /* Initialize the npx (if any) for the current process. */
- /*
- * XXX the above load_cr0() also initializes it and is a layering
- * violation if NPX is configured. It drops the npx partially
- * and this would be fatal if we were interrupted now, and decided
- * to force the state to the pcb, and checked the invariant
- * (CR0_TS clear) if and only if PCPU_GET(fpcurthread) != NULL).
- * ALL of this can happen except the check. The check used to
- * happen and be fatal later when we didn't complete the drop
- * before returning to user mode. This should be fixed properly
- * soon.
+ * Drop the FP state if we hold it, so that the process gets a
+ * clean FP state if it uses the FPU again.
*/
fpstate_drop(td);
@@ -1181,10 +1162,11 @@ cpu_setregs(void)
unsigned int cr0;
cr0 = rcr0();
-#ifdef SMP
- cr0 |= CR0_NE; /* Done by npxinit() */
-#endif
- cr0 |= CR0_MP | CR0_TS; /* Done at every execve() too. */
+ /*
+ * CR0_MP, CR0_NE and CR0_TS are also set by npx_probe() for the
+ * BSP. See the comments there about why we set them.
+ */
+ cr0 |= CR0_MP | CR0_NE | CR0_TS;
#ifndef I386_CPU
cr0 |= CR0_WP | CR0_AM;
#endif
OpenPOWER on IntegriCloud