Tue Jan 19 01:47:58 2021 UTC ()
Also print mmap return value and error code #ifdef DEBUG_MMAP.


(simonb)
diff -r1.2 -r1.3 src/sys/compat/netbsd32/netbsd32_vm.c

cvs diff -r1.2 -r1.3 src/sys/compat/netbsd32/netbsd32_vm.c (expand / switch to unified diff)

--- src/sys/compat/netbsd32/netbsd32_vm.c 2020/01/07 07:26:21 1.2
+++ src/sys/compat/netbsd32/netbsd32_vm.c 2021/01/19 01:47:58 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: netbsd32_vm.c,v 1.2 2020/01/07 07:26:21 mrg Exp $ */ 1/* $NetBSD: netbsd32_vm.c,v 1.3 2021/01/19 01:47:58 simonb Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998, 2001, 2008, 2018 Matthew R. Green 4 * Copyright (c) 1998, 2001, 2008, 2018 Matthew R. Green
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 * 27 *
28 * from: NetBSD: netbsd32_netbsd.c,v 1.221 2018/12/24 20:44:39 mrg Exp 28 * from: NetBSD: netbsd32_netbsd.c,v 1.221 2018/12/24 20:44:39 mrg Exp
29 */ 29 */
30 30
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32__KERNEL_RCSID(0, "$NetBSD: netbsd32_vm.c,v 1.2 2020/01/07 07:26:21 mrg Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: netbsd32_vm.c,v 1.3 2021/01/19 01:47:58 simonb Exp $");
33 33
34#include <sys/param.h> 34#include <sys/param.h>
35#include <sys/systm.h> 35#include <sys/systm.h>
36#include <sys/mman.h> 36#include <sys/mman.h>
37#include <sys/filedesc.h> 37#include <sys/filedesc.h>
38#include <sys/vfs_syscalls.h> 38#include <sys/vfs_syscalls.h>
39 39
40#include <compat/sys/mman.h> 40#include <compat/sys/mman.h>
41#include <compat/netbsd32/netbsd32.h> 41#include <compat/netbsd32/netbsd32.h>
42#include <compat/netbsd32/netbsd32_syscall.h> 42#include <compat/netbsd32/netbsd32_syscall.h>
43#include <compat/netbsd32/netbsd32_syscallargs.h> 43#include <compat/netbsd32/netbsd32_syscallargs.h>
44#include <compat/netbsd32/netbsd32_conv.h> 44#include <compat/netbsd32/netbsd32_conv.h>
45 45
@@ -76,24 +76,27 @@ netbsd32_mmap(struct lwp *l, const struc @@ -76,24 +76,27 @@ netbsd32_mmap(struct lwp *l, const struc
76#endif 76#endif
77 NETBSD32TO64_UAP(fd); 77 NETBSD32TO64_UAP(fd);
78 NETBSD32TOX_UAP(PAD, long); 78 NETBSD32TOX_UAP(PAD, long);
79 NETBSD32TOX_UAP(pos, off_t); 79 NETBSD32TOX_UAP(pos, off_t);
80#ifdef DEBUG_MMAP 80#ifdef DEBUG_MMAP
81 printf("mmap(addr=0x%lx, len=0x%lx, prot=0x%lx, flags=0x%lx, " 81 printf("mmap(addr=0x%lx, len=0x%lx, prot=0x%lx, flags=0x%lx, "
82 "fd=%ld, pos=0x%lx);\n", 82 "fd=%ld, pos=0x%lx);\n",
83 (long)SCARG(&ua, addr), (long)SCARG(&ua, len), 83 (long)SCARG(&ua, addr), (long)SCARG(&ua, len),
84 (long)SCARG(&ua, prot), (long)SCARG(&ua, flags), 84 (long)SCARG(&ua, prot), (long)SCARG(&ua, flags),
85 (long)SCARG(&ua, fd), (long)SCARG(&ua, pos)); 85 (long)SCARG(&ua, fd), (long)SCARG(&ua, pos));
86#endif 86#endif
87 87
88 error = sys_mmap(l, &ua, retval); 88 error = sys_mmap(l, &ua, retval);
 89#ifdef DEBUG_MMAP
 90 printf("mmap error = %d *retval = %#"PRIxREGISTER"\n", error, *retval);
 91#endif
89 if (error == 0 && (u_long)*retval > (u_long)UINT_MAX) { 92 if (error == 0 && (u_long)*retval > (u_long)UINT_MAX) {
90 const char *name = curlwp->l_name; 93 const char *name = curlwp->l_name;
91 94
92 if (name == NULL) 95 if (name == NULL)
93 name = curproc->p_comm; 96 name = curproc->p_comm;
94 printf("netbsd32_mmap(%s:%u:%u): retval out of range: 0x%lx\n", 97 printf("netbsd32_mmap(%s:%u:%u): retval out of range: 0x%lx\n",
95 name, curproc->p_pid, curlwp->l_lid, (u_long)*retval); 98 name, curproc->p_pid, curlwp->l_lid, (u_long)*retval);
96 /* Should try to recover and return an error here. */ 99 /* Should try to recover and return an error here. */
97 } 100 }
98 return error; 101 return error;
99} 102}