fix a bug where after a "swapin" the user area has a different
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 5 Jan 1994 09:31:42 +0000 (01:31 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 5 Jan 1994 09:31:42 +0000 (01:31 -0800)
virtual to physical mapping (see comments in code). (from Ralph)

SCCS-vsn: sys/pmax/pmax/vm_machdep.c 8.3

usr/src/sys/pmax/pmax/vm_machdep.c

index 06776a3..0c09ad8 100644 (file)
@@ -11,7 +11,7 @@
  *
  * from: Utah $Hdr: vm_machdep.c 1.21 91/04/06$
  *
  *
  * from: Utah $Hdr: vm_machdep.c 1.21 91/04/06$
  *
- *     @(#)vm_machdep.c        8.2 (Berkeley) %G%
+ *     @(#)vm_machdep.c        8.3 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -49,10 +49,10 @@ cpu_fork(p1, p2)
        p2->p_md.md_flags = p1->p_md.md_flags & (MDP_FPUSED | MDP_ULTRIX);
 
        /*
        p2->p_md.md_flags = p1->p_md.md_flags & (MDP_FPUSED | MDP_ULTRIX);
 
        /*
-        * Convert the user struct virtual address to a physical one
-        * and cache it in the proc struct. Note: if the phyical address
-        * can change (due to memory compaction in kmem_alloc?),
-        * we will have to update things.
+        * Cache the PTEs for the user area in the machine dependent
+        * part of the proc struct so cpu_switch() can quickly map in
+        * the user struct and kernel stack. Note: if the virtual address
+        * translation changes (e.g. swapout) we have to update this.
         */
        pte = kvtopte(up);
        for (i = 0; i < UPAGES; i++) {
         */
        pte = kvtopte(up);
        for (i = 0; i < UPAGES; i++) {
@@ -93,6 +93,31 @@ cpu_fork(p1, p2)
        return (0);
 }
 
        return (0);
 }
 
+/*
+ * Finish a swapin operation.
+ * We neded to update the cached PTEs for the user area in the
+ * machine dependent part of the proc structure.
+ */
+void
+cpu_swapin(p)
+       register struct proc *p;
+{
+       register struct user *up = p->p_addr;
+       register pt_entry_t *pte;
+       register int i;
+
+       /*
+        * Cache the PTEs for the user area in the machine dependent
+        * part of the proc struct so cpu_switch() can quickly map in
+        * the user struct and kernel stack.
+        */
+       pte = kvtopte(up);
+       for (i = 0; i < UPAGES; i++) {
+               p->p_md.md_upte[i] = pte->pt_entry & ~PG_G;
+               pte++;
+       }
+}
+
 /*
  * cpu_exit is called as the last action during exit.
  * We release the address space and machine-dependent resources,
 /*
  * cpu_exit is called as the last action during exit.
  * We release the address space and machine-dependent resources,