From 5a5232ebb88f2a3813d3f747f39a10c6652ae927 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 29 May 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-05-29 --- port/proc.c | 7 ++++++- port/sysproc.c | 12 ++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/port/proc.c b/port/proc.c index f48ba79badcb4795f7bd7430bdb6b60471450250..032ed66b5b34a9c909dbc2a323a7bcda11e738f3 100644 --- a/port/proc.c +++ b/port/proc.c @@ -606,7 +606,7 @@ kproc(char *name, void (*func)(void *), void *arg) /* * Save time: only copy u-> data and useful stack */ - clearmmucache(); + clearmmucache(); /* so child doesn't inherit any of your mappings */ memmove(up, u, sizeof(User)); n = USERADDR+BY2PG - (ulong)&lastvar; n = (n+32) & ~(BY2WD-1); /* be safe & word align */ @@ -645,5 +645,10 @@ kproc(char *name, void (*func)(void *), void *arg) memset(p->time, 0, sizeof(p->time)); p->time[TReal] = MACHP(0)->ticks; ready(p); + /* + * since the bss/data segments are now shareable, + * any mmu info about this process is now stale + * and has to be discarded. + */ flushmmu(); } diff --git a/port/sysproc.c b/port/sysproc.c index 0a2535c2b21a81f7acb97c68db108a0aab146fb1..7921d4592e0fc9d33dd8414b4ee539c194838eac 100644 --- a/port/sysproc.c +++ b/port/sysproc.c @@ -41,7 +41,7 @@ sysfork(ulong *arg) /* * Save time: only copy u-> data and useful stack */ - clearmmucache(); + clearmmucache(); /* so child doesn't inherit any of your mappings */ memmove((void*)upa, u, sizeof(User)); n = USERADDR+BY2PG - (ulong)&lastvar; n = (n+32) & ~(BY2WD-1); /* be safe & word align */ @@ -115,7 +115,6 @@ sysfork(ulong *arg) * Sched */ if(setlabel(&p->sched)){ - clearmmucache(); u->p = p; p->state = Running; p->mach = m; @@ -134,6 +133,11 @@ sysfork(ulong *arg) memset(p->time, 0, sizeof(p->time)); p->time[TReal] = MACHP(0)->ticks; memmove(p->text, u->p->text, NAMELEN); + /* + * since the bss/data segments are now shareable, + * any mmu info about this process is now stale + * (i.e. has bad properties) and has to be discarded. + */ flushmmu(); clearmmucache(); ready(p); @@ -351,6 +355,10 @@ sysexec(ulong *arg) o->pte[i].page->va += (USTKTOP-TSTKTOP); unlock(o); + /* + * at this point, the mmu contains info about the old address + * space and needs to be flushed + */ flushmmu(); clearmmucache(); execpc(exec.entry);