three kernel patches for review

Chris Pressey cpressey at catseye.mine.nu
Tue Apr 19 18:35:34 PDT 2005


Hi all,

For review by interested parties, attached:

1. kern-ansi.diff:
   ANSIfy a bunch of function definitions in sys/kern/kern_*.c files.
   (not contentious, although might cause minor conflicts for other
    developers holding local modified versions of those files)

2. bpf-comments.diff:
   Update some comments for bpf_validate() to make them reflect
   reality.  It doesn't check to make sure that jumps go forward;
   jumps are unsigned, and thus always go forward.  Also fix a
   typo in the man page.

3. vm-badram.diff:
   Port jhb's commit to FreeBSD CURRENT, sys/vm/vm_pageq.c rev 1.15,
   which allows a list of known-bad memory locations to be specified,
   which the VM subsystem will not attempt to map.  (I also added an
   ASSERT_IN_CRIT_SECTION to the function along the way, since the
   comments note that it should only be called in a critical section.)
   This is mainly for discussion - would people find this useful?
   Is there a better way we can accomplish the same thing?  Are there
   any additional improvement that can be made to it (e.g. allow listing
   a range of addresses?)

-Chris

Index: sys/kern/kern_acct.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/kern_acct.c,v
retrieving revision 1.17
diff -u -r1.17 kern_acct.c
--- sys/kern/kern_acct.c	29 Mar 2005 00:35:55 -0000	1.17
+++ sys/kern/kern_acct.c	17 Apr 2005 05:52:59 -0000
@@ -115,12 +115,13 @@
 /*
  * Accounting system call.  Written based on the specification and
  * previous implementation done by Mark Tinguely.
+ *
+ * int acct(struct acct_args {
+ *		syscallarg(char *) path;
+ *	    } *uap);
  */
 int
-acct(uap)
-	struct acct_args /* {
-		syscallarg(char *) path;
-	} */ *uap;
+acct(struct acct_args *uap)
 {
 	struct thread *td = curthread;
 	struct nlookupdata nd;
@@ -279,8 +280,7 @@
 #define	MAXFRACT	((1 << MANTSIZE) - 1)	/* Maximum fractional value. */
 
 static comp_t
-encode_comp_t(s, us)
-	u_long s, us;
+encode_comp_t(u_long s, u_long us)
 {
 	int exp, rnd;
 
@@ -315,8 +315,7 @@
  */
 /* ARGSUSED */
 static void
-acctwatch(a)
-	void *a;
+acctwatch(void *a)
 {
 	struct statfs sb;
 
Index: sys/kern/kern_exec.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/kern_exec.c,v
retrieving revision 1.31
diff -u -r1.31 kern_exec.c
--- sys/kern/kern_exec.c	2 Mar 2005 18:42:08 -0000	1.31
+++ sys/kern/kern_exec.c	17 Apr 2005 05:52:59 -0000
@@ -575,8 +575,7 @@
 }
 
 void
-exec_unmap_first_page(imgp)
-	struct image_params *imgp;
+exec_unmap_first_page(struct image_params *imgp)
 {
 	vm_page_t m;
 
@@ -873,8 +872,7 @@
  *	Return 0 for success or error code on failure.
  */
 int
-exec_check_permissions(imgp)
-	struct image_params *imgp;
+exec_check_permissions(struct image_params *imgp)
 {
 	struct proc *p = imgp->proc;
 	struct vnode *vp = imgp->vp;
@@ -936,8 +934,7 @@
  * Exec handler registration
  */
 int
-exec_register(execsw_arg)
-	const struct execsw *execsw_arg;
+exec_register(const struct execsw *execsw_arg)
 {
 	const struct execsw **es, **xs, **newexecsw;
 	int count = 2;	/* New slot and trailing NULL */
@@ -961,8 +958,7 @@
 }
 
 int
-exec_unregister(execsw_arg)
-	const struct execsw *execsw_arg;
+exec_unregister(const struct execsw *execsw_arg)
 {
 	const struct execsw **es, **xs, **newexecsw;
 	int count = 1;
Index: sys/kern/kern_exit.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/kern_exit.c,v
retrieving revision 1.39
diff -u -r1.39 kern_exit.c
--- sys/kern/kern_exit.c	12 Oct 2004 19:20:46 -0000	1.39
+++ sys/kern/kern_exit.c	17 Apr 2005 05:52:59 -0000
@@ -586,9 +586,7 @@
  * make process 'parent' the new parent of process 'child'.
  */
 void
-proc_reparent(child, parent)
-	struct proc *child;
-	struct proc *parent;
+proc_reparent(struct proc *child, struct proc *parent)
 {
 
 	if (child->p_pptr == parent)
@@ -610,8 +608,7 @@
  */
 
 int
-at_exit(function)
-	exitlist_fn function;
+at_exit(exitlist_fn function)
 {
 	struct exitlist *ep;
 
@@ -634,8 +631,7 @@
  * Returns the number of items removed (0 or 1)
  */
 int
-rm_at_exit(function)
-	exitlist_fn function;
+rm_at_exit(exitlist_fn function)
 {
 	struct exitlist *ep;
 
@@ -649,7 +645,8 @@
 	return (0);
 }
 
-void check_sigacts (void)
+void
+check_sigacts(void)
 {
 	struct proc *p = curproc;
 	struct sigacts *pss;
Index: sys/kern/kern_kthread.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/kern_kthread.c,v
retrieving revision 1.10
diff -u -r1.10 kern_kthread.c
--- sys/kern/kern_kthread.c	29 Jul 2004 09:02:33 -0000	1.10
+++ sys/kern/kern_kthread.c	17 Apr 2005 05:52:59 -0000
@@ -125,8 +125,7 @@
  * to be called from SYSINIT().
  */
 void
-kproc_start(udata)
-	const void *udata;
+kproc_start(const void *udata)
 {
 	const struct kproc_desc	*kp = udata;
 	int error;
Index: sys/kern/kern_ntptime.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/kern_ntptime.c,v
retrieving revision 1.9
diff -u -r1.9 kern_ntptime.c
--- sys/kern/kern_ntptime.c	30 Jan 2004 06:20:08 -0000	1.9
+++ sys/kern/kern_ntptime.c	17 Apr 2005 05:52:59 -0000
@@ -544,7 +544,7 @@
  * probably be integrated with the code that does that.
  */
 static void
-ntp_init()
+ntp_init(void)
 {
 
 	/*
@@ -594,8 +594,7 @@
  * is selected by the STA_MODE status bit.
  */
 static void
-hardupdate(offset)
-	long offset;		/* clock offset (ns) */
+hardupdate(long offset)
 {
 	long mtemp;
 	l_fp ftemp;
@@ -677,9 +676,7 @@
  * are determined by this routine and updated atomically.
  */
 void
-hardpps(tsp, nsec)
-	struct timespec *tsp;	/* time at PPS */
-	long nsec;		/* hardware counter at PPS */
+hardpps(struct timespec *tsp, long nsec)
 {
 	long u_sec, u_nsec, v_nsec; /* temps */
 	l_fp ftemp;
Index: sys/kern/kern_proc.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/kern_proc.c,v
retrieving revision 1.18
diff -u -r1.18 kern_proc.c
--- sys/kern/kern_proc.c	1 Feb 2005 02:25:45 -0000	1.18
+++ sys/kern/kern_proc.c	17 Apr 2005 05:52:59 -0000
@@ -85,7 +85,7 @@
  * Initialize global process hashing structures.
  */
 void
-procinit()
+procinit(void)
 {
 
 	LIST_INIT(&allproc);
@@ -101,8 +101,7 @@
  * Is p an inferior of the current process?
  */
 int
-inferior(p)
-	struct proc *p;
+inferior(struct proc *p)
 {
 
 	for (; p != curproc; p = p->p_pptr)
@@ -115,8 +114,7 @@
  * Locate a process by number
  */
 struct proc *
-pfind(pid)
-	pid_t pid;
+pfind(pid_t pid)
 {
 	struct proc *p;
 
@@ -130,8 +128,7 @@
  * Locate a process group by number
  */
 struct pgrp *
-pgfind(pgid)
-	pid_t pgid;
+pgfind(pid_t pgid)
 {
 	struct pgrp *pgrp;
 
@@ -145,10 +142,7 @@
  * Move p to a new or existing process group (and session)
  */
 int
-enterpgrp(p, pgid, mksess)
-	struct proc *p;
-	pid_t pgid;
-	int mksess;
+enterpgrp(struct proc *p, pid_t pgid, int mksess)
 {
 	struct pgrp *pgrp = pgfind(pgid);
 
@@ -220,8 +214,7 @@
  * remove process from process group
  */
 int
-leavepgrp(p)
-	struct proc *p;
+leavepgrp(struct proc *p)
 {
 
 	LIST_REMOVE(p, p_pglist);
@@ -235,8 +228,7 @@
  * delete a process group
  */
 static void
-pgdelete(pgrp)
-	struct pgrp *pgrp;
+pgdelete(struct pgrp *pgrp)
 {
 
 	/*
@@ -295,10 +287,7 @@
  * entering == 1 => p is entering specified group.
  */
 void
-fixjobc(p, pgrp, entering)
-	struct proc *p;
-	struct pgrp *pgrp;
-	int entering;
+fixjobc(struct proc *p, struct pgrp *pgrp, int entering)
 {
 	struct pgrp *hispgrp;
 	struct session *mysession = pgrp->pg_session;
@@ -337,8 +326,7 @@
  * hang-up all process in that group.
  */
 static void
-orphanpg(pg)
-	struct pgrp *pg;
+orphanpg(struct pgrp *pg)
 {
 	struct proc *p;
 
Index: sys/kern/kern_prot.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/kern_prot.c,v
retrieving revision 1.20
diff -u -r1.20 kern_prot.c
--- sys/kern/kern_prot.c	31 Jan 2005 22:29:59 -0000	1.20
+++ sys/kern/kern_prot.c	17 Apr 2005 05:52:59 -0000
@@ -871,7 +871,7 @@
  * Allocate a zeroed cred structure.
  */
 struct ucred *
-crget()
+crget(void)
 {
 	struct ucred *cr;
 
@@ -992,8 +992,7 @@
  * Dup cred struct to a new held one.
  */
 struct ucred *
-crdup(cr)
-	struct ucred *cr;
+crdup(struct ucred *cr)
 {
 	struct ucred *newcr;
 
@@ -1013,9 +1012,7 @@
  * Fill in a struct xucred based on a struct ucred.
  */
 void
-cru2x(cr, xcr)
-	struct ucred *cr;
-	struct xucred *xcr;
+cru2x(struct ucred *cr, struct xucred *xcr)
 {
 
 	bzero(xcr, sizeof(*xcr));
@@ -1065,7 +1062,7 @@
 }
 
 void
-setsugid()
+setsugid(void)
 {
 	struct proc *p = curproc;
 



Index: sys/net/bpf_filter.c
===================================================================
RCS file: /home/dcvs/src/sys/net/bpf_filter.c,v
retrieving revision 1.6
diff -u -r1.6 bpf_filter.c
--- sys/net/bpf_filter.c	21 Dec 2004 02:54:14 -0000	1.6
+++ sys/net/bpf_filter.c	17 Apr 2005 05:52:59 -0000
@@ -498,8 +498,8 @@
 #ifdef _KERNEL
 /*
  * Return true if the 'fcode' is a valid filter program.
- * The constraints are that each jump be forward and to a valid
- * code.  The code must terminate with either an accept or reject.
+ * The constraints are that jump and memory accesses are within valid
+ * ranges, and that the code terminates with either an accept or reject.
  *
  * The kernel needs to be able to verify an application's filter code.
  * Otherwise, a bogus program could easily crash the system.
@@ -512,8 +512,7 @@
 
 	for (i = 0; i < len; ++i) {
 		/*
-		 * Check that that jumps are forward, and within
-		 * the code block.
+		 * Check that that jumps are within the code block.
 		 */
 		p = &f[i];
 		if (BPF_CLASS(p->code) == BPF_JMP) {
Index: share/man/man4/bpf.4
===================================================================
RCS file: /home/dcvs/src/share/man/man4/bpf.4,v
retrieving revision 1.2
diff -u -r1.2 bpf.4
--- share/man/man4/bpf.4	17 Jun 2003 04:36:58 -0000	1.2
+++ share/man/man4/bpf.4	17 Apr 2005 05:52:59 -0000
@@ -174,7 +174,7 @@
 All other fields are undefined.
 .It Dv BIOCSETIF
 .Pq Li "struct ifreq"
-Sets the hardware interface associate with the file.  This
+Sets the hardware interface associated with the file.  This
 command must be performed before any packets can be read.
 The device is indicated by name using the
 .Li ifr_name



Index: sys/vm/vm_page.c
===================================================================
RCS file: /home/dcvs/src/sys/vm/vm_page.c,v
retrieving revision 1.28
diff -u -r1.28 vm_page.c
--- sys/vm/vm_page.c	10 Dec 2004 23:07:10 -0000	1.28
+++ sys/vm/vm_page.c	17 Apr 2005 20:17:43 -0000
@@ -161,6 +161,38 @@
 {
 	struct vpgqueues *vpq;
 	vm_page_t m;
+	vm_paddr_t bad;
+	char *cp, *list, *pos;
+
+	ASSERT_IN_CRIT_SECTION();
+
+	/*
+	 * See if a physical address in this page has been listed
+	 * in the blacklist tunable.  Entries in the tunable are
+	 * separated by spaces or commas.  If an invalid integer is
+	 * encountered then the rest of the string is skipped.
+	 */
+	if (testenv("vm.blacklist")) {
+		list = getenv("vm.blacklist");
+		for (pos = list; *pos != '\0'; pos = cp) {
+			bad = strtoq(pos, &cp, 0);
+			if (*cp != '\0') {
+				if (*cp == ' ' || *cp == ',') {
+					cp++;
+					if (cp == pos)
+						continue;
+				} else
+					break;
+			}
+			if (pa == trunc_page(bad)) {
+				printf("Skipping page with pa 0x%jx\n",
+				    (uintmax_t)pa);
+				freeenv(list);
+				return (NULL);
+			}
+		}
+		freeenv(list);
+	}
 
 	++vmstats.v_page_count;
 	++vmstats.v_free_count;







More information about the Submit mailing list