Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Jun 2005 00:57:19 GMT
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 79218 for review
Message-ID:  <200506300057.j5U0vJLn063560@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=79218

Change 79218 by peter@peter_overcee on 2005/06/30 00:56:26

	*blush* un-reverse copyout args

Affected files ...

.. //depot/projects/hammer/sys/kern/sys_process.c#30 edit

Differences ...

==== //depot/projects/hammer/sys/kern/sys_process.c#30 (text+ko) ====

@@ -156,6 +156,7 @@
 }
 
 #ifdef COMPAT_IA32
+/* For 32 bit binaries, we need to expose the 32 bit regs layouts. */
 int
 proc_read_regs32(struct thread *td, struct reg32 *regs32)
 {
@@ -352,10 +353,20 @@
 #endif
 
 #ifdef COMPAT_IA32
+/*
+ * This CPP subterfuge is to try and reduce the number of ifdefs in
+ * the body of the code.
+ *   COPYIN(uap->addr, &r.reg, sizeof r.reg);
+ * becomes either:
+ *   copyin(uap->addr, &r.reg, sizeof r.reg);
+ * or
+ *   copyin(uap->addr, &r.reg32, sizeof r.reg32);
+ * .. except this is done at runtime.
+ */
 #define	COPYIN(u, k, s)		wrap32 ? \
-	copyin(u, k ## 32, s ##32) : copyin(u, k, s)
+	copyin(u, k ## 32, s ## 32) : copyin(u, k, s)
 #define	COPYOUT(k, u, s)	wrap32 ? \
-	copyout(k ## 32, u, s ##32) : copyout(u, k, s)
+	copyout(k ## 32, u, s ## 32) : copyout(k, u, s)
 #else
 #define	COPYIN(u, k, s)		copyin(u, k, s)
 #define	COPYOUT(k, u, s)	copyout(k, u, s)
@@ -445,10 +456,23 @@
 #undef COPYOUT
 
 #ifdef COMPAT_IA32
+/*
+ * This CPP subterfuge is to try and reduce the number of ifdefs in
+ * the body of the code.
+ *   PROC_READ(regs, td2, addr);
+ * becomes either:
+ *   proc_read_regs(td2, addr);
+ * or
+ *   proc_read_regs32(td2, addr);
+ * .. except this is done at runtime.  There is an additional
+ * complication in that PROC_WRITE disallows 32 bit consumers
+ * from writing to 64 bit address space targets.
+ */
 #define	PROC_READ(w, t, a)	wrap32 ? \
-	 proc_read_ ## w ## 32(t, a) : proc_read_ ## w (t, a)
+	proc_read_ ## w ## 32(t, a) : proc_read_ ## w (t, a)
 #define	PROC_WRITE(w, t, a)	wrap32 ? \
-	(safe ? proc_write_ ## w ## 32(t, a) : EINVAL ) : proc_write_ ## w (t, a)
+	(safe ? proc_write_ ## w ## 32(t, a) : EINVAL ) : \
+	proc_write_ ## w (t, a)
 #else
 #define	PROC_READ(w, t, a)	proc_read_ ## w (t, a)
 #define	PROC_WRITE(w, t, a)	proc_write_ ## w (t, a)
@@ -547,6 +571,10 @@
 	}
 
 #ifdef COMPAT_IA32
+	/*
+	 * Test if we're a 32 bit client and what the target is.
+	 * Set the wrap controls accordingly.
+	 */
 	if (td->td_proc->p_sysent == &ia32_freebsd_sysvec) {
 		if (td2->td_proc->p_sysent == &ia32_freebsd_sysvec)
 			safe = 1;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200506300057.j5U0vJLn063560>