* [PATCH v2 01/16] bsd-user/main.c: Drop syscall flavor arg -bsd
2022-02-26 17:07 [PATCH v2 00/16] bsd-user: Start upstreaming the system calls Warner Losh
@ 2022-02-26 17:07 ` Warner Losh
2022-02-26 17:07 ` [PATCH v2 02/16] bsd-user/x86_64/target_arch_cpu.h: int $80 never was a BSD system call on amd64 Warner Losh
` (14 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Warner Losh @ 2022-02-26 17:07 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, arrowd, Kyle Evans, Richard Henderson, def, jrtc27,
Warner Losh, Brad Smith
We've not realistically been able to actually run any bsd program on any
other bsd program. They are too diverged to do this easily. The current
code is setup to do it, but implementing it is hard. Stop pretending
that we can do this.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/main.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index f1d58e905e7..bddb830e99b 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -164,7 +164,6 @@ static void usage(void)
"-E var=value sets/modifies targets environment variable(s)\n"
"-U var unsets targets environment variable(s)\n"
"-B address set guest_base address to address\n"
- "-bsd type select emulated BSD type FreeBSD/NetBSD/OpenBSD (default)\n"
"\n"
"Debug options:\n"
"-d item1[,...] enable logging of specified items\n"
@@ -392,17 +391,6 @@ int main(int argc, char **argv)
have_guest_base = true;
} else if (!strcmp(r, "drop-ld-preload")) {
(void) envlist_unsetenv(envlist, "LD_PRELOAD");
- } else if (!strcmp(r, "bsd")) {
- if (!strcasecmp(argv[optind], "freebsd")) {
- bsd_type = target_freebsd;
- } else if (!strcasecmp(argv[optind], "netbsd")) {
- bsd_type = target_netbsd;
- } else if (!strcasecmp(argv[optind], "openbsd")) {
- bsd_type = target_openbsd;
- } else {
- usage();
- }
- optind++;
} else if (!strcmp(r, "seed")) {
seed_optarg = optarg;
} else if (!strcmp(r, "singlestep")) {
--
2.33.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 02/16] bsd-user/x86_64/target_arch_cpu.h: int $80 never was a BSD system call on amd64
2022-02-26 17:07 [PATCH v2 00/16] bsd-user: Start upstreaming the system calls Warner Losh
2022-02-26 17:07 ` [PATCH v2 01/16] bsd-user/main.c: Drop syscall flavor arg -bsd Warner Losh
@ 2022-02-26 17:07 ` Warner Losh
2022-02-26 17:07 ` [PATCH v2 03/16] bsd-user/x86_64/target_arch_cpu.h: Remove openbsd syscall Warner Losh
` (13 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Warner Losh @ 2022-02-26 17:07 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, arrowd, Kyle Evans, Richard Henderson, def, jrtc27,
Warner Losh, Brad Smith
Although initial versions of NetBSD did use int $80, it was replaced by
syscall before any releases. OpenBSD and FreeBSD always did syscall.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Kyle Evans <kevans@FreeBSD.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/x86_64/target_arch_cpu.h | 58 -------------------------------
1 file changed, 58 deletions(-)
diff --git a/bsd-user/x86_64/target_arch_cpu.h b/bsd-user/x86_64/target_arch_cpu.h
index 0a9c0f08946..9dc52d5afc4 100644
--- a/bsd-user/x86_64/target_arch_cpu.h
+++ b/bsd-user/x86_64/target_arch_cpu.h
@@ -124,64 +124,6 @@ static inline void target_cpu_loop(CPUX86State *env)
process_queued_cpu_work(cs);
switch (trapnr) {
- case 0x80:
- /* syscall from int $0x80 */
- if (bsd_type == target_freebsd) {
- abi_ulong params = (abi_ulong) env->regs[R_ESP] +
- sizeof(int32_t);
- int32_t syscall_nr = env->regs[R_EAX];
- int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8;
-
- if (syscall_nr == TARGET_FREEBSD_NR_syscall) {
- get_user_s32(syscall_nr, params);
- params += sizeof(int32_t);
- } else if (syscall_nr == TARGET_FREEBSD_NR___syscall) {
- get_user_s32(syscall_nr, params);
- params += sizeof(int64_t);
- }
- get_user_s32(arg1, params);
- params += sizeof(int32_t);
- get_user_s32(arg2, params);
- params += sizeof(int32_t);
- get_user_s32(arg3, params);
- params += sizeof(int32_t);
- get_user_s32(arg4, params);
- params += sizeof(int32_t);
- get_user_s32(arg5, params);
- params += sizeof(int32_t);
- get_user_s32(arg6, params);
- params += sizeof(int32_t);
- get_user_s32(arg7, params);
- params += sizeof(int32_t);
- get_user_s32(arg8, params);
- env->regs[R_EAX] = do_freebsd_syscall(env,
- syscall_nr,
- arg1,
- arg2,
- arg3,
- arg4,
- arg5,
- arg6,
- arg7,
- arg8);
- } else { /* if (bsd_type == target_openbsd) */
- env->regs[R_EAX] = do_openbsd_syscall(env,
- env->regs[R_EAX],
- env->regs[R_EBX],
- env->regs[R_ECX],
- env->regs[R_EDX],
- env->regs[R_ESI],
- env->regs[R_EDI],
- env->regs[R_EBP]);
- }
- if (((abi_ulong)env->regs[R_EAX]) >= (abi_ulong)(-515)) {
- env->regs[R_EAX] = -env->regs[R_EAX];
- env->eflags |= CC_C;
- } else {
- env->eflags &= ~CC_C;
- }
- break;
-
case EXCP_SYSCALL:
/* syscall from syscall instruction */
if (bsd_type == target_freebsd) {
--
2.33.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 03/16] bsd-user/x86_64/target_arch_cpu.h: Remove openbsd syscall
2022-02-26 17:07 [PATCH v2 00/16] bsd-user: Start upstreaming the system calls Warner Losh
2022-02-26 17:07 ` [PATCH v2 01/16] bsd-user/main.c: Drop syscall flavor arg -bsd Warner Losh
2022-02-26 17:07 ` [PATCH v2 02/16] bsd-user/x86_64/target_arch_cpu.h: int $80 never was a BSD system call on amd64 Warner Losh
@ 2022-02-26 17:07 ` Warner Losh
2022-02-26 17:07 ` [PATCH v2 04/16] bsd-user/i386/target_arch_cpu.h: " Warner Losh
` (12 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Warner Losh @ 2022-02-26 17:07 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, arrowd, Kyle Evans, Richard Henderson, def, jrtc27,
Warner Losh, Brad Smith
This doesn't build on openbsd at the moment, and this could
should arguably be in bsd-user/*bsd/x86_64 somewhere. Until
we refactor to support OpenBSD/NetBSD again, drop it here.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Kyle Evans <kevans@FreeBSD.org>
---
bsd-user/x86_64/target_arch_cpu.h | 27 ++++++++-------------------
1 file changed, 8 insertions(+), 19 deletions(-)
diff --git a/bsd-user/x86_64/target_arch_cpu.h b/bsd-user/x86_64/target_arch_cpu.h
index 9dc52d5afc4..5be2f02416e 100644
--- a/bsd-user/x86_64/target_arch_cpu.h
+++ b/bsd-user/x86_64/target_arch_cpu.h
@@ -126,25 +126,14 @@ static inline void target_cpu_loop(CPUX86State *env)
switch (trapnr) {
case EXCP_SYSCALL:
/* syscall from syscall instruction */
- if (bsd_type == target_freebsd) {
- env->regs[R_EAX] = do_freebsd_syscall(env,
- env->regs[R_EAX],
- env->regs[R_EDI],
- env->regs[R_ESI],
- env->regs[R_EDX],
- env->regs[R_ECX],
- env->regs[8],
- env->regs[9], 0, 0);
- } else { /* if (bsd_type == target_openbsd) */
- env->regs[R_EAX] = do_openbsd_syscall(env,
- env->regs[R_EAX],
- env->regs[R_EDI],
- env->regs[R_ESI],
- env->regs[R_EDX],
- env->regs[10],
- env->regs[8],
- env->regs[9]);
- }
+ env->regs[R_EAX] = do_freebsd_syscall(env,
+ env->regs[R_EAX],
+ env->regs[R_EDI],
+ env->regs[R_ESI],
+ env->regs[R_EDX],
+ env->regs[R_ECX],
+ env->regs[8],
+ env->regs[9], 0, 0);
env->eip = env->exception_next_eip;
if (((abi_ulong)env->regs[R_EAX]) >= (abi_ulong)(-515)) {
env->regs[R_EAX] = -env->regs[R_EAX];
--
2.33.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 04/16] bsd-user/i386/target_arch_cpu.h: Remove openbsd syscall
2022-02-26 17:07 [PATCH v2 00/16] bsd-user: Start upstreaming the system calls Warner Losh
` (2 preceding siblings ...)
2022-02-26 17:07 ` [PATCH v2 03/16] bsd-user/x86_64/target_arch_cpu.h: Remove openbsd syscall Warner Losh
@ 2022-02-26 17:07 ` Warner Losh
2022-02-26 17:07 ` [PATCH v2 05/16] bsd-user/arm/target_arch_cpu.h: Only support FreeBSD sys calls Warner Losh
` (11 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Warner Losh @ 2022-02-26 17:07 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, arrowd, Kyle Evans, Richard Henderson, def, jrtc27,
Warner Losh, Brad Smith
This doesn't build on openbsd at the moment, and this could
should arguably be in bsd-user/*bsd/i386 somewhere. Until
we refactor to support OpenBSD/NetBSD again, drop it here.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Kyle Evans <kevans@FreeBSD.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/i386/target_arch_cpu.h | 84 +++++++++++++++------------------
1 file changed, 37 insertions(+), 47 deletions(-)
diff --git a/bsd-user/i386/target_arch_cpu.h b/bsd-user/i386/target_arch_cpu.h
index 3cbf69d8af2..9da22202d48 100644
--- a/bsd-user/i386/target_arch_cpu.h
+++ b/bsd-user/i386/target_arch_cpu.h
@@ -116,55 +116,45 @@ static inline void target_cpu_loop(CPUX86State *env)
process_queued_cpu_work(cs);
switch (trapnr) {
- case 0x80:
+ case 0x80: {
/* syscall from int $0x80 */
- if (bsd_type == target_freebsd) {
- abi_ulong params = (abi_ulong) env->regs[R_ESP] +
- sizeof(int32_t);
- int32_t syscall_nr = env->regs[R_EAX];
- int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8;
-
- if (syscall_nr == TARGET_FREEBSD_NR_syscall) {
- get_user_s32(syscall_nr, params);
- params += sizeof(int32_t);
- } else if (syscall_nr == TARGET_FREEBSD_NR___syscall) {
- get_user_s32(syscall_nr, params);
- params += sizeof(int64_t);
- }
- get_user_s32(arg1, params);
- params += sizeof(int32_t);
- get_user_s32(arg2, params);
- params += sizeof(int32_t);
- get_user_s32(arg3, params);
- params += sizeof(int32_t);
- get_user_s32(arg4, params);
- params += sizeof(int32_t);
- get_user_s32(arg5, params);
- params += sizeof(int32_t);
- get_user_s32(arg6, params);
- params += sizeof(int32_t);
- get_user_s32(arg7, params);
+ abi_ulong params = (abi_ulong) env->regs[R_ESP] +
+ sizeof(int32_t);
+ int32_t syscall_nr = env->regs[R_EAX];
+ int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8;
+
+ if (syscall_nr == TARGET_FREEBSD_NR_syscall) {
+ get_user_s32(syscall_nr, params);
params += sizeof(int32_t);
- get_user_s32(arg8, params);
- env->regs[R_EAX] = do_freebsd_syscall(env,
- syscall_nr,
- arg1,
- arg2,
- arg3,
- arg4,
- arg5,
- arg6,
- arg7,
- arg8);
- } else { /* if (bsd_type == target_openbsd) */
- env->regs[R_EAX] = do_openbsd_syscall(env,
- env->regs[R_EAX],
- env->regs[R_EBX],
- env->regs[R_ECX],
- env->regs[R_EDX],
- env->regs[R_ESI],
- env->regs[R_EDI],
- env->regs[R_EBP]);
+ } else if (syscall_nr == TARGET_FREEBSD_NR___syscall) {
+ get_user_s32(syscall_nr, params);
+ params += sizeof(int64_t);
+ }
+ get_user_s32(arg1, params);
+ params += sizeof(int32_t);
+ get_user_s32(arg2, params);
+ params += sizeof(int32_t);
+ get_user_s32(arg3, params);
+ params += sizeof(int32_t);
+ get_user_s32(arg4, params);
+ params += sizeof(int32_t);
+ get_user_s32(arg5, params);
+ params += sizeof(int32_t);
+ get_user_s32(arg6, params);
+ params += sizeof(int32_t);
+ get_user_s32(arg7, params);
+ params += sizeof(int32_t);
+ get_user_s32(arg8, params);
+ env->regs[R_EAX] = do_freebsd_syscall(env,
+ syscall_nr,
+ arg1,
+ arg2,
+ arg3,
+ arg4,
+ arg5,
+ arg6,
+ arg7,
+ arg8);
}
if (((abi_ulong)env->regs[R_EAX]) >= (abi_ulong)(-515)) {
env->regs[R_EAX] = -env->regs[R_EAX];
--
2.33.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 05/16] bsd-user/arm/target_arch_cpu.h: Only support FreeBSD sys calls
2022-02-26 17:07 [PATCH v2 00/16] bsd-user: Start upstreaming the system calls Warner Losh
` (3 preceding siblings ...)
2022-02-26 17:07 ` [PATCH v2 04/16] bsd-user/i386/target_arch_cpu.h: " Warner Losh
@ 2022-02-26 17:07 ` Warner Losh
2022-02-26 17:07 ` [PATCH v2 06/16] bsd-user/arm/target_arch_thread.h: Assume a FreeBSD target Warner Losh
` (10 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Warner Losh @ 2022-02-26 17:07 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, arrowd, Kyle Evans, Richard Henderson, def, jrtc27,
Warner Losh, Brad Smith
Since we don't build on OpenBSD, only do FreeBSD system calls here. In
the future, we'll need to move this to some place like
bsd-user/freebsd/arm/mumble.h, but until then just leave this
inline. This reflects changes to the upstream.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Kyle Evans <kevans@FreeBSD.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/arm/target_arch_cpu.h | 139 ++++++++++++++++-----------------
1 file changed, 66 insertions(+), 73 deletions(-)
diff --git a/bsd-user/arm/target_arch_cpu.h b/bsd-user/arm/target_arch_cpu.h
index b087db48fa4..afb7814a8d1 100644
--- a/bsd-user/arm/target_arch_cpu.h
+++ b/bsd-user/arm/target_arch_cpu.h
@@ -40,7 +40,6 @@ static inline void target_cpu_init(CPUARMState *env,
static inline void target_cpu_loop(CPUARMState *env)
{
int trapnr, si_signo, si_code;
- unsigned int n;
CPUState *cs = env_cpu(env);
for (;;) {
@@ -66,82 +65,76 @@ static inline void target_cpu_loop(CPUARMState *env)
break;
case EXCP_SWI:
{
- n = env->regs[7];
- if (bsd_type == target_freebsd) {
- int ret;
- abi_ulong params = get_sp_from_cpustate(env);
- int32_t syscall_nr = n;
- int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8;
+ int ret;
+ abi_ulong params = get_sp_from_cpustate(env);
+ int32_t syscall_nr = env->regs[7];
+ int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8;
- /* See arm/arm/syscall.c cpu_fetch_syscall_args() */
- if (syscall_nr == TARGET_FREEBSD_NR_syscall) {
- syscall_nr = env->regs[0];
- arg1 = env->regs[1];
- arg2 = env->regs[2];
- arg3 = env->regs[3];
- get_user_s32(arg4, params);
- params += sizeof(int32_t);
- get_user_s32(arg5, params);
- params += sizeof(int32_t);
- get_user_s32(arg6, params);
- params += sizeof(int32_t);
- get_user_s32(arg7, params);
- arg8 = 0;
- } else if (syscall_nr == TARGET_FREEBSD_NR___syscall) {
- syscall_nr = env->regs[0];
- arg1 = env->regs[2];
- arg2 = env->regs[3];
- get_user_s32(arg3, params);
- params += sizeof(int32_t);
- get_user_s32(arg4, params);
- params += sizeof(int32_t);
- get_user_s32(arg5, params);
- params += sizeof(int32_t);
- get_user_s32(arg6, params);
- arg7 = 0;
- arg8 = 0;
- } else {
- arg1 = env->regs[0];
- arg2 = env->regs[1];
- arg3 = env->regs[2];
- arg4 = env->regs[3];
- get_user_s32(arg5, params);
- params += sizeof(int32_t);
- get_user_s32(arg6, params);
- params += sizeof(int32_t);
- get_user_s32(arg7, params);
- params += sizeof(int32_t);
- get_user_s32(arg8, params);
- }
- ret = do_freebsd_syscall(env, syscall_nr, arg1, arg2, arg3,
- arg4, arg5, arg6, arg7, arg8);
+ /* See arm/arm/syscall.c cpu_fetch_syscall_args() */
+ if (syscall_nr == TARGET_FREEBSD_NR_syscall) {
+ syscall_nr = env->regs[0];
+ arg1 = env->regs[1];
+ arg2 = env->regs[2];
+ arg3 = env->regs[3];
+ get_user_s32(arg4, params);
+ params += sizeof(int32_t);
+ get_user_s32(arg5, params);
+ params += sizeof(int32_t);
+ get_user_s32(arg6, params);
+ params += sizeof(int32_t);
+ get_user_s32(arg7, params);
+ arg8 = 0;
+ } else if (syscall_nr == TARGET_FREEBSD_NR___syscall) {
+ syscall_nr = env->regs[0];
+ arg1 = env->regs[2];
+ arg2 = env->regs[3];
+ get_user_s32(arg3, params);
+ params += sizeof(int32_t);
+ get_user_s32(arg4, params);
+ params += sizeof(int32_t);
+ get_user_s32(arg5, params);
+ params += sizeof(int32_t);
+ get_user_s32(arg6, params);
+ arg7 = 0;
+ arg8 = 0;
+ } else {
+ arg1 = env->regs[0];
+ arg2 = env->regs[1];
+ arg3 = env->regs[2];
+ arg4 = env->regs[3];
+ get_user_s32(arg5, params);
+ params += sizeof(int32_t);
+ get_user_s32(arg6, params);
+ params += sizeof(int32_t);
+ get_user_s32(arg7, params);
+ params += sizeof(int32_t);
+ get_user_s32(arg8, params);
+ }
+ ret = do_freebsd_syscall(env, syscall_nr, arg1, arg2, arg3,
+ arg4, arg5, arg6, arg7, arg8);
+ /*
+ * Compare to arm/arm/vm_machdep.c
+ * cpu_set_syscall_retval()
+ */
+ if (-TARGET_EJUSTRETURN == ret) {
/*
- * Compare to arm/arm/vm_machdep.c
- * cpu_set_syscall_retval()
+ * Returning from a successful sigreturn syscall.
+ * Avoid clobbering register state.
*/
- if (-TARGET_EJUSTRETURN == ret) {
- /*
- * Returning from a successful sigreturn syscall.
- * Avoid clobbering register state.
- */
- break;
- }
- if (-TARGET_ERESTART == ret) {
- env->regs[15] -= env->thumb ? 2 : 4;
- break;
- }
- if ((unsigned int)ret >= (unsigned int)(-515)) {
- ret = -ret;
- cpsr_write(env, CPSR_C, CPSR_C, CPSRWriteByInstr);
- env->regs[0] = ret;
- } else {
- cpsr_write(env, 0, CPSR_C, CPSRWriteByInstr);
- env->regs[0] = ret; /* XXX need to handle lseek()? */
- /* env->regs[1] = 0; */
- }
+ break;
+ }
+ if (-TARGET_ERESTART == ret) {
+ env->regs[15] -= env->thumb ? 2 : 4;
+ break;
+ }
+ if ((unsigned int)ret >= (unsigned int)(-515)) {
+ ret = -ret;
+ cpsr_write(env, CPSR_C, CPSR_C, CPSRWriteByInstr);
+ env->regs[0] = ret;
} else {
- fprintf(stderr, "qemu: bsd_type (= %d) syscall "
- "not supported\n", bsd_type);
+ cpsr_write(env, 0, CPSR_C, CPSRWriteByInstr);
+ env->regs[0] = ret; /* XXX need to handle lseek()? */
+ /* env->regs[1] = 0; */
}
}
break;
--
2.33.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 06/16] bsd-user/arm/target_arch_thread.h: Assume a FreeBSD target
2022-02-26 17:07 [PATCH v2 00/16] bsd-user: Start upstreaming the system calls Warner Losh
` (4 preceding siblings ...)
2022-02-26 17:07 ` [PATCH v2 05/16] bsd-user/arm/target_arch_cpu.h: Only support FreeBSD sys calls Warner Losh
@ 2022-02-26 17:07 ` Warner Losh
2022-02-26 17:07 ` [PATCH v2 07/16] bsd-user/x86_64/target_arch_thread.h: " Warner Losh
` (9 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Warner Losh @ 2022-02-26 17:07 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, arrowd, Kyle Evans, Richard Henderson, def, jrtc27,
Warner Losh, Brad Smith
Since we can't run on anything else, assume for the moment that this is
a FreeBSD target. In the future, we'll need to handle this properly
via some include file in bsd-user/*bsd/arm/mumble.h. There's a number
of other diffs that would be needed to make things work on OtherBSD,
so it doesn't make sense to preseve this one detail today.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Kyle Evans <kevans@FreeBSD.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/arm/target_arch_thread.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/bsd-user/arm/target_arch_thread.h b/bsd-user/arm/target_arch_thread.h
index 11c7f765838..fcafca2408c 100644
--- a/bsd-user/arm/target_arch_thread.h
+++ b/bsd-user/arm/target_arch_thread.h
@@ -62,9 +62,7 @@ static inline void target_thread_init(struct target_pt_regs *regs,
}
regs->ARM_pc = infop->entry & 0xfffffffe;
regs->ARM_sp = stack;
- if (bsd_type == target_freebsd) {
- regs->ARM_lr = infop->entry & 0xfffffffe;
- }
+ regs->ARM_lr = infop->entry & 0xfffffffe;
/*
* FreeBSD kernel passes the ps_strings pointer in r0. This is used by some
* programs to set status messages that we see in ps. bsd-user doesn't
--
2.33.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 07/16] bsd-user/x86_64/target_arch_thread.h: Assume a FreeBSD target
2022-02-26 17:07 [PATCH v2 00/16] bsd-user: Start upstreaming the system calls Warner Losh
` (5 preceding siblings ...)
2022-02-26 17:07 ` [PATCH v2 06/16] bsd-user/arm/target_arch_thread.h: Assume a FreeBSD target Warner Losh
@ 2022-02-26 17:07 ` Warner Losh
2022-02-26 17:07 ` [PATCH v2 08/16] bsd-user: Remove bsd_type Warner Losh
` (8 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Warner Losh @ 2022-02-26 17:07 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, arrowd, Kyle Evans, Richard Henderson, def, jrtc27,
Warner Losh, Brad Smith
Since we can't run on anything else, assume for the moment that this is
a FreeBSD target. In the future, we'll need to handle this properly via
some include file in bsd-user/*bsd/x86_64/mumble.h. There's a number of
other diffs that would be needed to make things work on OtherBSD, so it
doesn't make sense to preseve this one detail today.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Kyle Evans <kevans@FreeBSD.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/x86_64/target_arch_thread.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/bsd-user/x86_64/target_arch_thread.h b/bsd-user/x86_64/target_arch_thread.h
index d105e43fd35..b745d7ffeb7 100644
--- a/bsd-user/x86_64/target_arch_thread.h
+++ b/bsd-user/x86_64/target_arch_thread.h
@@ -32,9 +32,7 @@ static inline void target_thread_init(struct target_pt_regs *regs,
regs->rax = 0;
regs->rsp = infop->start_stack;
regs->rip = infop->entry;
- if (bsd_type == target_freebsd) {
- regs->rdi = infop->start_stack;
- }
+ regs->rdi = infop->start_stack;
}
#endif /* !_TARGET_ARCH_THREAD_H_ */
--
2.33.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 08/16] bsd-user: Remove bsd_type
2022-02-26 17:07 [PATCH v2 00/16] bsd-user: Start upstreaming the system calls Warner Losh
` (6 preceding siblings ...)
2022-02-26 17:07 ` [PATCH v2 07/16] bsd-user/x86_64/target_arch_thread.h: " Warner Losh
@ 2022-02-26 17:07 ` Warner Losh
2022-02-26 17:07 ` [PATCH v2 09/16] bsd-user/freebsd/os-syscall.c: Move syscall processing here Warner Losh
` (7 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Warner Losh @ 2022-02-26 17:07 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, arrowd, Kyle Evans, Richard Henderson, def, jrtc27,
Warner Losh, Brad Smith
Remove keeping track of which type of bsd we're running on. It's no
longer referenced in the code. Building bsd-user on NetBSD or OpenBSD
isn't possible, let alone running that code. Stop pretending that we can
do the cross BSD thing since there's been a large divergence since 2000
that makes this nearly impossible between FreeBSD and {Net,Open}BSD and
at least quite difficult between NetBSD and OpenBSD.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Kyle Evans <kevans@FreeBSD.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/main.c | 2 --
bsd-user/qemu.h | 7 -------
2 files changed, 9 deletions(-)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index bddb830e99b..88d347d05eb 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -96,7 +96,6 @@ unsigned long reserved_va;
static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX;
const char *qemu_uname_release;
-enum BSDType bsd_type;
char qemu_proc_pathname[PATH_MAX]; /* full path to exeutable */
unsigned long target_maxtsiz = TARGET_MAXTSIZ; /* max text size */
@@ -284,7 +283,6 @@ int main(int argc, char **argv)
const char *gdbstub = NULL;
char **target_environ, **wrk;
envlist_t *envlist = NULL;
- bsd_type = HOST_DEFAULT_BSD_TYPE;
char *argv0 = NULL;
adjust_ssize();
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 02921ac8b3b..e5742bd6c03 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -29,13 +29,6 @@
extern char **environ;
-enum BSDType {
- target_freebsd,
- target_netbsd,
- target_openbsd,
-};
-extern enum BSDType bsd_type;
-
#include "exec/user/thunk.h"
#include "target_arch.h"
#include "syscall_defs.h"
--
2.33.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 09/16] bsd-user/freebsd/os-syscall.c: Move syscall processing here
2022-02-26 17:07 [PATCH v2 00/16] bsd-user: Start upstreaming the system calls Warner Losh
` (7 preceding siblings ...)
2022-02-26 17:07 ` [PATCH v2 08/16] bsd-user: Remove bsd_type Warner Losh
@ 2022-02-26 17:07 ` Warner Losh
2022-02-26 17:07 ` [PATCH v2 10/16] bsd-user: Move system call building to os-syscall.c Warner Losh
` (6 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Warner Losh @ 2022-02-26 17:07 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, arrowd, Kyle Evans, Richard Henderson, def, jrtc27,
Warner Losh, Brad Smith
While there is some commonality between *BSD syscall processing, there's
a number of differences and the system call numbers and ABIs have been
independent since the late 90s. Move FreeBSD's proessing here and delete
it.
The upstream implementation is somewhat different than the current
implementation. It will be much easier to upstream these from scratch,
justifying the final result, rather than working out the diffs and
justifying the changes. Also tweak a comment to qemu standard form.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Kyle Evans <kevans@FreeBSD.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/freebsd/os-syscall.c | 69 +++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
create mode 100644 bsd-user/freebsd/os-syscall.c
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
new file mode 100644
index 00000000000..fc57e324173
--- /dev/null
+++ b/bsd-user/freebsd/os-syscall.c
@@ -0,0 +1,69 @@
+/*
+ * BSD syscalls
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ * Copyright (c) 2013-2014 Stacey D. Son
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * We need the FreeBSD "legacy" definitions. Rust needs the FreeBSD 11 system
+ * calls since it doesn't use libc at all, so we have to emulate that despite
+ * FreeBSD 11 being EOL'd.
+ */
+#define _WANT_FREEBSD11_STAT
+#define _WANT_FREEBSD11_STATFS
+#define _WANT_FREEBSD11_DIRENT
+#define _WANT_KERNEL_ERRNO
+#define _WANT_SEMUN
+#include "qemu/osdep.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
+#include <sys/syscall.h>
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <utime.h>
+
+#include "qemu.h"
+#include "qemu-common.h"
+#include "signal-common.h"
+#include "user/syscall-trace.h"
+
+void target_set_brk(abi_ulong new_brk)
+{
+}
+
+bool is_error(abi_long ret)
+{
+
+ return (abi_ulong)ret >= (abi_ulong)(-4096);
+}
+
+/*
+ * do_syscall() should always have a single exit point at the end so that
+ * actions, such as logging of syscall results, can be performed. All errnos
+ * that do_syscall() returns must be -TARGET_<errcode>.
+ */
+abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ abi_long arg2, abi_long arg3, abi_long arg4,
+ abi_long arg5, abi_long arg6, abi_long arg7,
+ abi_long arg8)
+{
+ return 0;
+}
+
+void syscall_init(void)
+{
+}
--
2.33.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 10/16] bsd-user: Move system call building to os-syscall.c
2022-02-26 17:07 [PATCH v2 00/16] bsd-user: Start upstreaming the system calls Warner Losh
` (8 preceding siblings ...)
2022-02-26 17:07 ` [PATCH v2 09/16] bsd-user/freebsd/os-syscall.c: Move syscall processing here Warner Losh
@ 2022-02-26 17:07 ` Warner Losh
2022-02-26 17:07 ` [PATCH v2 11/16] bsd-user/sycall.c: Now obsolete, remove Warner Losh
` (5 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Warner Losh @ 2022-02-26 17:07 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, arrowd, Kyle Evans, Richard Henderson, def, jrtc27,
Warner Losh, Brad Smith
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/freebsd/meson.build | 1 +
bsd-user/meson.build | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/bsd-user/freebsd/meson.build b/bsd-user/freebsd/meson.build
index 4b69cca7b90..f87c788e846 100644
--- a/bsd-user/freebsd/meson.build
+++ b/bsd-user/freebsd/meson.build
@@ -1,3 +1,4 @@
bsd_user_ss.add(files(
'os-sys.c',
+ 'os-syscall.c',
))
diff --git a/bsd-user/meson.build b/bsd-user/meson.build
index 8380fa44c25..5243122fc56 100644
--- a/bsd-user/meson.build
+++ b/bsd-user/meson.build
@@ -13,7 +13,6 @@ bsd_user_ss.add(files(
'mmap.c',
'signal.c',
'strace.c',
- 'syscall.c',
'uaccess.c',
))
--
2.33.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 11/16] bsd-user/sycall.c: Now obsolete, remove
2022-02-26 17:07 [PATCH v2 00/16] bsd-user: Start upstreaming the system calls Warner Losh
` (9 preceding siblings ...)
2022-02-26 17:07 ` [PATCH v2 10/16] bsd-user: Move system call building to os-syscall.c Warner Losh
@ 2022-02-26 17:07 ` Warner Losh
2022-02-26 17:07 ` [PATCH v2 12/16] bsd-user/freebsd/os-syscall.c: Add get_errno and host_to_target_errno Warner Losh
` (4 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Warner Losh @ 2022-02-26 17:07 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, arrowd, Kyle Evans, Richard Henderson, def, jrtc27,
Warner Losh, Brad Smith
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Kyle Evans <kevans@FreeBSD.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/syscall.c | 516 ---------------------------------------------
1 file changed, 516 deletions(-)
delete mode 100644 bsd-user/syscall.c
diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
deleted file mode 100644
index d3322760f43..00000000000
--- a/bsd-user/syscall.c
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
- * BSD syscalls
- *
- * Copyright (c) 2003 - 2008 Fabrice Bellard
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-#include "qemu/osdep.h"
-#include "qemu/cutils.h"
-#include "qemu/path.h"
-#include <sys/syscall.h>
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <utime.h>
-
-#include "qemu.h"
-#include "qemu-common.h"
-#include "user/syscall-trace.h"
-
-//#define DEBUG
-
-static abi_ulong target_brk;
-static abi_ulong target_original_brk;
-
-abi_long get_errno(abi_long ret)
-{
- if (ret == -1) {
- /* XXX need to translate host -> target errnos here */
- return -(errno);
- }
- return ret;
-}
-
-#define target_to_host_bitmask(x, tbl) (x)
-
-bool is_error(abi_long ret)
-{
- return (abi_ulong)ret >= (abi_ulong)(-4096);
-}
-
-void target_set_brk(abi_ulong new_brk)
-{
- target_original_brk = target_brk = HOST_PAGE_ALIGN(new_brk);
-}
-
-/* do_obreak() must return target errnos. */
-static abi_long do_obreak(abi_ulong new_brk)
-{
- abi_ulong brk_page;
- abi_long mapped_addr;
- int new_alloc_size;
-
- if (!new_brk)
- return 0;
- if (new_brk < target_original_brk)
- return -TARGET_EINVAL;
-
- brk_page = HOST_PAGE_ALIGN(target_brk);
-
- /* If the new brk is less than this, set it and we're done... */
- if (new_brk < brk_page) {
- target_brk = new_brk;
- return 0;
- }
-
- /* We need to allocate more memory after the brk... */
- new_alloc_size = HOST_PAGE_ALIGN(new_brk - brk_page + 1);
- mapped_addr = get_errno(target_mmap(brk_page, new_alloc_size,
- PROT_READ|PROT_WRITE,
- MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0));
-
- if (!is_error(mapped_addr))
- target_brk = new_brk;
- else
- return mapped_addr;
-
- return 0;
-}
-
-#ifdef __FreeBSD__
-/*
- * XXX this uses the undocumented oidfmt interface to find the kind of
- * a requested sysctl, see /sys/kern/kern_sysctl.c:sysctl_sysctl_oidfmt()
- * (this is mostly copied from src/sbin/sysctl/sysctl.c)
- */
-static int
-oidfmt(int *oid, int len, char *fmt, uint32_t *kind)
-{
- int qoid[CTL_MAXNAME+2];
- uint8_t buf[BUFSIZ];
- int i;
- size_t j;
-
- qoid[0] = 0;
- qoid[1] = 4;
- memcpy(qoid + 2, oid, len * sizeof(int));
-
- j = sizeof(buf);
- i = sysctl(qoid, len + 2, buf, &j, 0, 0);
- if (i)
- return i;
-
- if (kind)
- *kind = *(uint32_t *)buf;
-
- if (fmt)
- strcpy(fmt, (char *)(buf + sizeof(uint32_t)));
- return (0);
-}
-
-/*
- * try and convert sysctl return data for the target.
- * XXX doesn't handle CTLTYPE_OPAQUE and CTLTYPE_STRUCT.
- */
-static int sysctl_oldcvt(void *holdp, size_t holdlen, uint32_t kind)
-{
- switch (kind & CTLTYPE) {
- case CTLTYPE_INT:
- case CTLTYPE_UINT:
- *(uint32_t *)holdp = tswap32(*(uint32_t *)holdp);
- break;
-#ifdef TARGET_ABI32
- case CTLTYPE_LONG:
- case CTLTYPE_ULONG:
- *(uint32_t *)holdp = tswap32(*(long *)holdp);
- break;
-#else
- case CTLTYPE_LONG:
- *(uint64_t *)holdp = tswap64(*(long *)holdp);
- break;
- case CTLTYPE_ULONG:
- *(uint64_t *)holdp = tswap64(*(unsigned long *)holdp);
- break;
-#endif
-#ifdef CTLTYPE_U64
- case CTLTYPE_S64:
- case CTLTYPE_U64:
-#else
- case CTLTYPE_QUAD:
-#endif
- *(uint64_t *)holdp = tswap64(*(uint64_t *)holdp);
- break;
- case CTLTYPE_STRING:
- break;
- default:
- /* XXX unhandled */
- return -1;
- }
- return 0;
-}
-
-/* XXX this needs to be emulated on non-FreeBSD hosts... */
-static abi_long do_freebsd_sysctl(abi_ulong namep, int32_t namelen, abi_ulong oldp,
- abi_ulong oldlenp, abi_ulong newp, abi_ulong newlen)
-{
- abi_long ret;
- void *hnamep, *holdp, *hnewp = NULL;
- size_t holdlen;
- abi_ulong oldlen = 0;
- int32_t *snamep = g_malloc(sizeof(int32_t) * namelen), *p, *q, i;
- uint32_t kind = 0;
-
- if (oldlenp)
- get_user_ual(oldlen, oldlenp);
- if (!(hnamep = lock_user(VERIFY_READ, namep, namelen, 1)))
- return -TARGET_EFAULT;
- if (newp && !(hnewp = lock_user(VERIFY_READ, newp, newlen, 1)))
- return -TARGET_EFAULT;
- if (!(holdp = lock_user(VERIFY_WRITE, oldp, oldlen, 0)))
- return -TARGET_EFAULT;
- holdlen = oldlen;
- for (p = hnamep, q = snamep, i = 0; i < namelen; p++, i++)
- *q++ = tswap32(*p);
- oidfmt(snamep, namelen, NULL, &kind);
- /* XXX swap hnewp */
- ret = get_errno(sysctl(snamep, namelen, holdp, &holdlen, hnewp, newlen));
- if (!ret)
- sysctl_oldcvt(holdp, holdlen, kind);
- put_user_ual(holdlen, oldlenp);
- unlock_user(hnamep, namep, 0);
- unlock_user(holdp, oldp, holdlen);
- if (hnewp)
- unlock_user(hnewp, newp, 0);
- g_free(snamep);
- return ret;
-}
-#endif
-
-/* FIXME
- * lock_iovec()/unlock_iovec() have a return code of 0 for success where
- * other lock functions have a return code of 0 for failure.
- */
-static abi_long lock_iovec(int type, struct iovec *vec, abi_ulong target_addr,
- int count, int copy)
-{
- struct target_iovec *target_vec;
- abi_ulong base;
- int i;
-
- target_vec = lock_user(VERIFY_READ, target_addr, count * sizeof(struct target_iovec), 1);
- if (!target_vec)
- return -TARGET_EFAULT;
- for (i = 0;i < count; i++) {
- base = tswapl(target_vec[i].iov_base);
- vec[i].iov_len = tswapl(target_vec[i].iov_len);
- if (vec[i].iov_len != 0) {
- vec[i].iov_base = lock_user(type, base, vec[i].iov_len, copy);
- /* Don't check lock_user return value. We must call writev even
- if a element has invalid base address. */
- } else {
- /* zero length pointer is ignored */
- vec[i].iov_base = NULL;
- }
- }
- unlock_user (target_vec, target_addr, 0);
- return 0;
-}
-
-static abi_long unlock_iovec(struct iovec *vec, abi_ulong target_addr,
- int count, int copy)
-{
- struct target_iovec *target_vec;
- abi_ulong base;
- int i;
-
- target_vec = lock_user(VERIFY_READ, target_addr, count * sizeof(struct target_iovec), 1);
- if (!target_vec)
- return -TARGET_EFAULT;
- for (i = 0;i < count; i++) {
- if (target_vec[i].iov_base) {
- base = tswapl(target_vec[i].iov_base);
- unlock_user(vec[i].iov_base, base, copy ? vec[i].iov_len : 0);
- }
- }
- unlock_user (target_vec, target_addr, 0);
-
- return 0;
-}
-
-/* do_syscall() should always have a single exit point at the end so
- that actions, such as logging of syscall results, can be performed.
- All errnos that do_syscall() returns must be -TARGET_<errcode>. */
-abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
- abi_long arg2, abi_long arg3, abi_long arg4,
- abi_long arg5, abi_long arg6, abi_long arg7,
- abi_long arg8)
-{
- CPUState *cpu = env_cpu(cpu_env);
- abi_long ret;
- void *p;
-
-#ifdef DEBUG
- gemu_log("freebsd syscall %d\n", num);
-#endif
- record_syscall_start(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0);
-
- if (do_strace)
- print_freebsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
-
- switch (num) {
- case TARGET_FREEBSD_NR_exit:
-#ifdef CONFIG_GPROF
- _mcleanup();
-#endif
- gdb_exit(arg1);
- qemu_plugin_user_exit();
- /* XXX: should free thread stack and CPU env */
- _exit(arg1);
- ret = 0; /* avoid warning */
- break;
- case TARGET_FREEBSD_NR_read:
- if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
- goto efault;
- ret = get_errno(read(arg1, p, arg3));
- unlock_user(p, arg2, ret);
- break;
- case TARGET_FREEBSD_NR_write:
- if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
- goto efault;
- ret = get_errno(write(arg1, p, arg3));
- unlock_user(p, arg2, 0);
- break;
- case TARGET_FREEBSD_NR_writev:
- {
- int count = arg3;
- struct iovec *vec;
-
- vec = alloca(count * sizeof(struct iovec));
- if (lock_iovec(VERIFY_READ, vec, arg2, count, 1) < 0)
- goto efault;
- ret = get_errno(writev(arg1, vec, count));
- unlock_iovec(vec, arg2, count, 0);
- }
- break;
- case TARGET_FREEBSD_NR_open:
- if (!(p = lock_user_string(arg1)))
- goto efault;
- ret = get_errno(open(path(p),
- target_to_host_bitmask(arg2, fcntl_flags_tbl),
- arg3));
- unlock_user(p, arg1, 0);
- break;
- case TARGET_FREEBSD_NR_mmap:
- ret = get_errno(target_mmap(arg1, arg2, arg3,
- target_to_host_bitmask(arg4, mmap_flags_tbl),
- arg5,
- arg6));
- break;
- case TARGET_FREEBSD_NR_mprotect:
- ret = get_errno(target_mprotect(arg1, arg2, arg3));
- break;
- case TARGET_FREEBSD_NR_break:
- ret = do_obreak(arg1);
- break;
-#ifdef __FreeBSD__
- case TARGET_FREEBSD_NR___sysctl:
- ret = do_freebsd_sysctl(arg1, arg2, arg3, arg4, arg5, arg6);
- break;
-#endif
- case TARGET_FREEBSD_NR_sysarch:
- ret = do_freebsd_sysarch(cpu_env, arg1, arg2);
- break;
- case TARGET_FREEBSD_NR_syscall:
- case TARGET_FREEBSD_NR___syscall:
- ret = do_freebsd_syscall(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,arg5,arg6,arg7,arg8,0);
- break;
- default:
- ret = get_errno(syscall(num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8));
- break;
- }
- fail:
-#ifdef DEBUG
- gemu_log(" = %ld\n", ret);
-#endif
- if (do_strace)
- print_freebsd_syscall_ret(num, ret);
-
- record_syscall_return(cpu, num, ret);
- return ret;
- efault:
- ret = -TARGET_EFAULT;
- goto fail;
-}
-
-abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1,
- abi_long arg2, abi_long arg3, abi_long arg4,
- abi_long arg5, abi_long arg6)
-{
- CPUState *cpu = env_cpu(cpu_env);
- abi_long ret;
- void *p;
-
-#ifdef DEBUG
- gemu_log("netbsd syscall %d\n", num);
-#endif
-
- record_syscall_start(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0);
-
- if (do_strace)
- print_netbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
-
- switch (num) {
- case TARGET_NETBSD_NR_exit:
-#ifdef CONFIG_GPROF
- _mcleanup();
-#endif
- gdb_exit(arg1);
- qemu_plugin_user_exit();
- /* XXX: should free thread stack and CPU env */
- _exit(arg1);
- ret = 0; /* avoid warning */
- break;
- case TARGET_NETBSD_NR_read:
- if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
- goto efault;
- ret = get_errno(read(arg1, p, arg3));
- unlock_user(p, arg2, ret);
- break;
- case TARGET_NETBSD_NR_write:
- if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
- goto efault;
- ret = get_errno(write(arg1, p, arg3));
- unlock_user(p, arg2, 0);
- break;
- case TARGET_NETBSD_NR_open:
- if (!(p = lock_user_string(arg1)))
- goto efault;
- ret = get_errno(open(path(p),
- target_to_host_bitmask(arg2, fcntl_flags_tbl),
- arg3));
- unlock_user(p, arg1, 0);
- break;
- case TARGET_NETBSD_NR_mmap:
- ret = get_errno(target_mmap(arg1, arg2, arg3,
- target_to_host_bitmask(arg4, mmap_flags_tbl),
- arg5,
- arg6));
- break;
- case TARGET_NETBSD_NR_mprotect:
- ret = get_errno(target_mprotect(arg1, arg2, arg3));
- break;
- case TARGET_NETBSD_NR_syscall:
- case TARGET_NETBSD_NR___syscall:
- ret = do_netbsd_syscall(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,arg5,arg6,0);
- break;
- default:
- ret = syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
- break;
- }
- fail:
-#ifdef DEBUG
- gemu_log(" = %ld\n", ret);
-#endif
- if (do_strace)
- print_netbsd_syscall_ret(num, ret);
-
- record_syscall_return(cpu, num, ret);
- return ret;
- efault:
- ret = -TARGET_EFAULT;
- goto fail;
-}
-
-abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
- abi_long arg2, abi_long arg3, abi_long arg4,
- abi_long arg5, abi_long arg6)
-{
- CPUState *cpu = env_cpu(cpu_env);
- abi_long ret;
- void *p;
-
-#ifdef DEBUG
- gemu_log("openbsd syscall %d\n", num);
-#endif
-
- record_syscall_start(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0);
-
- if (do_strace)
- print_openbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
-
- switch (num) {
- case TARGET_OPENBSD_NR_exit:
-#ifdef CONFIG_GPROF
- _mcleanup();
-#endif
- gdb_exit(arg1);
- qemu_plugin_user_exit();
- /* XXX: should free thread stack and CPU env */
- _exit(arg1);
- ret = 0; /* avoid warning */
- break;
- case TARGET_OPENBSD_NR_read:
- if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
- goto efault;
- ret = get_errno(read(arg1, p, arg3));
- unlock_user(p, arg2, ret);
- break;
- case TARGET_OPENBSD_NR_write:
- if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
- goto efault;
- ret = get_errno(write(arg1, p, arg3));
- unlock_user(p, arg2, 0);
- break;
- case TARGET_OPENBSD_NR_open:
- if (!(p = lock_user_string(arg1)))
- goto efault;
- ret = get_errno(open(path(p),
- target_to_host_bitmask(arg2, fcntl_flags_tbl),
- arg3));
- unlock_user(p, arg1, 0);
- break;
- case TARGET_OPENBSD_NR_mmap:
- ret = get_errno(target_mmap(arg1, arg2, arg3,
- target_to_host_bitmask(arg4, mmap_flags_tbl),
- arg5,
- arg6));
- break;
- case TARGET_OPENBSD_NR_mprotect:
- ret = get_errno(target_mprotect(arg1, arg2, arg3));
- break;
- case TARGET_OPENBSD_NR_syscall:
- case TARGET_OPENBSD_NR___syscall:
- ret = do_openbsd_syscall(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,arg5,arg6,0);
- break;
- default:
- ret = syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
- break;
- }
- fail:
-#ifdef DEBUG
- gemu_log(" = %ld\n", ret);
-#endif
- if (do_strace)
- print_openbsd_syscall_ret(num, ret);
-
- record_syscall_return(cpu, num, ret);
- return ret;
- efault:
- ret = -TARGET_EFAULT;
- goto fail;
-}
-
-void syscall_init(void)
-{
-}
--
2.33.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 12/16] bsd-user/freebsd/os-syscall.c: Add get_errno and host_to_target_errno
2022-02-26 17:07 [PATCH v2 00/16] bsd-user: Start upstreaming the system calls Warner Losh
` (10 preceding siblings ...)
2022-02-26 17:07 ` [PATCH v2 11/16] bsd-user/sycall.c: Now obsolete, remove Warner Losh
@ 2022-02-26 17:07 ` Warner Losh
2022-02-26 17:07 ` [PATCH v2 13/16] bsd-user/bsd-file.h: Implementation details for the filesystem calls Warner Losh
` (3 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Warner Losh @ 2022-02-26 17:07 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, arrowd, Kyle Evans, Richard Henderson, def, jrtc27,
Warner Losh, Brad Smith
Add the helper functions get_errno and host_to_target_errno. get_errno
returns either the system call results, or the -errno when system call
indicates failure by returning -1. Host_to_target_errno returns errno
(since on FreeBSD they are the same on all architectures) along with a
comment about why it's the identity.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Kyle Evans <kevans@FreeBSD.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/freebsd/os-syscall.c | 23 ++++++++++++++++++++++-
bsd-user/qemu.h | 3 ++-
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index fc57e324173..597a41c2f50 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -45,9 +45,30 @@ void target_set_brk(abi_ulong new_brk)
{
}
-bool is_error(abi_long ret)
+/*
+ * errno conversion.
+ */
+abi_long get_errno(abi_long ret)
{
+ if (ret == -1) {
+ return -host_to_target_errno(errno);
+ } else {
+ return ret;
+ }
+}
+int host_to_target_errno(int err)
+{
+ /*
+ * All the BSDs have the property that the error numbers are uniform across
+ * all architectures for a given BSD, though they may vary between different
+ * BSDs.
+ */
+ return err;
+}
+
+bool is_error(abi_long ret)
+{
return (abi_ulong)ret >= (abi_ulong)(-4096);
}
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index e5742bd6c03..56042ddbc5d 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -246,9 +246,10 @@ extern unsigned long target_dflssiz;
extern unsigned long target_maxssiz;
extern unsigned long target_sgrowsiz;
-/* syscall.c */
+/* os-syscall.c */
abi_long get_errno(abi_long ret);
bool is_error(abi_long ret);
+int host_to_target_errno(int err);
/* os-sys.c */
abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2);
--
2.33.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 13/16] bsd-user/bsd-file.h: Implementation details for the filesystem calls
2022-02-26 17:07 [PATCH v2 00/16] bsd-user: Start upstreaming the system calls Warner Losh
` (11 preceding siblings ...)
2022-02-26 17:07 ` [PATCH v2 12/16] bsd-user/freebsd/os-syscall.c: Add get_errno and host_to_target_errno Warner Losh
@ 2022-02-26 17:07 ` Warner Losh
2022-02-27 3:20 ` Richard Henderson
2022-02-26 17:07 ` [PATCH v2 14/16] bsd-user: introduce target.h Warner Losh
` (2 subsequent siblings)
15 siblings, 1 reply; 18+ messages in thread
From: Warner Losh @ 2022-02-26 17:07 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, arrowd, Kyle Evans, Richard Henderson, def, jrtc27,
Warner Losh, Brad Smith
An include file that pulls in all the definitions needed for the file
related system calls. This also includes the host definitions to
implement the system calls and some helper routines to lock/unlock
different aspects of the system call arguments.
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/bsd-file.h | 30 ++++++++++++++++++++++++++++++
bsd-user/freebsd/os-syscall.c | 2 ++
2 files changed, 32 insertions(+)
create mode 100644 bsd-user/bsd-file.h
diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h
new file mode 100644
index 00000000000..f0c3f347ec0
--- /dev/null
+++ b/bsd-user/bsd-file.h
@@ -0,0 +1,30 @@
+/*
+ * file related system call shims and definitions
+ *
+ * Copyright (c) 2013 Stacey D. Son
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BSD_FILE_H_
+#define BSD_FILE_H_
+
+#include "qemu/path.h"
+
+extern struct iovec *lock_iovec(int type, abi_ulong target_addr, int count,
+ int copy);
+extern void unlock_iovec(struct iovec *vec, abi_ulong target_addr, int count,
+ int copy);
+
+#endif /* !BSD_FILE_H_ */
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index 597a41c2f50..a17ff9f6ecc 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -41,6 +41,8 @@
#include "signal-common.h"
#include "user/syscall-trace.h"
+#include "bsd-file.h"
+
void target_set_brk(abi_ulong new_brk)
{
}
--
2.33.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 13/16] bsd-user/bsd-file.h: Implementation details for the filesystem calls
2022-02-26 17:07 ` [PATCH v2 13/16] bsd-user/bsd-file.h: Implementation details for the filesystem calls Warner Losh
@ 2022-02-27 3:20 ` Richard Henderson
0 siblings, 0 replies; 18+ messages in thread
From: Richard Henderson @ 2022-02-27 3:20 UTC (permalink / raw)
To: Warner Losh, qemu-devel
Cc: Peter Maydell, arrowd, Kyle Evans, def, jrtc27, Brad Smith
On 2/26/22 07:07, Warner Losh wrote:
> An include file that pulls in all the definitions needed for the file
> related system calls. This also includes the host definitions to
> implement the system calls and some helper routines to lock/unlock
> different aspects of the system call arguments.
>
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
> bsd-user/bsd-file.h | 30 ++++++++++++++++++++++++++++++
> bsd-user/freebsd/os-syscall.c | 2 ++
> 2 files changed, 32 insertions(+)
> create mode 100644 bsd-user/bsd-file.h
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 14/16] bsd-user: introduce target.h
2022-02-26 17:07 [PATCH v2 00/16] bsd-user: Start upstreaming the system calls Warner Losh
` (12 preceding siblings ...)
2022-02-26 17:07 ` [PATCH v2 13/16] bsd-user/bsd-file.h: Implementation details for the filesystem calls Warner Losh
@ 2022-02-26 17:07 ` Warner Losh
2022-02-26 17:07 ` [PATCH v2 15/16] bsd-user: Define target_arg64 Warner Losh
2022-02-26 17:07 ` [PATCH v2 16/16] bsd-user: Add safe system call macros Warner Losh
15 siblings, 0 replies; 18+ messages in thread
From: Warner Losh @ 2022-02-26 17:07 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, arrowd, Kyle Evans, Richard Henderson, def, jrtc27,
Warner Losh, Brad Smith
Create target.h. This file is intended to be simple and describe basic
things about the architecture. If something is a basic feature of the
architecture, it belongs here. Should we need something that's per-BSD
there will be a target-os.h that will live in the per-bsd directories.
Define regpairs_aligned to reflect whether or not registers are 'paired'
for 64-bit arguments or not. This will be false for all 64-bit targets,
and will be true on those architectures that pair (currently just armv7
and powerpc on FreeBSD 14.x).
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Kyle Evans <kevans@FreeBSD.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/arm/target.h | 21 +++++++++++++++++++++
bsd-user/i386/target.h | 21 +++++++++++++++++++++
bsd-user/qemu.h | 1 +
bsd-user/x86_64/target.h | 21 +++++++++++++++++++++
4 files changed, 64 insertions(+)
create mode 100644 bsd-user/arm/target.h
create mode 100644 bsd-user/i386/target.h
create mode 100644 bsd-user/x86_64/target.h
diff --git a/bsd-user/arm/target.h b/bsd-user/arm/target.h
new file mode 100644
index 00000000000..419c039b68e
--- /dev/null
+++ b/bsd-user/arm/target.h
@@ -0,0 +1,21 @@
+/*
+ * Intel general target stuff that's common to all i386 details
+ *
+ * Copyright (c) 2022 M. Warner Losh <imp@bsdimp.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef TARGET_H
+#define TARGET_H
+
+/*
+ * arm EABI 'lumps' the registers for 64-bit args.
+ */
+static inline bool regpairs_aligned(void *cpu_env)
+{
+ return true;
+}
+
+#endif /* ! TARGET_H */
+
diff --git a/bsd-user/i386/target.h b/bsd-user/i386/target.h
new file mode 100644
index 00000000000..9b9df047a3b
--- /dev/null
+++ b/bsd-user/i386/target.h
@@ -0,0 +1,21 @@
+/*
+ * Intel general target stuff that's common to all i386 details
+ *
+ * Copyright (c) 2022 M. Warner Losh <imp@bsdimp.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef TARGET_ARCH_H
+#define TARGET_ARCH_H
+
+/*
+ * i386 doesn't 'lump' the registers for 64-bit args.
+ */
+static inline bool regpairs_aligned(void *cpu_env)
+{
+ return false;
+}
+
+#endif /* ! TARGET_ARCH_H */
+
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 56042ddbc5d..a9efa807b78 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -35,6 +35,7 @@ extern char **environ;
#include "target_syscall.h"
#include "target_os_vmparam.h"
#include "target_os_signal.h"
+#include "target.h"
#include "exec/gdbstub.h"
/*
diff --git a/bsd-user/x86_64/target.h b/bsd-user/x86_64/target.h
new file mode 100644
index 00000000000..8956631db1d
--- /dev/null
+++ b/bsd-user/x86_64/target.h
@@ -0,0 +1,21 @@
+/*
+ * Intel general target stuff that's common to all x86_64 details
+ *
+ * Copyright (c) 2022 M. Warner Losh <imp@bsdimp.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef TARGET_H
+#define TARGET_H
+
+/*
+ * x86 doesn't 'lump' the registers for 64-bit args, all args are 64 bits.
+ */
+static inline bool regpairs_aligned(void *cpu_env)
+{
+ return false;
+}
+
+#endif /* ! TARGET_H */
+
--
2.33.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 15/16] bsd-user: Define target_arg64
2022-02-26 17:07 [PATCH v2 00/16] bsd-user: Start upstreaming the system calls Warner Losh
` (13 preceding siblings ...)
2022-02-26 17:07 ` [PATCH v2 14/16] bsd-user: introduce target.h Warner Losh
@ 2022-02-26 17:07 ` Warner Losh
2022-02-26 17:07 ` [PATCH v2 16/16] bsd-user: Add safe system call macros Warner Losh
15 siblings, 0 replies; 18+ messages in thread
From: Warner Losh @ 2022-02-26 17:07 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Stacey Son, arrowd, Kyle Evans, Richard Henderson,
def, jrtc27, Warner Losh, Brad Smith
target_arg64 is a generic way to extract 64-bits from a pair of
arguments. On 32-bit platforms, it returns them joined together as
appropriate. On 64-bit platforms, it returns the first arg because it's
already 64-bits.
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Kyle Evans <kevans@FreeBSD.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/qemu.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index a9efa807b78..af272c2a802 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -462,6 +462,19 @@ static inline void *lock_user_string(abi_ulong guest_addr)
#define unlock_user_struct(host_ptr, guest_addr, copy) \
unlock_user(host_ptr, guest_addr, (copy) ? sizeof(*host_ptr) : 0)
+static inline uint64_t target_arg64(uint32_t word0, uint32_t word1)
+{
+#if TARGET_ABI_BITS == 32
+#ifdef TARGET_WORDS_BIGENDIAN
+ return ((uint64_t)word0 << 32) | word1;
+#else
+ return ((uint64_t)word1 << 32) | word0;
+#endif
+#else /* TARGET_ABI_BITS != 32 */
+ return word0;
+#endif /* TARGET_ABI_BITS != 32 */
+}
+
#include <pthread.h>
#include "user/safe-syscall.h"
--
2.33.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 16/16] bsd-user: Add safe system call macros
2022-02-26 17:07 [PATCH v2 00/16] bsd-user: Start upstreaming the system calls Warner Losh
` (14 preceding siblings ...)
2022-02-26 17:07 ` [PATCH v2 15/16] bsd-user: Define target_arg64 Warner Losh
@ 2022-02-26 17:07 ` Warner Losh
15 siblings, 0 replies; 18+ messages in thread
From: Warner Losh @ 2022-02-26 17:07 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, arrowd, Kyle Evans, Richard Henderson, def, jrtc27,
Warner Losh, Brad Smith
Add a series of macros to create system call macros that go via the
safe_syscall path.
Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/syscall_defs.h | 47 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h
index 62b472b990b..c3bf14f38f4 100644
--- a/bsd-user/syscall_defs.h
+++ b/bsd-user/syscall_defs.h
@@ -179,4 +179,51 @@ struct target_freebsd__wrusage {
struct target_freebsd_rusage wru_children;
};
+#define safe_syscall0(type, name) \
+type safe_##name(void) \
+{ \
+ return safe_syscall(SYS_##name); \
+}
+
+#define safe_syscall1(type, name, type1, arg1) \
+type safe_##name(type1 arg1) \
+{ \
+ return safe_syscall(SYS_##name, arg1); \
+}
+
+#define safe_syscall2(type, name, type1, arg1, type2, arg2) \
+type safe_##name(type1 arg1, type2 arg2) \
+{ \
+ return safe_syscall(SYS_##name, arg1, arg2); \
+}
+
+#define safe_syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \
+type safe_##name(type1 arg1, type2 arg2, type3 arg3) \
+{ \
+ return safe_syscall(SYS_##name, arg1, arg2, arg3); \
+}
+
+#define safe_syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \
+ type4, arg4) \
+type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
+{ \
+ return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4); \
+}
+
+#define safe_syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \
+ type4, arg4, type5, arg5) \
+type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
+ type5 arg5) \
+{ \
+ return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5); \
+}
+
+#define safe_syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \
+ type4, arg4, type5, arg5, type6, arg6) \
+type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
+ type5 arg5, type6 arg6) \
+{ \
+ return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5, arg6); \
+}
+
#endif /* ! _SYSCALL_DEFS_H_ */
--
2.33.1
^ permalink raw reply related [flat|nested] 18+ messages in thread