Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Introduce and use PROC_PTRSZ() to handle differing point...
details: https://anonhg.NetBSD.org/src/rev/448964fa8ee3
branches: trunk
changeset: 348010:448964fa8ee3
user: christos <christos%NetBSD.org@localhost>
date: Thu Sep 29 20:40:53 2016 +0000
description:
Introduce and use PROC_PTRSZ() to handle differing pointer size 64->32
emulation.
diffstat:
sys/kern/core_elf32.c | 20 +++++---------------
sys/kern/kern_proc.c | 11 +++--------
sys/kern/sys_process.c | 6 +++---
sys/sys/proc.h | 4 +++-
4 files changed, 14 insertions(+), 27 deletions(-)
diffs (132 lines):
diff -r d7dce42069b3 -r 448964fa8ee3 sys/kern/core_elf32.c
--- a/sys/kern/core_elf32.c Thu Sep 29 20:40:49 2016 +0000
+++ b/sys/kern/core_elf32.c Thu Sep 29 20:40:53 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: core_elf32.c,v 1.48 2016/09/05 17:42:57 dholland Exp $ */
+/* $NetBSD: core_elf32.c,v 1.49 2016/09/29 20:40:53 christos Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.48 2016/09/05 17:42:57 dholland Exp $");
+__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.49 2016/09/29 20:40:53 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_coredump.h"
@@ -407,7 +407,6 @@
int error;
struct proc *p = l->l_proc;
void *uauxv, *kauxv;
- size_t len;
if ((error = copyin_psstrings(p, &pss)) != 0)
return error;
@@ -415,18 +414,9 @@
if (pss.ps_envstr == NULL)
return EIO;
- len = p->p_execsw->es_arglen;
-#ifdef COMPAT_NETBSD32
- if (p->p_flag & PK_32) {
- uauxv = (void *)((char *)pss.ps_envstr
- + (pss.ps_nenvstr + 1) * sizeof(int32_t));
- len *= sizeof(int32_t);
- } else
-#endif
- {
- uauxv = (void *)(pss.ps_envstr + pss.ps_nenvstr + 1);
- len *= sizeof(char *);
- }
+ size_t ptrsz = PROC_PTRSZ(p);
+ uauxv = (void *)((char *)pss.ps_envstr + (pss.ps_nenvstr + 1) * ptrsz);
+ size_t len = p->p_execsw->es_arglen * ptrsz;
kauxv = kmem_alloc(len, KM_SLEEP);
error = copyin_proc(p, uauxv, kauxv, len);
diff -r d7dce42069b3 -r 448964fa8ee3 sys/kern/kern_proc.c
--- a/sys/kern/kern_proc.c Thu Sep 29 20:40:49 2016 +0000
+++ b/sys/kern/kern_proc.c Thu Sep 29 20:40:53 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_proc.c,v 1.197 2016/09/17 12:00:34 maxv Exp $ */
+/* $NetBSD: kern_proc.c,v 1.198 2016/09/29 20:40:53 christos Exp $ */
/*-
* Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.197 2016/09/17 12:00:34 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.198 2016/09/29 20:40:53 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_kstack.h"
@@ -2052,12 +2052,6 @@
goto done;
}
-#ifdef COMPAT_NETBSD32
- if (p->p_flag & PK_32)
- entry_len = sizeof(netbsd32_charp);
- else
-#endif
- entry_len = sizeof(char *);
/*
* Now copy each string.
@@ -2065,6 +2059,7 @@
len = 0; /* bytes written to user buffer */
loaded = 0; /* bytes from argv already processed */
i = 0; /* To make compiler happy */
+ entry_len = PROC_PTRSZ(p);
for (; argvlen; --argvlen) {
int finished = 0;
diff -r d7dce42069b3 -r 448964fa8ee3 sys/kern/sys_process.c
--- a/sys/kern/sys_process.c Thu Sep 29 20:40:49 2016 +0000
+++ b/sys/kern/sys_process.c Thu Sep 29 20:40:53 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_process.c,v 1.169 2016/05/25 17:43:58 christos Exp $ */
+/* $NetBSD: sys_process.c,v 1.170 2016/09/29 20:40:53 christos Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.169 2016/05/25 17:43:58 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.170 2016/09/29 20:40:53 christos Exp $");
#include "opt_ptrace.h"
#include "opt_ktrace.h"
@@ -563,7 +563,7 @@
case PIOD_READ_AUXV:
req = PT_READ_D;
uio.uio_rw = UIO_READ;
- tmp = t->p_execsw->es_arglen * sizeof(char *);
+ tmp = t->p_execsw->es_arglen * PROC_PTRSZ(t);
if (uio.uio_offset > tmp)
return EIO;
if (uio.uio_resid > tmp - uio.uio_offset)
diff -r d7dce42069b3 -r 448964fa8ee3 sys/sys/proc.h
--- a/sys/sys/proc.h Thu Sep 29 20:40:49 2016 +0000
+++ b/sys/sys/proc.h Thu Sep 29 20:40:53 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: proc.h,v 1.333 2016/09/23 14:09:39 skrll Exp $ */
+/* $NetBSD: proc.h,v 1.334 2016/09/29 20:40:53 christos Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -556,6 +556,8 @@
return p;
}
+#define PROC_PTRSZ(p) (((p)->p_flag & PK_32) ? sizeof(int) : sizeof(void *))
+
/*
* PROCLIST_FOREACH: iterate on the given proclist, skipping PK_MARKER ones.
*/
Home |
Main Index |
Thread Index |
Old Index