This diff
* copies the stackgap_init() and stackgap_alloc() functions from
  compat/common/compat_util.c to dev/systrace.c, the one place they
  are used,
* removes the remaining kernel references to compat/*.

Once the zboot and systrace diffs are in, this will allow all of
compat/common/* and compat/linux/* to be removed.


Index: sys/conf/files
===================================================================
RCS file: /cvs/src/sys/conf/files,v
retrieving revision 1.612
diff -u -p -r1.612 files
--- sys/conf/files      28 Feb 2016 15:46:18 -0000      1.612
+++ sys/conf/files      28 Feb 2016 21:44:56 -0000
@@ -974,9 +974,6 @@ file net/pfkeyv2.c                  key | ipsec | tcp_s
 file net/pfkeyv2_parsemessage.c                key | ipsec | tcp_signature
 file net/pfkeyv2_convert.c             key | ipsec | tcp_signature
 
-# COMPAT_* support code (base and other shared code)
-file compat/common/compat_util.c       !small_kernel
-
 # libx86emu
 file dev/x86emu/x86emu.c               x86emu
 file dev/x86emu/x86emu_util.c          x86emu
Index: sys/dev/systrace.c
===================================================================
RCS file: /cvs/src/sys/dev/systrace.c,v
retrieving revision 1.77
diff -u -p -r1.77 systrace.c
--- sys/dev/systrace.c  8 Sep 2015 11:58:58 -0000       1.77
+++ sys/dev/systrace.c  28 Feb 2016 21:59:47 -0000
@@ -48,7 +48,8 @@
 #include <sys/poll.h>
 #include <sys/ptrace.h>
 
-#include <compat/common/compat_util.h>
+#include <sys/exec.h>
+#include <uvm/uvm_extern.h>
 
 #include <dev/systrace.h>
 
@@ -1810,4 +1811,34 @@ systrace_msg_policyfree(struct fsystrace
        systrace_wakeup(fst);
 
        return (0);
+}
+
+caddr_t  
+stackgap_init(struct proc *p)
+{
+       struct process *pr = p->p_p;
+
+       if (pr->ps_stackgap == 0) {
+               if (uvm_map(&pr->ps_vmspace->vm_map, &pr->ps_stackgap,
+                   round_page(STACKGAPLEN), NULL, 0, 0,
+                   UVM_MAPFLAG(PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE,
+                   MAP_INHERIT_COPY, MADV_RANDOM, UVM_FLAG_COPYONW)))
+                       sigexit(p, SIGILL);
+       }
+
+        return (caddr_t)pr->ps_stackgap;
+}
+
+void *          
+stackgap_alloc(caddr_t *sgp, size_t sz)
+{
+       void *n = (void *) *sgp;
+       caddr_t nsgp;
+
+       sz = ALIGN(sz);
+       nsgp = *sgp + sz;
+       if (nsgp > (caddr_t)trunc_page((vaddr_t)n) + STACKGAPLEN)
+               return NULL;
+       *sgp = nsgp;
+       return n;
 }
Index: sys/dev/systrace.h
===================================================================
RCS file: /cvs/src/sys/dev/systrace.h,v
retrieving revision 1.25
diff -u -p -r1.25 systrace.h
--- sys/dev/systrace.h  20 Jan 2015 01:48:13 -0000      1.25
+++ sys/dev/systrace.h  28 Feb 2016 21:43:04 -0000
@@ -236,5 +236,8 @@ void systrace_execve0(struct proc *);
 void systrace_execve1(char *, struct proc *);
 int systrace_scriptname(struct proc *, char *);
 
+caddr_t stackgap_init(struct proc *);
+void *stackgap_alloc(caddr_t *, size_t);
+
 #endif /* _KERNEL */
 #endif /* _SYSTRACE_H_ */
Index: sys/kern/Makefile
===================================================================
RCS file: /cvs/src/sys/kern/Makefile,v
retrieving revision 1.41
diff -u -p -r1.41 Makefile
--- sys/kern/Makefile   1 Dec 2015 15:32:29 -0000       1.41
+++ sys/kern/Makefile   28 Feb 2016 21:45:53 -0000
@@ -28,9 +28,7 @@ SYSTAGS=/var/db/sys_tags
 SYSDIR=/sys
 
 # Directories in which to place tags links (other than machine-dependent)
-DGEN=  compat compat/common \
-       compat/linux \
-       conf \
+DGEN=  conf \
        ddb \
        dev dev/eisa dev/ic dev/isa dev/pci dev/pcmcia dev/cardbus \
        dev/sun dev/tc \
-- 
Christian "naddy" Weisgerber                          [email protected]

Reply via email to