Make it possible to compile a kernel with COMPAT_NETBSD32 but without COMPAT_40. This fixes PR port-amd64/39967.diff -r1.147 -r1.148 src/sys/compat/netbsd32/netbsd32_netbsd.c
(tron)
--- src/sys/compat/netbsd32/netbsd32_netbsd.c 2008/11/19 18:36:05 1.147
+++ src/sys/compat/netbsd32/netbsd32_netbsd.c 2008/11/20 11:56:40 1.148
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: netbsd32_netbsd.c,v 1.147 2008/11/19 18:36:05 ad Exp $ */ | 1 | /* $NetBSD: netbsd32_netbsd.c,v 1.148 2008/11/20 11:56:40 tron Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1998, 2001 Matthew R. Green | 4 | * Copyright (c) 1998, 2001 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. | |
@@ -17,27 +17,27 @@ | @@ -17,27 +17,27 @@ | |||
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
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 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.147 2008/11/19 18:36:05 ad Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.148 2008/11/20 11:56:40 tron Exp $"); | |
31 | 31 | |||
32 | #if defined(_KERNEL_OPT) | 32 | #if defined(_KERNEL_OPT) | |
33 | #include "opt_ddb.h" | 33 | #include "opt_ddb.h" | |
34 | #include "opt_ntp.h" | 34 | #include "opt_ntp.h" | |
35 | #include "opt_compat_netbsd.h" | 35 | #include "opt_compat_netbsd.h" | |
36 | #include "opt_compat_43.h" | 36 | #include "opt_compat_43.h" | |
37 | #include "opt_sysv.h" | 37 | #include "opt_sysv.h" | |
38 | #include "opt_syscall_debug.h" | 38 | #include "opt_syscall_debug.h" | |
39 | #include "opt_sa.h" | 39 | #include "opt_sa.h" | |
40 | 40 | |||
41 | #include "fs_lfs.h" | 41 | #include "fs_lfs.h" | |
42 | #endif | 42 | #endif | |
43 | 43 | |||
@@ -164,27 +164,31 @@ struct emul emul_netbsd32 = { | @@ -164,27 +164,31 @@ struct emul emul_netbsd32 = { | |||
164 | NULL, | 164 | NULL, | |
165 | NULL, | 165 | NULL, | |
166 | NULL, | 166 | NULL, | |
167 | #ifdef __HAVE_SYSCALL_INTERN | 167 | #ifdef __HAVE_SYSCALL_INTERN | |
168 | netbsd32_syscall_intern, | 168 | netbsd32_syscall_intern, | |
169 | #else | 169 | #else | |
170 | syscall, | 170 | syscall, | |
171 | #endif | 171 | #endif | |
172 | &netbsd32_sysctl_root, | 172 | &netbsd32_sysctl_root, | |
173 | NULL, | 173 | NULL, | |
174 | 174 | |||
175 | netbsd32_vm_default_addr, | 175 | netbsd32_vm_default_addr, | |
176 | NULL, | 176 | NULL, | |
177 | #ifdef COMPAT_40 | |||
177 | &saemul_netbsd32, | 178 | &saemul_netbsd32, | |
179 | #else | |||
180 | NULL, | |||
181 | #endif | |||
178 | sizeof(ucontext32_t), | 182 | sizeof(ucontext32_t), | |
179 | startlwp32, | 183 | startlwp32, | |
180 | }; | 184 | }; | |
181 | 185 | |||
182 | /* | 186 | /* | |
183 | * below are all the standard NetBSD system calls, in the 32bit | 187 | * below are all the standard NetBSD system calls, in the 32bit | |
184 | * environment, with the necessary conversions to 64bit before | 188 | * environment, with the necessary conversions to 64bit before | |
185 | * calling the real syscall. anything that needs special | 189 | * calling the real syscall. anything that needs special | |
186 | * attention is handled elsewhere. | 190 | * attention is handled elsewhere. | |
187 | */ | 191 | */ | |
188 | 192 | |||
189 | int | 193 | int | |
190 | netbsd32_exit(struct lwp *l, const struct netbsd32_exit_args *uap, register_t *retval) | 194 | netbsd32_exit(struct lwp *l, const struct netbsd32_exit_args *uap, register_t *retval) | |
@@ -367,39 +371,43 @@ netbsd32_break(struct lwp *l, const stru | @@ -367,39 +371,43 @@ netbsd32_break(struct lwp *l, const stru | |||
367 | /* { | 371 | /* { | |
368 | syscallarg(netbsd32_charp) nsize; | 372 | syscallarg(netbsd32_charp) nsize; | |
369 | } */ | 373 | } */ | |
370 | struct sys_obreak_args ua; | 374 | struct sys_obreak_args ua; | |
371 | 375 | |||
372 | SCARG(&ua, nsize) = SCARG_P32(uap, nsize); | 376 | SCARG(&ua, nsize) = SCARG_P32(uap, nsize); | |
373 | NETBSD32TOP_UAP(nsize, char); | 377 | NETBSD32TOP_UAP(nsize, char); | |
374 | return (sys_obreak(l, &ua, retval)); | 378 | return (sys_obreak(l, &ua, retval)); | |
375 | } | 379 | } | |
376 | 380 | |||
377 | int | 381 | int | |
378 | netbsd32_mount(struct lwp *l, const struct netbsd32_mount_args *uap, register_t *retval) | 382 | netbsd32_mount(struct lwp *l, const struct netbsd32_mount_args *uap, register_t *retval) | |
379 | { | 383 | { | |
384 | #ifdef COMPAT_40 | |||
380 | /* { | 385 | /* { | |
381 | syscallarg(const netbsd32_charp) type; | 386 | syscallarg(const netbsd32_charp) type; | |
382 | syscallarg(const netbsd32_charp) path; | 387 | syscallarg(const netbsd32_charp) path; | |
383 | syscallarg(int) flags; | 388 | syscallarg(int) flags; | |
384 | syscallarg(netbsd32_voidp) data; | 389 | syscallarg(netbsd32_voidp) data; | |
385 | } */ | 390 | } */ | |
386 | struct compat_40_sys_mount_args ua; | 391 | struct compat_40_sys_mount_args ua; | |
387 | 392 | |||
388 | NETBSD32TOP_UAP(type, const char); | 393 | NETBSD32TOP_UAP(type, const char); | |
389 | NETBSD32TOP_UAP(path, const char); | 394 | NETBSD32TOP_UAP(path, const char); | |
390 | NETBSD32TO64_UAP(flags); | 395 | NETBSD32TO64_UAP(flags); | |
391 | NETBSD32TOP_UAP(data, void); | 396 | NETBSD32TOP_UAP(data, void); | |
392 | return (compat_40_sys_mount(l, &ua, retval)); | 397 | return (compat_40_sys_mount(l, &ua, retval)); | |
398 | #else | |||
399 | return ENOSYS; | |||
400 | #endif | |||
393 | } | 401 | } | |
394 | 402 | |||
395 | int | 403 | int | |
396 | netbsd32_unmount(struct lwp *l, const struct netbsd32_unmount_args *uap, register_t *retval) | 404 | netbsd32_unmount(struct lwp *l, const struct netbsd32_unmount_args *uap, register_t *retval) | |
397 | { | 405 | { | |
398 | /* { | 406 | /* { | |
399 | syscallarg(const netbsd32_charp) path; | 407 | syscallarg(const netbsd32_charp) path; | |
400 | syscallarg(int) flags; | 408 | syscallarg(int) flags; | |
401 | } */ | 409 | } */ | |
402 | struct sys_unmount_args ua; | 410 | struct sys_unmount_args ua; | |
403 | 411 | |||
404 | NETBSD32TOP_UAP(path, const char); | 412 | NETBSD32TOP_UAP(path, const char); | |
405 | NETBSD32TO64_UAP(flags); | 413 | NETBSD32TO64_UAP(flags); |
--- src/sys/compat/netbsd32/Attic/netbsd32_sa.c 2008/10/15 06:52:38 1.7
+++ src/sys/compat/netbsd32/Attic/netbsd32_sa.c 2008/11/20 11:56:40 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: netbsd32_sa.c,v 1.7 2008/10/15 06:52:38 wrstuden Exp $ */ | 1 | /* $NetBSD: netbsd32_sa.c,v 1.8 2008/11/20 11:56:40 tron Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2005 The NetBSD Foundation. | 4 | * Copyright (c) 2005 The NetBSD Foundation. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to the NetBSD Foundation | 7 | * This code is derived from software contributed to the NetBSD Foundation | |
8 | * by Quentin Garnier. | 8 | * by Quentin Garnier. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -23,27 +23,27 @@ | @@ -23,27 +23,27 @@ | |||
23 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 23 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
24 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 24 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
26 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 26 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
32 | * POSSIBILITY OF SUCH DAMAGE. | 32 | * POSSIBILITY OF SUCH DAMAGE. | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #include <sys/cdefs.h> | 35 | #include <sys/cdefs.h> | |
36 | __KERNEL_RCSID(0, "$NetBSD: netbsd32_sa.c,v 1.7 2008/10/15 06:52:38 wrstuden Exp $"); | 36 | __KERNEL_RCSID(0, "$NetBSD: netbsd32_sa.c,v 1.8 2008/11/20 11:56:40 tron Exp $"); | |
37 | 37 | |||
38 | #include <sys/types.h> | 38 | #include <sys/types.h> | |
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
41 | #include <sys/kernel.h> | 41 | #include <sys/kernel.h> | |
42 | #include <sys/dirent.h> | 42 | #include <sys/dirent.h> | |
43 | #include <sys/mount.h> | 43 | #include <sys/mount.h> | |
44 | #include <sys/proc.h> | 44 | #include <sys/proc.h> | |
45 | #include <sys/sa.h> | 45 | #include <sys/sa.h> | |
46 | #include <sys/savar.h> | 46 | #include <sys/savar.h> | |
47 | #include <sys/syscallargs.h> | 47 | #include <sys/syscallargs.h> | |
48 | 48 | |||
49 | #include <compat/netbsd32/netbsd32.h> | 49 | #include <compat/netbsd32/netbsd32.h> | |
@@ -122,80 +122,90 @@ void * | @@ -122,80 +122,90 @@ void * | |||
122 | netbsd32_sa_ucsp(void *arg) | 122 | netbsd32_sa_ucsp(void *arg) | |
123 | { | 123 | { | |
124 | ucontext32_t *uc32 = arg; | 124 | ucontext32_t *uc32 = arg; | |
125 | 125 | |||
126 | return NETBSD32IPTR64(_UC_MACHINE32_SP(uc32)); | 126 | return NETBSD32IPTR64(_UC_MACHINE32_SP(uc32)); | |
127 | } | 127 | } | |
128 | 128 | |||
129 | /* Sycalls conversion */ | 129 | /* Sycalls conversion */ | |
130 | 130 | |||
131 | int | 131 | int | |
132 | netbsd32_sa_register(struct lwp *l, | 132 | netbsd32_sa_register(struct lwp *l, | |
133 | const struct netbsd32_sa_register_args *uap, register_t *retval) | 133 | const struct netbsd32_sa_register_args *uap, register_t *retval) | |
134 | { | 134 | { | |
135 | #ifdef COMPAT_40 | |||
135 | /* { | 136 | /* { | |
136 | syscallarg(netbsd32_sa_upcall_t) new; | 137 | syscallarg(netbsd32_sa_upcall_t) new; | |
137 | syscallarg(netbsd32_sa_upcallp_t) old; | 138 | syscallarg(netbsd32_sa_upcallp_t) old; | |
138 | syscallarg(int) flags; | 139 | syscallarg(int) flags; | |
139 | syscallarg(netbsd32_ssize_t) stackinfo_offset; | 140 | syscallarg(netbsd32_ssize_t) stackinfo_offset; | |
140 | } */ | 141 | } */ | |
141 | sa_upcall_t prev; | 142 | sa_upcall_t prev; | |
142 | int error; | 143 | int error; | |
143 | 144 | |||
144 | error = dosa_register(l, NETBSD32PTR64(SCARG(uap, new)), &prev, | 145 | error = dosa_register(l, NETBSD32PTR64(SCARG(uap, new)), &prev, | |
145 | SCARG(uap, flags), SCARG(uap, stackinfo_offset)); | 146 | SCARG(uap, flags), SCARG(uap, stackinfo_offset)); | |
146 | if (error) | 147 | if (error) | |
147 | return error; | 148 | return error; | |
148 | 149 | |||
149 | if (NETBSD32PTR64(SCARG(uap, old))) { | 150 | if (NETBSD32PTR64(SCARG(uap, old))) { | |
150 | 151 | |||
151 | netbsd32_sa_upcall_t old; | 152 | netbsd32_sa_upcall_t old; | |
152 | NETBSD32PTR32(old, prev); | 153 | NETBSD32PTR32(old, prev); | |
153 | return copyout(&old, NETBSD32PTR64(SCARG(uap, old)), | 154 | return copyout(&old, NETBSD32PTR64(SCARG(uap, old)), | |
154 | sizeof(old)); | 155 | sizeof(old)); | |
155 | } | 156 | } | |
156 | 157 | |||
157 | return 0; | 158 | return 0; | |
159 | #else | |||
160 | return ENOSYS; | |||
161 | #endif | |||
158 | } | 162 | } | |
159 | 163 | |||
164 | #ifdef COMPAT_40 | |||
160 | static int | 165 | static int | |
161 | netbsd32_sa_copyin_stack(stack_t *stacks, int index, stack_t *dest) | 166 | netbsd32_sa_copyin_stack(stack_t *stacks, int index, stack_t *dest) | |
162 | { | 167 | { | |
163 | stack32_t s32, *stacks32; | 168 | stack32_t s32, *stacks32; | |
164 | int error; | 169 | int error; | |
165 | 170 | |||
166 | stacks32 = (stack32_t *)stacks; | 171 | stacks32 = (stack32_t *)stacks; | |
167 | error = copyin(stacks32 + index, &s32, sizeof(s32)); | 172 | error = copyin(stacks32 + index, &s32, sizeof(s32)); | |
168 | if (error) | 173 | if (error) | |
169 | return error; | 174 | return error; | |
170 | 175 | |||
171 | dest->ss_sp = NETBSD32IPTR64(s32.ss_sp); | 176 | dest->ss_sp = NETBSD32IPTR64(s32.ss_sp); | |
172 | dest->ss_size = s32.ss_size; | 177 | dest->ss_size = s32.ss_size; | |
173 | dest->ss_flags = s32.ss_flags; | 178 | dest->ss_flags = s32.ss_flags; | |
174 | 179 | |||
175 | return 0; | 180 | return 0; | |
176 | } | 181 | } | |
182 | #endif | |||
177 | 183 | |||
178 | int | 184 | int | |
179 | netbsd32_sa_stacks(struct lwp *l, const struct netbsd32_sa_stacks_args *uap, | 185 | netbsd32_sa_stacks(struct lwp *l, const struct netbsd32_sa_stacks_args *uap, | |
180 | register_t *retval) | 186 | register_t *retval) | |
181 | { | 187 | { | |
188 | #ifdef COMPAT_40 | |||
182 | /* { | 189 | /* { | |
183 | syscallarg(int) num; | 190 | syscallarg(int) num; | |
184 | syscallarg(netbsd32_stackp_t) stacks; | 191 | syscallarg(netbsd32_stackp_t) stacks; | |
185 | } */ | 192 | } */ | |
186 | 193 | |||
187 | return sa_stacks1(l, retval, SCARG(uap, num), | 194 | return sa_stacks1(l, retval, SCARG(uap, num), | |
188 | NETBSD32PTR64(SCARG(uap, stacks)), netbsd32_sa_copyin_stack); | 195 | NETBSD32PTR64(SCARG(uap, stacks)), netbsd32_sa_copyin_stack); | |
196 | #else | |||
197 | return ENOSYS; | |||
198 | #endif | |||
189 | } | 199 | } | |
190 | 200 | |||
191 | int | 201 | int | |
192 | netbsd32_sa_setconcurrency(struct lwp *l, | 202 | netbsd32_sa_setconcurrency(struct lwp *l, | |
193 | const struct netbsd32_sa_setconcurrency_args *uap, register_t *retval) | 203 | const struct netbsd32_sa_setconcurrency_args *uap, register_t *retval) | |
194 | { | 204 | { | |
195 | /* { | 205 | /* { | |
196 | syscallarg(int) concurrency; | 206 | syscallarg(int) concurrency; | |
197 | } */ | 207 | } */ | |
198 | struct sys_sa_setconcurrency_args ua; | 208 | struct sys_sa_setconcurrency_args ua; | |
199 | 209 | |||
200 | NETBSD32TO64_UAP(concurrency); | 210 | NETBSD32TO64_UAP(concurrency); | |
201 | return sys_sa_setconcurrency(l, &ua, retval); | 211 | return sys_sa_setconcurrency(l, &ua, retval); |