From de22416ef671aff08087e176a856c05382f08b94 Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Sun, 27 Jul 2003 23:45:48 +0000 Subject: [PATCH] Reset the per-CPU unique value at boot and clear it in the PCB of the child when forking. This provides a consistent initial state. Note that cpu_set_upcall() does not clear the per-CPU unique value as it is followed by a call to set_mcontext(), which sets it accordingly. --- sys/alpha/alpha/machdep.c | 8 +++++--- sys/alpha/alpha/mp_machdep.c | 3 +++ sys/alpha/alpha/vm_machdep.c | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c index ba40437d29f..64148f98478 100644 --- a/sys/alpha/alpha/machdep.c +++ b/sys/alpha/alpha/machdep.c @@ -548,6 +548,9 @@ alpha_init(pfn, ptb, bim, bip, biv) alpha_pal_wrmces(alpha_pal_rdmces() & ~(ALPHA_MCES_DSC|ALPHA_MCES_DPC)); + /* Clear userland thread pointer */ + alpha_pal_wrunique(0); + /* * Find out what hardware we're on, and do basic initialization. */ @@ -2028,7 +2031,7 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret) mcp->mc_regs[FRAME_SP] = alpha_pal_rdusp(); mcp->mc_thrptr = alpha_pal_rdunique(); } else - mcp->mc_thrptr = td->td_pcb->pcb_hw.apcb_unique; + mcp->mc_thrptr = 0; mcp->mc_format = _MC_REV0_TRAPFRAME; PROC_LOCK(curthread->td_proc); @@ -2069,8 +2072,7 @@ set_mcontext(struct thread *td, const mcontext_t *mcp) if (td == curthread) { alpha_pal_wrusp(mcp->mc_regs[FRAME_SP]); alpha_pal_wrunique(mcp->mc_thrptr); - } else - td->td_pcb->pcb_hw.apcb_unique = mcp->mc_thrptr; + } /* * The context is a trapframe, so just copy it over the diff --git a/sys/alpha/alpha/mp_machdep.c b/sys/alpha/alpha/mp_machdep.c index 609fa85d3cd..f37d0f143af 100644 --- a/sys/alpha/alpha/mp_machdep.c +++ b/sys/alpha/alpha/mp_machdep.c @@ -137,6 +137,9 @@ smp_init_secondary(void) */ alpha_pal_wrval((u_int64_t) pcpup); + /* Clear userland thread pointer. */ + alpha_pal_wrunique(0); + /* * Point interrupt/exception vectors to our own. */ diff --git a/sys/alpha/alpha/vm_machdep.c b/sys/alpha/alpha/vm_machdep.c index 3df13886e89..b0ed1461912 100644 --- a/sys/alpha/alpha/vm_machdep.c +++ b/sys/alpha/alpha/vm_machdep.c @@ -145,6 +145,7 @@ cpu_fork(td1, p2, td2, flags) */ bcopy(td1->td_pcb, td2->td_pcb, sizeof(struct pcb)); td2->td_pcb->pcb_hw.apcb_usp = alpha_pal_rdusp(); + td2->td_pcb->pcb_hw.apcb_unique = 0; td2->td_pcb->pcb_hw.apcb_flags &= ~ALPHA_PCB_FLAGS_FEN; /* -- 2.45.2