BSD 4_3_Reno release
[unix-history] / usr / src / sys / vax / vm_machdep.c
index 882311d..e27cd85 100644 (file)
@@ -1,18 +1,21 @@
-/*     vm_machdep.c    6.1     83/07/29        */
-
-#include "../machine/pte.h"
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)vm_machdep.c        7.9 (Berkeley) 6/21/90
+ */
 
 
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/proc.h"
-#include "../h/cmap.h"
-#include "../h/mount.h"
-#include "../h/vm.h"
-#include "../h/text.h"
+#include "param.h"
+#include "systm.h"
+#include "user.h"
+#include "proc.h"
+#include "cmap.h"
+#include "vm.h"
+#include "text.h"
 
 
-#include "../vax/mtpr.h"
+#include "pte.h"
+#include "mtpr.h"
 
 /*
  * Set a red zone in the kernel stack after the u. area.
 
 /*
  * Set a red zone in the kernel stack after the u. area.
@@ -29,71 +32,22 @@ setredzone(pte, vaddr)
                mtpr(TBIS, vaddr + sizeof (struct user));
 }
 
                mtpr(TBIS, vaddr + sizeof (struct user));
 }
 
-#ifndef mapin
-mapin(pte, v, pfnum, count, prot)
-       struct pte *pte;
-       u_int v, pfnum;
-       int count, prot;
-{
-
-       while (count > 0) {
-               *(int *)pte++ = pfnum | prot;
-               mtpr(TBIS, ptob(v));
-               v++;
-               pfnum++;
-               count--;
-       }
-}
-#endif
-
-#ifdef notdef
-/*ARGSUSED*/
-mapout(pte, size)
-       register struct pte *pte;
-       int size;
-{
-
-       panic("mapout");
-}
-#endif
-
 /*
  * Check for valid program size
 /*
  * Check for valid program size
+ * NB - Check data and data growth separately as they may overflow 
+ * when summed together.
  */
  */
-chksize(ts, ds, ss)
-       register unsigned ts, ds, ss;
+chksize(ts, ids, uds, ss)
+       unsigned ts, ids, uds, ss;
 {
 {
-       static int maxdmap = 0;
-
-       if (ts > MAXTSIZ || ds > MAXDSIZ || ss > MAXSSIZ) {
-               u.u_error = ENOMEM;
-               return (1);
-       }
-       /* check for swap map overflow */
-       if (maxdmap == 0) {
-               register int i, blk;
-
-               blk = dmmin;
-               for (i = 0; i < NDMAP; i++) {
-                       maxdmap += blk;
-                       if (blk < dmmax)
-                               blk *= 2;
-               }
-       }
-       if (ctod(ts) > NXDAD * dmtext ||
-           ctod(ds) > maxdmap || ctod(ss) > maxdmap) {
-               u.u_error = ENOMEM;
-               return (1);
-       }
-       /*
-        * Make sure the process isn't bigger than our
-        * virtual memory limit.
-        *
-        * THERE SHOULD BE A CONSTANT FOR THIS.
-        */
-       if (ts + ds + ss + LOWPAGES + HIGHPAGES > btoc(USRSTACK)) {
-               u.u_error = ENOMEM;
-               return (1);
+       extern unsigned maxtsize;
+
+       if (ctob(ts) > maxtsize ||
+           ctob(ids) > u.u_rlimit[RLIMIT_DATA].rlim_cur ||
+           ctob(uds) > u.u_rlimit[RLIMIT_DATA].rlim_cur ||
+           ctob(ids + uds) > u.u_rlimit[RLIMIT_DATA].rlim_cur ||
+           ctob(ss) > u.u_rlimit[RLIMIT_STACK].rlim_cur) {
+               return (ENOMEM);
        }
        return (0);
 }
        }
        return (0);
 }
@@ -135,23 +89,20 @@ chgprot(addr, tprot)
        register struct cmap *c;
 
        v = clbase(btop(addr));
        register struct cmap *c;
 
        v = clbase(btop(addr));
-       if (!isatsv(u.u_procp, v)) {
-               u.u_error = EFAULT;
-               return (0);
-       }
+       if (!isatsv(u.u_procp, v))
+               return (EFAULT);
        tp = vtotp(u.u_procp, v);
        pte = tptopte(u.u_procp, tp);
        if (pte->pg_fod == 0 && pte->pg_pfnum) {
                c = &cmap[pgtocm(pte->pg_pfnum)];
        tp = vtotp(u.u_procp, v);
        pte = tptopte(u.u_procp, tp);
        if (pte->pg_fod == 0 && pte->pg_pfnum) {
                c = &cmap[pgtocm(pte->pg_pfnum)];
-               if (c->c_blkno && c->c_mdev != MSWAPX)
-                       munhash(mount[c->c_mdev].m_dev,
-                           (daddr_t)(u_long)c->c_blkno);
+               if (c->c_blkno)
+                       munhash(c->c_vp, (daddr_t)(u_long)c->c_blkno);
        }
        *(int *)pte &= ~PG_PROT;
        *(int *)pte |= tprot;
        distcl(pte);
        tbiscl(v);
        }
        *(int *)pte &= ~PG_PROT;
        *(int *)pte |= tprot;
        distcl(pte);
        tbiscl(v);
-       return (1);
+       return (0);
 }
 
 settprot(tprot)
 }
 
 settprot(tprot)
@@ -212,8 +163,8 @@ pagemove(from, to, size)
 
        if (size % CLBYTES)
                panic("pagemove");
 
        if (size % CLBYTES)
                panic("pagemove");
-       fpte = &Sysmap[btop(from - 0x80000000)];
-       tpte = &Sysmap[btop(to - 0x80000000)];
+       fpte = kvtopte(from);
+       tpte = kvtopte(to);
        while (size > 0) {
                *tpte++ = *fpte;
                *(int *)fpte++ = 0;
        while (size > 0) {
                *tpte++ = *fpte;
                *(int *)fpte++ = 0;