*-user: simplify safe signal handling
Subsystems (2)
The following changes since commit 212a33d3b0c65ae2583bb1d06cb140cd0890894c:
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2021-12-19 16:36:10 -0800)
are available in the Git repository at:
https://gitlab.com/rth7680/qemu.git tags/pull-user-20211220
for you to fetch changes up to 3363615a65af8a09d8adbd19ed3ae6b52f26ca7a:
meson: Move bsd_user_ss to bsd-user/ (2021-12-20 10:13:43 -0800)
----------------------------------------------------------------
Move errno processing from safe_syscall() to safe_syscall_base(). Move safe_syscall() from linux-user to common-user.
Add FreeBSD support to safe_syscall_base().
Tidy top-level meson.build wrt {bsd,linux}-user.
----------------------------------------------------------------
Richard Henderson (15):
linux-user: Untabify all safe-syscall.inc.S
linux-user: Move syscall error detection into safe_syscall_base linux-user/host/mips: Add safe-syscall.inc.S linux-user/host/sparc64: Add safe-syscall.inc.S
linux-user: Remove HAVE_SAFE_SYSCALL and hostdep.h
linux-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS
bsd-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS
linux-user: Rename TARGET_QEMU_ESIGRETURN to QEMU_ESIGRETURN
linux-user: Create special-errno.h
bsd-user: Create special-errno.h
common-user: Move safe-syscall.* from linux-user
common-user: Adjust system call return on FreeBSD
linux-user: Move thunk.c from top-level
meson: Move linux_user_ss to linux-user/
meson: Move bsd_user_ss to bsd-user/
meson.build | 23 +++-
bsd-user/errno_defs.h | 6 +-
bsd-user/special-errno.h | 24 ++++
{linux-user => include/user}/safe-syscall.h | 37 ++----
linux-user/cpu_loop-common.h | 1 +
linux-user/generic/target_errno_defs.h | 17 ---
linux-user/host/aarch64/hostdep.h | 18 ---
linux-user/host/arm/hostdep.h | 18 ---
linux-user/host/i386/hostdep.h | 18 ---
linux-user/host/ia64/hostdep.h | 15 ---
linux-user/host/mips/hostdep.h | 15 ---
linux-user/host/ppc/hostdep.h | 15 ---
linux-user/host/ppc64/hostdep.h | 18 ---
linux-user/host/riscv/hostdep.h | 14 --
linux-user/host/s390/hostdep.h | 15 ---
linux-user/host/s390x/hostdep.h | 18 ---
linux-user/host/sparc/hostdep.h | 15 ---
linux-user/host/sparc64/hostdep.h | 15 ---
linux-user/host/x32/hostdep.h | 15 ---
linux-user/host/x86_64/hostdep.h | 18 ---
linux-user/signal-common.h | 4 +-
linux-user/special-errno.h | 32 +++++
linux-user/user-internals.h | 1 -
common-user/safe-syscall-error.c | 25 ++++
linux-user/aarch64/cpu_loop.c | 4 +-
linux-user/aarch64/signal.c | 4 +-
linux-user/alpha/cpu_loop.c | 4 +-
linux-user/alpha/signal.c | 8 +-
linux-user/arm/cpu_loop.c | 4 +-
linux-user/arm/signal.c | 8 +-
linux-user/cris/cpu_loop.c | 4 +-
linux-user/cris/signal.c | 4 +-
linux-user/hexagon/cpu_loop.c | 4 +-
linux-user/hexagon/signal.c | 2 +-
linux-user/hppa/cpu_loop.c | 4 +-
linux-user/hppa/signal.c | 4 +-
linux-user/i386/cpu_loop.c | 12 +-
linux-user/i386/signal.c | 8 +-
linux-user/m68k/cpu_loop.c | 4 +-
linux-user/m68k/signal.c | 8 +-
linux-user/microblaze/cpu_loop.c | 4 +-
linux-user/microblaze/signal.c | 4 +-
linux-user/mips/cpu_loop.c | 4 +-
linux-user/mips/signal.c | 8 +-
linux-user/openrisc/cpu_loop.c | 4 +-
linux-user/ppc/cpu_loop.c | 4 +-
linux-user/ppc/signal.c | 10 +-
linux-user/riscv/cpu_loop.c | 4 +-
linux-user/riscv/signal.c | 2 +-
linux-user/s390x/cpu_loop.c | 4 +-
linux-user/s390x/signal.c | 8 +-
linux-user/sh4/cpu_loop.c | 4 +-
linux-user/sh4/signal.c | 8 +-
linux-user/signal.c | 10 +-
linux-user/sparc/cpu_loop.c | 2 +-
linux-user/sparc/signal.c | 8 +-
linux-user/syscall.c | 21 +--
thunk.c => linux-user/thunk.c | 0
linux-user/xtensa/cpu_loop.c | 4 +-
linux-user/xtensa/signal.c | 4 +-
MAINTAINERS | 3 +-
bsd-user/meson.build | 6 +
common-user/host/aarch64/safe-syscall.inc.S | 88 ++++++++++++
common-user/host/arm/safe-syscall.inc.S | 108 +++++++++++++++
common-user/host/i386/safe-syscall.inc.S | 126 ++++++++++++++++++
common-user/host/mips/safe-syscall.inc.S | 148 +++++++++++++++++++++
common-user/host/ppc64/safe-syscall.inc.S | 94 +++++++++++++
common-user/host/riscv/safe-syscall.inc.S | 79 +++++++++++
common-user/host/s390x/safe-syscall.inc.S | 98 ++++++++++++++
common-user/host/sparc64/safe-syscall.inc.S | 89 +++++++++++++
.../host/x86_64/safe-syscall.inc.S | 44 +++---
common-user/meson.build | 6 +
{linux-user => common-user}/safe-syscall.S | 5 +-
linux-user/host/aarch64/safe-syscall.inc.S | 75 -----------
linux-user/host/arm/safe-syscall.inc.S | 90 -------------
linux-user/host/i386/safe-syscall.inc.S | 100 --------------
linux-user/host/ppc64/safe-syscall.inc.S | 96 -------------
linux-user/host/riscv/safe-syscall.inc.S | 77 -----------
linux-user/host/s390x/safe-syscall.inc.S | 90 -------------
linux-user/meson.build | 9 +-
80 files changed, 1099 insertions(+), 932 deletions(-)
create mode 100644 bsd-user/special-errno.h
rename {linux-user => include/user}/safe-syscall.h (83%)
delete mode 100644 linux-user/host/aarch64/hostdep.h
delete mode 100644 linux-user/host/arm/hostdep.h
delete mode 100644 linux-user/host/i386/hostdep.h
delete mode 100644 linux-user/host/ia64/hostdep.h
delete mode 100644 linux-user/host/mips/hostdep.h
delete mode 100644 linux-user/host/ppc/hostdep.h
delete mode 100644 linux-user/host/ppc64/hostdep.h
delete mode 100644 linux-user/host/riscv/hostdep.h
delete mode 100644 linux-user/host/s390/hostdep.h
delete mode 100644 linux-user/host/s390x/hostdep.h
delete mode 100644 linux-user/host/sparc/hostdep.h
delete mode 100644 linux-user/host/sparc64/hostdep.h
delete mode 100644 linux-user/host/x32/hostdep.h
delete mode 100644 linux-user/host/x86_64/hostdep.h
create mode 100644 linux-user/special-errno.h
create mode 100644 common-user/safe-syscall-error.c
rename thunk.c => linux-user/thunk.c (100%)
create mode 100644 common-user/host/aarch64/safe-syscall.inc.S
create mode 100644 common-user/host/arm/safe-syscall.inc.S
create mode 100644 common-user/host/i386/safe-syscall.inc.S
create mode 100644 common-user/host/mips/safe-syscall.inc.S
create mode 100644 common-user/host/ppc64/safe-syscall.inc.S
create mode 100644 common-user/host/riscv/safe-syscall.inc.S
create mode 100644 common-user/host/s390x/safe-syscall.inc.S
create mode 100644 common-user/host/sparc64/safe-syscall.inc.S
rename {linux-user => common-user}/host/x86_64/safe-syscall.inc.S (81%)
create mode 100644 common-user/meson.build
rename {linux-user => common-user}/safe-syscall.S (91%)
delete mode 100644 linux-user/host/aarch64/safe-syscall.inc.S
delete mode 100644 linux-user/host/arm/safe-syscall.inc.S
delete mode 100644 linux-user/host/i386/safe-syscall.inc.S
delete mode 100644 linux-user/host/ppc64/safe-syscall.inc.S
delete mode 100644 linux-user/host/riscv/safe-syscall.inc.S
delete mode 100644 linux-user/host/s390x/safe-syscall.inc.S[PULL 07/15] bsd-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS
This value is fully internal to qemu, and so is not a TARGET define. We use this as an extra marker for both host and target errno.
--- bsd-user/errno_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
bsd-user/errno_defs.h +1 -1
@@ -151,6 +151,6 @@/* Internal errors: */ #define TARGET_EJUSTRETURN 254/* Just return without modifing regs */ #define TARGET_ERESTART 255/* Restart syscall */ -#define TARGET_ERESTARTSYS TARGET_ERESTART/* Linux compat */ +#define QEMU_ERESTARTSYS TARGET_ERESTART#endif /* ! _ERRNO_DEFS_H_ */
Signature · 1 line
2.25.1
[PULL 04/15] linux-user/host/sparc64: Add safe-syscall.inc.S
In reply to Richard Henderson--- linux-user/host/sparc64/hostdep.h | 3 + linux-user/host/sparc64/safe-syscall.inc.S | 89 ++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 linux-user/host/sparc64/safe-syscall.inc.S
linux-user/host/sparc64/hostdep.h +3 -0
@@ -12,4 +12,7 @@#ifndef SPARC64_HOSTDEP_H #define SPARC64_HOSTDEP_H +/* We have a safe-syscall.inc.S */ +#define HAVE_SAFE_SYSCALL +#endif
linux-user/host/sparc64/safe-syscall.inc.S new file +89 -0
89 lines not on this page · raw message
Signature · 1 line
2.25.1
[PULL 03/15] linux-user/host/mips: Add safe-syscall.inc.S
In reply to Richard Henderson--- linux-user/host/mips/hostdep.h | 3 + linux-user/host/mips/safe-syscall.inc.S | 148 ++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 linux-user/host/mips/safe-syscall.inc.S
linux-user/host/mips/hostdep.h +3 -0
@@ -12,4 +12,7 @@#ifndef MIPS_HOSTDEP_H #define MIPS_HOSTDEP_H +/* We have a safe-syscall.inc.S */ +#define HAVE_SAFE_SYSCALL +#endif
linux-user/host/mips/safe-syscall.inc.S new file +148 -0
148 lines not on this page · raw message
Signature · 1 line
2.25.1
[PULL 01/15] linux-user: Untabify all safe-syscall.inc.S
In reply to Richard Henderson--- linux-user/host/aarch64/safe-syscall.inc.S | 110 +++++++------- linux-user/host/arm/safe-syscall.inc.S | 134 ++++++++--------- linux-user/host/i386/safe-syscall.inc.S | 158 ++++++++++----------- linux-user/host/ppc64/safe-syscall.inc.S | 134 ++++++++--------- linux-user/host/riscv/safe-syscall.inc.S | 114 +++++++-------- linux-user/host/s390x/safe-syscall.inc.S | 140 +++++++++--------- linux-user/host/x86_64/safe-syscall.inc.S | 2 +- 7 files changed, 396 insertions(+), 396 deletions(-)
linux-user/host/aarch64/safe-syscall.inc.S +55 -55
@@ -10,66 +10,66 @@ * See the COPYING file in the top-level directory. */ - .global safe_syscall_base - .global safe_syscall_start - .global safe_syscall_end - .type safe_syscall_base, #function - .type safe_syscall_start, #function - .type safe_syscall_end, #function + .global safe_syscall_base + .global safe_syscall_start + .global safe_syscall_end + .type safe_syscall_base, #function + .type safe_syscall_start, #function + .type safe_syscall_end, #function - /* This is the entry point for making a system call. The calling - * convention here is that of a C varargs function with the - * first argument an 'int *' to the signal_pending flag, the - * second one the system call number (as a 'long'), and all further - * arguments being syscall arguments (also 'long'). - * We return a long which is the syscall's return value, which - * may be negative-errno on failure. Conversion to the - * -1-and-errno-set convention is done by the calling wrapper. - */ + /* This is the entry point for making a system call. The calling + * convention here is that of a C varargs function with the + * first argument an 'int *' to the signal_pending flag, the + * second one the system call number (as a 'long'), and all further + * arguments being syscall arguments (also 'long'). + * We return a long which is the syscall's return value, which + * may be negative-errno on failure. Conversion to the + * -1-and-errno-set convention is done by the calling wrapper. + */ safe_syscall_base: - .cfi_startproc - /* The syscall calling convention isn't the same as the - * C one: - * we enter with x0 == *signal_pending - * x1 == syscall number - * x2 ... x7, (stack) == syscall arguments - * and return the result in x0 - * and the syscall instruction needs - * x8 == syscall number - * x0 ... x6 == syscall arguments - * and returns the result in x0 - * Shuffle everything around appropriately. - */ - mov x9, x0 /* signal_pending pointer */ - mov x8, x1 /* syscall number */ - mov x0, x2 /* syscall arguments */ - mov x1, x3 - mov x2, x4 - mov x3, x5 - mov x4, x6 - mov x5, x7 - ldr x6, [sp] + .cfi_startproc + /* The syscall calling convention isn't the same as the + * C one: + * we enter with x0 == *signal_pending + * x1 == syscall number + * x2 ... x7, (stack) == syscall arguments + * and return the result in x0 + * and the syscall instruction needs + * x8 == syscall number + * x0 ... x6 == syscall arguments + * and returns the result in x0 + * Shuffle everything around appropriately. + */ + mov x9, x0 /* signal_pending pointer */ + mov x8, x1 /* syscall number */ + mov x0, x2 /* syscall arguments */ + mov x1, x3 + mov x2, x4 + mov x3, x5 + mov x4, x6 + mov x5, x7 + ldr x6, [sp] - /* This next sequence of code works in conjunction with the - * rewind_if_safe_syscall_function(). If a signal is taken - * and the interrupted PC is anywhere between 'safe_syscall_start' - * and 'safe_syscall_end' then we rewind it to 'safe_syscall_start'. - * The code sequence must therefore be able to cope with this, and - * the syscall instruction must be the final one in the sequence. - */ + /* This next sequence of code works in conjunction with the + * rewind_if_safe_syscall_function(). If a signal is taken + * and the interrupted PC is anywhere between 'safe_syscall_start' + * and 'safe_syscall_end' then we rewind it to 'safe_syscall_start'. + * The code sequence must therefore be able to cope with this, and + * the syscall instruction must be the final one in the sequence. + */ safe_syscall_start: - /* if signal_pending is non-zero, don't do the call */ - ldr w10, [x9] - cbnz w10, 0f - svc 0x0 + /* if signal_pending is non-zero, don't do the call */ + ldr w10, [x9] + cbnz w10, 0f + svc 0x0 safe_syscall_end: - /* code path for having successfully executed the syscall */ - ret + /* code path for having successfully executed the syscall */ + ret 0: - /* code path when we didn't execute the syscall */ - mov x0, #-TARGET_ERESTARTSYS - ret - .cfi_endproc + /* code path when we didn't execute the syscall */ + mov x0, #-TARGET_ERESTARTSYS + ret + .cfi_endproc - .size safe_syscall_base, .-safe_syscall_base + .size safe_syscall_base, .-safe_syscall_base
linux-user/host/arm/safe-syscall.inc.S +67 -67
148 lines not on this page · raw message
linux-user/host/i386/safe-syscall.inc.S +79 -79
170 lines not on this page · raw message
linux-user/host/ppc64/safe-syscall.inc.S +67 -67
154 lines not on this page · raw message
linux-user/host/riscv/safe-syscall.inc.S +57 -57
125 lines not on this page · raw message
linux-user/host/s390x/safe-syscall.inc.S +70 -70
151 lines not on this page · raw message
linux-user/host/x86_64/safe-syscall.inc.S +1 -1
@@ -67,7 +67,7 @@ safe_syscall_base: */ safe_syscall_start: /* if signal_pending is non-zero, don't do the call */ - cmpl $0, (%rbp) + cmpl $0, (%rbp) jnz 1f syscall safe_syscall_end:
Signature · 1 line
2.25.1
[PULL 08/15] linux-user: Rename TARGET_QEMU_ESIGRETURN to QEMU_ESIGRETURN
In reply to Richard HendersonThis value is fully internal to qemu, and so is not a TARGET define.
--- linux-user/generic/target_errno_defs.h | 2 +- linux-user/aarch64/cpu_loop.c | 2 +- linux-user/aarch64/signal.c | 4 ++-- linux-user/alpha/cpu_loop.c | 2 +- linux-user/alpha/signal.c | 8 ++++---- linux-user/arm/cpu_loop.c | 2 +- linux-user/arm/signal.c | 8 ++++---- linux-user/cris/cpu_loop.c | 2 +- linux-user/cris/signal.c | 4 ++-- linux-user/hexagon/cpu_loop.c | 2 +- linux-user/hexagon/signal.c | 2 +- linux-user/hppa/cpu_loop.c | 2 +- linux-user/hppa/signal.c | 4 ++-- linux-user/i386/cpu_loop.c | 6 +++--- linux-user/i386/signal.c | 8 ++++---- linux-user/m68k/cpu_loop.c | 2 +- linux-user/m68k/signal.c | 8 ++++---- linux-user/microblaze/cpu_loop.c | 2 +- linux-user/microblaze/signal.c | 4 ++-- linux-user/mips/cpu_loop.c | 2 +- linux-user/mips/signal.c | 8 ++++---- linux-user/openrisc/cpu_loop.c | 2 +- linux-user/ppc/cpu_loop.c | 2 +- linux-user/ppc/signal.c | 10 +++++----- linux-user/riscv/cpu_loop.c | 2 +- linux-user/riscv/signal.c | 2 +- linux-user/s390x/cpu_loop.c | 2 +- linux-user/s390x/signal.c | 8 ++++---- linux-user/sh4/cpu_loop.c | 2 +- linux-user/sh4/signal.c | 8 ++++---- linux-user/sparc/cpu_loop.c | 2 +- linux-user/sparc/signal.c | 8 ++++---- linux-user/syscall.c | 2 +- linux-user/xtensa/cpu_loop.c | 2 +- linux-user/xtensa/signal.c | 4 ++-- 35 files changed, 70 insertions(+), 70 deletions(-)
linux-user/generic/target_errno_defs.h +1 -1
@@ -162,6 +162,6 @@* ERESTART_NOINTR (which is kernel internal) to guarantee that we won't * clash with a valid guest errno now or in the future. */ -#define TARGET_QEMU_ESIGRETURN 513/* Return from signal */ +#define QEMU_ESIGRETURN 513/* Return from signal */ #endif
linux-user/aarch64/cpu_loop.c +1 -1
@@ -101,7 +101,7 @@ void cpu_loop(CPUARMState *env) 0, 0);if (ret == -QEMU_ERESTARTSYS ) { env->pc -=4 ; - }else if (ret != -TARGET_QEMU_ESIGRETURN ) { + }else if (ret != -QEMU_ESIGRETURN ) { env->xregs[0 ] = ret; }break ;
linux-user/aarch64/signal.c +2 -2
@@ -556,12 +556,12 @@ long do_rt_sigreturn(CPUARMState *env)target_restore_altstack (&frame->uc.tuc_stack, env);unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:unlock_user_struct (frame, frame_addr,0 );force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }long do_sigreturn (CPUARMState *env)
linux-user/alpha/cpu_loop.c +1 -1
@@ -102,7 +102,7 @@ void cpu_loop(CPUAlphaState *env) env->pc -=4 ;break ; } -if (sysret == -TARGET_QEMU_ESIGRETURN ) { +if (sysret == -QEMU_ESIGRETURN ) {break ; }/* Syscall writes 0 to V0 to bypass error check, similar
linux-user/alpha/signal.c +4 -4
@@ -225,11 +225,11 @@ long do_sigreturn(CPUAlphaState *env)restore_sigcontext (env, sc);unlock_user_struct (sc, sc_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }long do_rt_sigreturn (CPUAlphaState *env)
@@ -249,13 +249,13 @@ long do_rt_sigreturn(CPUAlphaState *env)target_restore_altstack (&frame->uc.tuc_stack, env);unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:unlock_user_struct (frame, frame_addr,0 );force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }void setup_sigtramp (abi_ulong sigtramp_page)
linux-user/arm/cpu_loop.c +1 -1
@@ -409,7 +409,7 @@ void cpu_loop(CPUARMState *env) 0, 0);if (ret == -QEMU_ERESTARTSYS ) { env->regs[15 ] -= env->thumb ?2 :4 ; - }else if (ret != -TARGET_QEMU_ESIGRETURN ) { + }else if (ret != -QEMU_ESIGRETURN ) { env->regs[0 ] = ret; } }
linux-user/arm/signal.c +4 -4
@@ -511,12 +511,12 @@ long do_sigreturn(CPUARMState *env) }unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:unlock_user_struct (frame, frame_addr,0 );force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }long do_rt_sigreturn (CPUARMState *env)
@@ -546,12 +546,12 @@ long do_rt_sigreturn(CPUARMState *env) }unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:unlock_user_struct (frame, frame_addr,0 );force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }/*
linux-user/cris/cpu_loop.c +1 -1
@@ -52,7 +52,7 @@ void cpu_loop(CPUCRISState *env) 0, 0);if (ret == -QEMU_ERESTARTSYS ) { env->pc -=2 ; - }else if (ret != -TARGET_QEMU_ESIGRETURN ) { + }else if (ret != -QEMU_ESIGRETURN ) { env->regs[10 ] = ret; }break ;
linux-user/cris/signal.c +2 -2
@@ -177,10 +177,10 @@ long do_sigreturn(CPUCRISState *env)restore_sigcontext (&frame->sc, env);unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }long do_rt_sigreturn (CPUCRISState *env)
linux-user/hexagon/cpu_loop.c +1 -1
@@ -57,7 +57,7 @@ void cpu_loop(CPUHexagonState *env) 0, 0);if (ret == -QEMU_ERESTARTSYS ) { env->gpr[HEX_REG_PC ] -=4 ; - }else if (ret != -TARGET_QEMU_ESIGRETURN ) { + }else if (ret != -QEMU_ESIGRETURN ) { env->gpr[0 ] = ret; }break ;
linux-user/hexagon/signal.c +1 -1
@@ -268,7 +268,7 @@ long do_rt_sigreturn(CPUHexagonState *env)target_restore_altstack (&frame->uc.uc_stack, env);unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:unlock_user_struct (frame, frame_addr,0 );
linux-user/hppa/cpu_loop.c +1 -1
@@ -134,7 +134,7 @@ void cpu_loop(CPUHPPAState *env) env->iaoq_b = env->gr[31 ] +4 ;break ;case -QEMU_ERESTARTSYS : -case -TARGET_QEMU_ESIGRETURN : +case -QEMU_ESIGRETURN :break ; }break ;
linux-user/hppa/signal.c +2 -2
@@ -191,9 +191,9 @@ long do_rt_sigreturn(CPUArchState *env)target_restore_altstack (&frame->uc.tuc_stack, env);unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }
linux-user/i386/cpu_loop.c +3 -3
@@ -181,7 +181,7 @@ static void emulate_vsyscall(CPUX86State *env) env->regs[R_EDX ], env->regs[10 ], env->regs[8 ], env->regs[9], 0, 0);g_assert (ret != -QEMU_ERESTARTSYS ); -g_assert (ret != -TARGET_QEMU_ESIGRETURN ); +g_assert (ret != -QEMU_ESIGRETURN );if (ret == -TARGET_EFAULT ) { goto sigsegv; }
@@ -225,7 +225,7 @@ void cpu_loop(CPUX86State *env) 0, 0);if (ret == -QEMU_ERESTARTSYS ) { env->eip -=2 ; - }else if (ret != -TARGET_QEMU_ESIGRETURN ) { + }else if (ret != -QEMU_ESIGRETURN ) { env->regs[R_EAX ] = ret; }break ;
@@ -243,7 +243,7 @@ void cpu_loop(CPUX86State *env) 0, 0);if (ret == -QEMU_ERESTARTSYS ) { env->eip -=2 ; - }else if (ret != -TARGET_QEMU_ESIGRETURN ) { + }else if (ret != -QEMU_ESIGRETURN ) { env->regs[R_EAX ] = ret; }break ;
linux-user/i386/signal.c +4 -4
@@ -559,12 +559,12 @@ long do_sigreturn(CPUX86State *env)if (restore_sigcontext (env, &frame->sc)) goto badframe;unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:unlock_user_struct (frame, frame_addr,0 );force_sig (TARGET_SIGSEGV ); - return -TARGET_QEMU_ESIGRETURN; + return -QEMU_ESIGRETURN; }#endif
@@ -588,12 +588,12 @@ long do_rt_sigreturn(CPUX86State *env)target_restore_altstack (&frame->uc.tuc_stack, env);unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:unlock_user_struct (frame, frame_addr,0 );force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }#ifndef TARGET_X86_64
linux-user/m68k/cpu_loop.c +1 -1
@@ -82,7 +82,7 @@ void cpu_loop(CPUM68KState *env) 0, 0);if (ret == -QEMU_ERESTARTSYS ) { env->pc -=2 ; - }else if (ret != -TARGET_QEMU_ESIGRETURN ) { + }else if (ret != -QEMU_ESIGRETURN ) { env->dregs[0 ] = ret; } }
linux-user/m68k/signal.c +4 -4
@@ -353,11 +353,11 @@ long do_sigreturn(CPUM68KState *env)restore_sigcontext (env, &frame->sc);unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }long do_rt_sigreturn (CPUM68KState *env)
@@ -381,12 +381,12 @@ long do_rt_sigreturn(CPUM68KState *env)target_restore_altstack (&frame->uc.tuc_stack, env);unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:unlock_user_struct (frame, frame_addr,0 );force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }void setup_sigtramp (abi_ulong sigtramp_page)
linux-user/microblaze/cpu_loop.c +1 -1
@@ -56,7 +56,7 @@ void cpu_loop(CPUMBState *env)if (ret == -QEMU_ERESTARTSYS ) {/* Wind back to before the syscall. */ env->pc -=4 ; - }else if (ret != -TARGET_QEMU_ESIGRETURN ) { + }else if (ret != -QEMU_ESIGRETURN ) { env->regs[3 ] = ret; }/* All syscall exits result in guest r14 being equal to the
linux-user/microblaze/signal.c +2 -2
@@ -207,12 +207,12 @@ long do_rt_sigreturn(CPUMBState *env)target_restore_altstack (&frame->uc.tuc_stack, env);unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:unlock_user_struct (frame, frame_addr,0 );force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }void setup_sigtramp (abi_ulong sigtramp_page)
linux-user/mips/cpu_loop.c +1 -1
@@ -145,7 +145,7 @@ done_syscall: env->active_tc.PC -=4 ;break ; } -if (ret == -TARGET_QEMU_ESIGRETURN ) { +if (ret == -QEMU_ESIGRETURN ) {/* Returning from a successful sigreturn syscall. Avoid clobbering register state. */ break ;
linux-user/mips/signal.c +4 -4
@@ -281,11 +281,11 @@ long do_sigreturn(CPUMIPSState *regs)/* I am not sure this is right, but it seems to work * maybe a problem with nested signals ? */ regs->CP0_EPC =0 ; -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:force_sig (TARGET_SIGSEGV ); - return -TARGET_QEMU_ESIGRETURN; + return -QEMU_ESIGRETURN; }# endif /* O32 */
@@ -371,11 +371,11 @@ long do_rt_sigreturn(CPUMIPSState *env)/* I am not sure this is right, but it seems to work * maybe a problem with nested signals ? */ env->CP0_EPC =0 ; -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }void setup_sigtramp (abi_ulong sigtramp_page)
linux-user/openrisc/cpu_loop.c +1 -1
@@ -50,7 +50,7 @@ void cpu_loop(CPUOpenRISCState *env) cpu_get_gpr(env, 8), 0, 0);if (ret == -QEMU_ERESTARTSYS ) { env->pc -=4 ; - }else if (ret != -TARGET_QEMU_ESIGRETURN ) { + }else if (ret != -QEMU_ESIGRETURN ) {cpu_set_gpr (env,11 , ret); }break ;
linux-user/ppc/cpu_loop.c +1 -1
@@ -432,7 +432,7 @@ void cpu_loop(CPUPPCState *env) env->nip -=4 ;break ; } -if (ret == (target_ulong)(-TARGET_QEMU_ESIGRETURN )) { +if (ret == (target_ulong)(-QEMU_ESIGRETURN )) {/* Returning from a successful sigreturn syscall. Avoid corrupting register state. */ break ;
linux-user/ppc/signal.c +5 -5
@@ -591,13 +591,13 @@ long do_sigreturn(CPUPPCState *env)unlock_user_struct (sr, sr_addr,1 );unlock_user_struct (sc, sc_addr,1 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; sigsegv:unlock_user_struct (sr, sr_addr,1 );unlock_user_struct (sc, sc_addr,1 );force_sig (TARGET_SIGSEGV ); - return -TARGET_QEMU_ESIGRETURN; + return -QEMU_ESIGRETURN; }#endif /* !defined(TARGET_PPC64) */
@@ -646,12 +646,12 @@ long do_rt_sigreturn(CPUPPCState *env)target_restore_altstack (&rt_sf->uc.tuc_stack, env);unlock_user_struct (rt_sf, rt_sf_addr,1 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; sigsegv:unlock_user_struct (rt_sf, rt_sf_addr,1 );force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }/* This syscall implements {get,set,swap}context for userland. */
@@ -704,7 +704,7 @@ abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx,/* We cannot return to a partially updated context. */ force_sig (TARGET_SIGSEGV ); } -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }return 0 ;
linux-user/riscv/cpu_loop.c +1 -1
@@ -71,7 +71,7 @@ void cpu_loop(CPURISCVState *env) }if (ret == -QEMU_ERESTARTSYS ) { env->pc -=4 ; - }else if (ret != -TARGET_QEMU_ESIGRETURN ) { + }else if (ret != -QEMU_ESIGRETURN ) { env->gpr[xA0] = ret; }if (cs->singlestep_enabled) {
linux-user/riscv/signal.c +1 -1
@@ -188,7 +188,7 @@ long do_rt_sigreturn(CPURISCVState *env)target_restore_altstack (&frame->uc.uc_stack, env);unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:unlock_user_struct (frame, frame_addr,0 );
linux-user/s390x/cpu_loop.c +1 -1
@@ -85,7 +85,7 @@ void cpu_loop(CPUS390XState *env) env->regs[6], env->regs[7], 0, 0);if (ret == -QEMU_ERESTARTSYS ) { env->psw.addr -= env->int_svc_ilen; - }else if (ret != -TARGET_QEMU_ESIGRETURN ) { + }else if (ret != -QEMU_ESIGRETURN ) { env->regs[2 ] = ret; }break ;
linux-user/s390x/signal.c +4 -4
@@ -359,7 +359,7 @@ long do_sigreturn(CPUS390XState *env)trace_user_do_sigreturn (env, frame_addr);if (!lock_user_struct (VERIFY_READ , frame, frame_addr,1 )) {force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }/* Make sure that we're initializing all of target_set. */
@@ -373,7 +373,7 @@ long do_sigreturn(CPUS390XState *env)restore_sigregs_ext (env, &frame->sregs_ext);unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }long do_rt_sigreturn (CPUS390XState *env)
@@ -385,7 +385,7 @@ long do_rt_sigreturn(CPUS390XState *env)trace_user_do_rt_sigreturn (env, frame_addr);if (!lock_user_struct (VERIFY_READ , frame, frame_addr,1 )) {force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }target_to_host_sigset (&set, &frame->uc.tuc_sigmask);
@@ -397,7 +397,7 @@ long do_rt_sigreturn(CPUS390XState *env)target_restore_altstack (&frame->uc.tuc_stack, env);unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }void setup_sigtramp (abi_ulong sigtramp_page)
linux-user/sh4/cpu_loop.c +1 -1
@@ -52,7 +52,7 @@ void cpu_loop(CPUSH4State *env) 0, 0);if (ret == -QEMU_ERESTARTSYS ) { env->pc -=2 ; - }else if (ret != -TARGET_QEMU_ESIGRETURN ) { + }else if (ret != -QEMU_ESIGRETURN ) { env->gregs[0 ] = ret; }break ;
linux-user/sh4/signal.c +4 -4
@@ -286,12 +286,12 @@ long do_sigreturn(CPUSH4State *regs)restore_sigcontext (regs, &frame->sc);unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:unlock_user_struct (frame, frame_addr,0 );force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }long do_rt_sigreturn (CPUSH4State *regs)
@@ -313,12 +313,12 @@ long do_rt_sigreturn(CPUSH4State *regs)target_restore_altstack (&frame->uc.tuc_stack, regs);unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:unlock_user_struct (frame, frame_addr,0 );force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }void setup_sigtramp (abi_ulong sigtramp_page)
linux-user/sparc/cpu_loop.c +1 -1
@@ -181,7 +181,7 @@ void cpu_loop (CPUSPARCState *env) env->regwptr[2 ], env->regwptr[3 ], env->regwptr[4 ], env->regwptr[5 ], 0, 0); -if (ret == -QEMU_ERESTARTSYS || ret == -TARGET_QEMU_ESIGRETURN ) { +if (ret == -QEMU_ERESTARTSYS || ret == -QEMU_ESIGRETURN ) {break ; }if ((abi_ulong )ret >= (abi_ulong)(-515 )) {
linux-user/sparc/signal.c +4 -4
@@ -431,12 +431,12 @@ long do_sigreturn(CPUSPARCState *env)set_sigmask (&host_set);unlock_user_struct (sf, sf_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; segv_and_exit:unlock_user_struct (sf, sf_addr,0 );force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ;#else return -TARGET_ENOSYS ;#endif
@@ -495,12 +495,12 @@ long do_rt_sigreturn(CPUSPARCState *env) env->npc = tnpc;unlock_user_struct (sf, sf_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; segv_and_exit:unlock_user_struct (sf, sf_addr,0 );force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }#if defined(TARGET_SPARC64 ) && !defined(TARGET_ABI32 )
linux-user/syscall.c +1 -1
@@ -550,7 +550,7 @@ const char *target_strerror(int err)if (err ==QEMU_ERESTARTSYS ) {return "To be restarted" ; } -if (err ==TARGET_QEMU_ESIGRETURN ) { +if (err ==QEMU_ESIGRETURN ) {return "Successful exit from sigreturn" ; }
linux-user/xtensa/cpu_loop.c +1 -1
@@ -188,7 +188,7 @@ void cpu_loop(CPUXtensaState *env) env->pc -=3 ;break ; -case -TARGET_QEMU_ESIGRETURN : +case -QEMU_ESIGRETURN :break ; }break ;
linux-user/xtensa/signal.c +2 -2
@@ -263,12 +263,12 @@ long do_rt_sigreturn(CPUXtensaState *env)target_restore_altstack (&frame->uc.tuc_stack, env);unlock_user_struct (frame, frame_addr,0 ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; badframe:unlock_user_struct (frame, frame_addr,0 );force_sig (TARGET_SIGSEGV ); -return -TARGET_QEMU_ESIGRETURN ; +return -QEMU_ESIGRETURN ; }void setup_sigtramp (abi_ulong sigtramp_page)
Signature · 1 line
2.25.1
[PULL 02/15] linux-user: Move syscall error detection into safe_syscall_base
In reply to Richard HendersonThe current api from safe_syscall_base() is to return -errno, which is the interface provided by *some* linux kernel abis. The wrapper macro, safe_syscall(), detects error, stores into errno, and returns -1, to match the api of the system syscall().
For those kernel abis that do not return -errno natively, this leads to double syscall error detection. E.g. Linux ppc64, which sets the SO flag for error.
Simplify the usage from C by moving the error detection into assembly, and usage from assembly by providing a C helper with which to set errno.
--- linux-user/safe-syscall.h | 16 +++------- linux-user/safe-syscall-error.c | 28 ++++++++++++++++ linux-user/host/aarch64/safe-syscall.inc.S | 20 ++++++------ linux-user/host/arm/safe-syscall.inc.S | 27 ++++++++++------ linux-user/host/i386/safe-syscall.inc.S | 37 +++++++++++++++------- linux-user/host/ppc64/safe-syscall.inc.S | 24 +++++++------- linux-user/host/riscv/safe-syscall.inc.S | 20 ++++++------ linux-user/host/s390x/safe-syscall.inc.S | 32 ++++++++++++------- linux-user/host/x86_64/safe-syscall.inc.S | 29 +++++++++-------- linux-user/meson.build | 1 + 10 files changed, 147 insertions(+), 87 deletions(-) create mode 100644 linux-user/safe-syscall-error.c
linux-user/safe-syscall.h +5 -11
@@ -127,21 +127,15 @@#ifdef HAVE_SAFE_SYSCALL /* The core part of this function is implemented in assembly */ extern long safe_syscall_base (int *pending,long number, ...); +extern long safe_syscall_set_errno_tail (int value); +/* These are defined by the safe-syscall.inc.S file */ extern char safe_syscall_start[];extern char safe_syscall_end[]; -#define safe_syscall (...) \ - ({ \ - long ret_; \ - int *psp_ = &((TaskState *)thread_cpu->opaque)->signal_pending; \ - ret_ = safe_syscall_base(psp_, __VA_ARGS__); \ - if (is_error(ret_)) { \ - errno = -ret_; \ - ret_ = -1; \ - } \ - ret_; \ - }) +#define safe_syscall (...) \ + safe_syscall_base(&((TaskState *)thread_cpu->opaque)->signal_pending, \ + __VA_ARGS__)#else
linux-user/safe-syscall-error.c new file +28 -0
@@ -0,0 +1,28 @@ +/* +* safe-syscall-error.c: errno setting fragment +* This is intended to be invoked by safe-syscall.S +* +* Written by Richard Henderson <[email protected]> +* Copyright (C) 2021 Red Hat, Inc. +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "hostdep.h" +#include "safe-syscall.h" + +#ifdef HAVE_SAFE_SYSCALL +/* +* This is intended to be invoked via tail-call on the error path +* from the assembly in host/arch/safe-syscall.inc.S. This takes +* care of the host specific addressing of errno. +* Return -1 to finalize the return value for safe_syscall_base. +*/ +long safe_syscall_set_errno_tail (int value) +{ + errno = value; +return -1 ; +} +#endif
linux-user/host/aarch64/safe-syscall.inc.S +11 -9
@@ -22,15 +22,12 @@ * first argument an 'int *' to the signal_pending flag, the * second one the system call number (as a 'long'), and all further * arguments being syscall arguments (also 'long'). - * We return a long which is the syscall's return value, which - * may be negative-errno on failure. Conversion to the - * -1-and-errno-set convention is done by the calling wrapper. */ safe_syscall_base: .cfi_startproc /* The syscall calling convention isn't the same as the * C one: - * we enter with x0 == *signal_pending + * we enter with x0 == &signal_pending * x1 == syscall number * x2 ... x7, (stack) == syscall arguments * and return the result in x0
@@ -60,16 +57,21 @@ safe_syscall_base: safe_syscall_start: /* if signal_pending is non-zero, don't do the call */ ldr w10, [x9] - cbnz w10, 0f + cbnz w10, 2f svc 0x0 safe_syscall_end: /* code path for having successfully executed the syscall */ + cmp x0, #-4096 + b.hi 0f ret -0: + /* code path setting errno */ +0: neg w0, w0 + b safe_syscall_set_errno_tail + /* code path when we didn't execute the syscall */ - mov x0, #-TARGET_ERESTARTSYS - ret - .cfi_endproc +2: mov w0, #TARGET_ERESTARTSYS + b safe_syscall_set_errno_tail + .cfi_endproc .size safe_syscall_base, .-safe_syscall_base
linux-user/host/arm/safe-syscall.inc.S +18 -9
@@ -27,9 +27,6 @@ * first argument an 'int *' to the signal_pending flag, the * second one the system call number (as a 'long'), and all further * arguments being syscall arguments (also 'long'). - * We return a long which is the syscall's return value, which - * may be negative-errno on failure. Conversion to the - * -1-and-errno-set convention is done by the calling wrapper. */ safe_syscall_base: .fnstart
@@ -46,7 +43,7 @@ safe_syscall_base: .cfi_rel_offset lr, 20 /* The syscall calling convention isn't the same as the C one: - * we enter with r0 == *signal_pending + * we enter with r0 == &signal_pending * r1 == syscall number * r2, r3, [sp+0] ... [sp+12] == syscall arguments * and return the result in r0
@@ -74,17 +71,29 @@ safe_syscall_start: /* if signal_pending is non-zero, don't do the call */ ldr r12, [r8] /* signal_pending */ tst r12, r12 - bne 1f + bne 2f swi 0 safe_syscall_end: /* code path for having successfully executed the syscall */ + cmp r0, #-4096 + neghi r0, r0 + bhi 1f pop { r4, r5, r6, r7, r8, pc } -1: /* code path when we didn't execute the syscall */ - ldr r0, =-TARGET_ERESTARTSYS - pop { r4, r5, r6, r7, r8, pc } +2: mov r0, #TARGET_ERESTARTSYS + + /* code path setting errno */ +1: pop { r4, r5, r6, r7, r8, lr } + .cfi_adjust_cfa_offset -24 + .cfi_restore r4 + .cfi_restore r5 + .cfi_restore r6 + .cfi_restore r7 + .cfi_restore r8 + .cfi_restore lr + b safe_syscall_set_errno_tail + .fnend .cfi_endproc - .size safe_syscall_base, .-safe_syscall_base
linux-user/host/i386/safe-syscall.inc.S +26 -11
@@ -20,9 +20,6 @@ * first argument an 'int *' to the signal_pending flag, the * second one the system call number (as a 'long'), and all further * arguments being syscall arguments (also 'long'). - * We return a long which is the syscall's return value, which - * may be negative-errno on failure. Conversion to the - * -1-and-errno-set convention is done by the calling wrapper. */ safe_syscall_base: .cfi_startproc
@@ -41,7 +38,7 @@ safe_syscall_base: /* The syscall calling convention isn't the same as the C one: * we enter with 0(%esp) == return address - * 4(%esp) == *signal_pending + * 4(%esp) == &signal_pending * 8(%esp) == syscall number * 12(%esp) ... 32(%esp) == syscall arguments * and return the result in eax
@@ -70,11 +67,13 @@ safe_syscall_start: /* if signal_pending is non-zero, don't do the call */ mov 4+16(%esp), %eax /* signal_pending */ cmpl $0, (%eax) - jnz 1f + jnz 2f mov 8+16(%esp), %eax /* syscall number */ int $0x80 safe_syscall_end: /* code path for having successfully executed the syscall */ + cmp $-4095, %eax + jae 0f pop %ebx .cfi_remember_state .cfi_adjust_cfa_offset -4
@@ -89,12 +88,28 @@ safe_syscall_end: .cfi_adjust_cfa_offset -4 .cfi_restore ebp ret - -1: - /* code path when we didn't execute the syscall */ .cfi_restore_state - mov $-TARGET_ERESTARTSYS, %eax - jmp safe_syscall_end - .cfi_endproc +0: neg %eax + jmp 1f + + /* code path when we didn't execute the syscall */ +2: mov $TARGET_ERESTARTSYS, %eax + + /* code path setting errno */ +1: pop %ebx + .cfi_adjust_cfa_offset -4 + .cfi_restore ebx + pop %edi + .cfi_adjust_cfa_offset -4 + .cfi_restore edi + pop %esi + .cfi_adjust_cfa_offset -4 + .cfi_restore esi + pop %ebp + .cfi_adjust_cfa_offset -4 + .cfi_restore ebp + jmp safe_syscall_set_errno_tail + + .cfi_endproc .size safe_syscall_base, .-safe_syscall_base
linux-user/host/ppc64/safe-syscall.inc.S +11 -13
@@ -22,9 +22,6 @@ * first argument an 'int *' to the signal_pending flag, the * second one the system call number (as a 'long'), and all further * arguments being syscall arguments (also 'long'). - * We return a long which is the syscall's return value, which - * may be negative-errno on failure. Conversion to the - * -1-and-errno-set convention is done by the calling wrapper. */ #if _CALL_ELF == 2 safe_syscall_base:
@@ -39,7 +36,7 @@ safe_syscall_base: .L.safe_syscall_base: .cfi_startproc #endif - /* We enter with r3 == *signal_pending + /* We enter with r3 == &signal_pending * r4 == syscall number * r5 ... r10 == syscall arguments * and return the result in r3
@@ -71,21 +68,22 @@ safe_syscall_start: /* if signal_pending is non-zero, don't do the call */ lwz 12, 0(14) cmpwi 0, 12, 0 - bne- 0f + bne- 2f sc safe_syscall_end: /* code path when we did execute the syscall */ - ld 14, 16(1) /* restore r14 to its original value */ - bnslr+ - - /* syscall failed; return negative errno */ - neg 3, 3 + ld 14, 16(1) /* restore r14 */ + bso- 1f blr /* code path when we didn't execute the syscall */ -0: addi 3, 0, -TARGET_ERESTARTSYS - ld 14, 16(1) /* restore r14 to its original value */ - blr +2: ld 14, 16(1) /* restore r14 */ + addi 3, 0, TARGET_ERESTARTSYS + + /* code path setting errno */ +1: b safe_syscall_set_errno_tail + nop /* per abi, for the linker to modify */ + .cfi_endproc #if _CALL_ELF == 2
linux-user/host/riscv/safe-syscall.inc.S +11 -9
@@ -23,15 +23,12 @@ * first argument an 'int *' to the signal_pending flag, the * second one the system call number (as a 'long'), and all further * arguments being syscall arguments (also 'long'). - * We return a long which is the syscall's return value, which - * may be negative-errno on failure. Conversion to the - * -1-and-errno-set convention is done by the calling wrapper. */ safe_syscall_base: .cfi_startproc /* * The syscall calling convention is nearly the same as C: - * we enter with a0 == *signal_pending + * we enter with a0 == &signal_pending * a1 == syscall number * a2 ... a7 == syscall arguments * and return the result in a0
@@ -62,16 +59,21 @@ safe_syscall_base: safe_syscall_start: /* If signal_pending is non-zero, don't do the call */ lw t1, 0(t0) - bnez t1, 0f + bnez t1, 2f scall safe_syscall_end: /* code path for having successfully executed the syscall */ + li t2, -4096 + bgtu a0, t2, 0f ret -0: + /* code path setting errno */ +0: neg a0, a0 + j safe_syscall_set_errno_tail + /* code path when we didn't execute the syscall */ - li a0, -TARGET_ERESTARTSYS - ret - .cfi_endproc +2: li a0, TARGET_ERESTARTSYS + j safe_syscall_set_errno_tail + .cfi_endproc .size safe_syscall_base, .-safe_syscall_base
linux-user/host/s390x/safe-syscall.inc.S +20 -12
@@ -20,9 +20,6 @@ * first argument an 'int *' to the signal_pending flag, the * second one the system call number (as a 'long'), and all further * arguments being syscall arguments (also 'long'). - * We return a long which is the syscall's return value, which - * may be negative-errno on failure. Conversion to the - * -1-and-errno-set convention is done by the calling wrapper. */ safe_syscall_base: .cfi_startproc
@@ -44,9 +41,9 @@ safe_syscall_base: stg %r1,0(%r15) /* store back chain */ stg %r0,8(%r15) /* store eos */ - /* The syscall calling convention isn't the same as the - * C one: - * we enter with r2 == *signal_pending + /* + * The syscall calling convention isn't the same as the C one: + * we enter with r2 == &signal_pending * r3 == syscall number * r4, r5, r6, (stack) == syscall arguments * and return the result in r2
@@ -77,14 +74,25 @@ safe_syscall_start: svc 0 safe_syscall_end: -1: lg %r15,0(%r15) /* load back chain */ + /* code path for having successfully executed the syscall */ + lg %r15,0(%r15) /* load back chain */ .cfi_remember_state .cfi_adjust_cfa_offset -160 lmg %r6,%r15,48(%r15) /* load saved registers */ - br %r14 - .cfi_restore_state -2: lghi %r2, -TARGET_ERESTARTSYS - j 1b - .cfi_endproc + lghi %r0, -4095 /* check for syscall error */ + clgr %r2, %r0 + blr %r14 /* return on success */ + lcr %r2, %r2 /* create positive errno */ + jg safe_syscall_set_errno_tail + .cfi_restore_state + + /* code path when we didn't execute the syscall */ +2: lg %r15,0(%r15) /* load back chain */ + .cfi_adjust_cfa_offset -160 + lmg %r6,%r15,48(%r15) /* load saved registers */ + lghi %r2, TARGET_ERESTARTSYS + jg safe_syscall_set_errno_tail + + .cfi_endproc .size safe_syscall_base, .-safe_syscall_base
linux-user/host/x86_64/safe-syscall.inc.S +16 -13
@@ -19,9 +19,6 @@ * first argument an 'int *' to the signal_pending flag, the * second one the system call number (as a 'long'), and all further * arguments being syscall arguments (also 'long'). - * We return a long which is the syscall's return value, which - * may be negative-errno on failure. Conversion to the - * -1-and-errno-set convention is done by the calling wrapper. */ safe_syscall_base: .cfi_startproc
@@ -35,9 +32,9 @@ safe_syscall_base: .cfi_adjust_cfa_offset 8 .cfi_rel_offset rbp, 0 - /* The syscall calling convention isn't the same as the - * C one: - * we enter with rdi == *signal_pending + /* + * The syscall calling convention isn't the same as the C one: + * we enter with rdi == &signal_pending * rsi == syscall number * rdx, rcx, r8, r9, (stack), (stack) == syscall arguments * and return the result in rax
@@ -68,24 +65,30 @@ safe_syscall_base: safe_syscall_start: /* if signal_pending is non-zero, don't do the call */ cmpl $0, (%rbp) - jnz 1f + jnz 2f syscall safe_syscall_end: /* code path for having successfully executed the syscall */ + cmp $-4095, %rax + jae 0f pop %rbp .cfi_remember_state .cfi_def_cfa_offset 8 .cfi_restore rbp ret - -1: - /* code path when we didn't execute the syscall */ .cfi_restore_state - mov $-TARGET_ERESTARTSYS, %rax - pop %rbp + +0: neg %eax + jmp 1f + + /* code path when we didn't execute the syscall */ +2: mov $TARGET_ERESTARTSYS, %eax + + /* code path setting errno */ +1: pop %rbp .cfi_def_cfa_offset 8 .cfi_restore rbp - ret + jmp safe_syscall_set_errno_tail .cfi_endproc .size safe_syscall_base, .-safe_syscall_base
linux-user/meson.build +1 -0
@@ -10,6 +10,7 @@ linux_user_ss.add(files( 'main.c', 'mmap.c', 'safe-syscall.S', + 'safe-syscall-error.c', 'signal.c', 'strace.c', 'syscall.c',
Signature · 1 line
2.25.1
Re: [PULL 02/15] linux-user: Move syscall error detection into safe_syscall_base
Le 20/12/2021 à 21:24, Richard Henderson a écrit :
Quoted 26 lines
The current api from
safe_syscall_base()is to return -errno, which is the interface provided by *some* linux kernel abis. The wrapper macro,safe_syscall(), detects error, stores into errno, and returns -1, to match the api of the systemsyscall().For those kernel abis that do not return -errno natively, this leads to double syscall error detection. E.g. Linux ppc64, which sets the SO flag for error.
Simplify the usage from C by moving the error detection into assembly, and usage from assembly by providing a C helper with which to set errno.
Reviewed-by Warner Losh <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- linux-user/safe-syscall.h | 16 +++------- linux-user/safe-syscall-error.c | 28 ++++++++++++++++ linux-user/host/aarch64/safe-syscall.inc.S | 20 ++++++------ linux-user/host/arm/safe-syscall.inc.S | 27 ++++++++++------ linux-user/host/i386/safe-syscall.inc.S | 37 +++++++++++++++------- linux-user/host/ppc64/safe-syscall.inc.S | 24 +++++++------- linux-user/host/riscv/safe-syscall.inc.S | 20 ++++++------ linux-user/host/s390x/safe-syscall.inc.S | 32 ++++++++++++------- linux-user/host/x86_64/safe-syscall.inc.S | 29 +++++++++-------- linux-user/meson.build | 1 + 10 files changed, 147 insertions(+), 87 deletions(-)
Quoted 3 lines
create mode 100644
linux-user/safe-syscall-error.c
This patch breaks command execution in bash command line interface:
- if I run "chroot chroot/powerpc/jessie ls", it works
- if I run "echo ls | chroot chroot/powerpc/jessie", it hangs
- if I run "chroot chroot/powerpc/jessie bash invalid_command",
it does nothing whereas it should return "bash: invalid_command: No such file or directory".
I think the exit status of the command is not correctly detected by bash.
Thanks,
Laurent
Re: [PULL 02/15] linux-user: Move syscall error detection into safe_syscall_base
Quoted 9 lines · Laurent Vivier
This patch breaks command execution in bash command line interface:
- if I run "chroot chroot/powerpc/jessie ls", it works
- if I run "echo ls | chroot chroot/powerpc/jessie", it hangs
- if I run "chroot chroot/powerpc/jessie bash
invalid_command",
it does nothing whereas it should return "bash:invalid_command: No such file or
directory".
Thanks. I've reproduced this (or something close enough):
Host:openat(AT_FDCWD, "asdf", O_RDONLY) = -1 ENOENT (No such file or directory)
Guest:
502138 open("asdf",O_RDONLY|O_LARGEFILE) = 100
r~
[PULL 14/15] meson: Move linux_user_ss to linux-user/
In reply to Richard HendersonWe have no need to reference linux_user_ss outside of linux-user. Go ahead and merge it directly into specific_ss.
--- meson.build | 3 --- linux-user/meson.build | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-)
meson.build +0 -3
@@ -2382,7 +2382,6 @@ common_user_ss = ss.source_set() crypto_ss = ss.source_set() hwcore_ss = ss.source_set() io_ss = ss.source_set() -linux_user_ss = ss.source_set() qmp_ss = ss.source_set() qom_ss = ss.source_set() softmmu_ss = ss.source_set()
@@ -2633,8 +2632,6 @@ subdir('linux-user') specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss) -specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss) - common_user_ss = common_user_ss.apply(config_all, strict: false) common_user = static_library('common-user', sources: common_user_ss.sources(),
linux-user/meson.build +4 -0
@@ -2,6 +2,8 @@ if not have_linux_user subdir_done() endif +linux_user_ss = ss.source_set() + common_user_inc += include_directories('host/' / host_arch) common_user_inc += include_directories('.')
@@ -42,3 +44,5 @@ subdir('sh4') subdir('sparc') subdir('x86_64') subdir('xtensa') + +specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss)
Signature · 1 line
2.25.1
[PULL 06/15] linux-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS
In reply to Richard HendersonThis value is fully internal to qemu, and so is not a TARGET define. We use this as an extra marker for both host and target errno.
--- linux-user/generic/target_errno_defs.h | 2 +- linux-user/safe-syscall.h | 8 ++++---- linux-user/signal-common.h | 2 +- linux-user/aarch64/cpu_loop.c | 2 +- linux-user/alpha/cpu_loop.c | 2 +- linux-user/arm/cpu_loop.c | 2 +- linux-user/cris/cpu_loop.c | 2 +- linux-user/hexagon/cpu_loop.c | 2 +- linux-user/hppa/cpu_loop.c | 2 +- linux-user/i386/cpu_loop.c | 6 +++--- linux-user/m68k/cpu_loop.c | 2 +- linux-user/microblaze/cpu_loop.c | 2 +- linux-user/mips/cpu_loop.c | 2 +- linux-user/openrisc/cpu_loop.c | 2 +- linux-user/ppc/cpu_loop.c | 2 +- linux-user/riscv/cpu_loop.c | 2 +- linux-user/s390x/cpu_loop.c | 2 +- linux-user/sh4/cpu_loop.c | 2 +- linux-user/signal.c | 6 +++--- linux-user/sparc/cpu_loop.c | 2 +- linux-user/syscall.c | 16 ++++++++-------- linux-user/xtensa/cpu_loop.c | 2 +- linux-user/host/aarch64/safe-syscall.inc.S | 3 +-- linux-user/host/arm/safe-syscall.inc.S | 2 +- linux-user/host/i386/safe-syscall.inc.S | 2 +- linux-user/host/mips/safe-syscall.inc.S | 2 +- linux-user/host/ppc64/safe-syscall.inc.S | 2 +- linux-user/host/riscv/safe-syscall.inc.S | 2 +- linux-user/host/s390x/safe-syscall.inc.S | 2 +- linux-user/host/sparc64/safe-syscall.inc.S | 2 +- linux-user/host/x86_64/safe-syscall.inc.S | 2 +- 31 files changed, 45 insertions(+), 46 deletions(-)
linux-user/generic/target_errno_defs.h +1 -1
@@ -153,7 +153,7 @@* after handling any pending signals. They match with the ones the guest * kernel uses for the same purpose. */ -#define TARGET_ERESTARTSYS 512/* Restart system call (if SA_RESTART) */ +#define QEMU_ERESTARTSYS 512/* Restart system call (if SA_RESTART) */ /* QEMU internal, not visible to the guest. This is returned by the * do_sigreturn() code after a successful sigreturn syscall, to indicate
linux-user/safe-syscall.h +4 -4
@@ -25,10 +25,10 @@* * Call a system call if guest signal not pending. * This has the same API as the libc syscall() function, except that it -* may return -1 with errno == TARGET_ERESTARTSYS if a signal was pending. +* may return -1 with errno == QEMU_ERESTARTSYS if a signal was pending. * * Returns: the system call result, or -1 with an error code in errno -* (Errnos are host errnos; we rely on TARGET_ERESTARTSYS not clashing +* (Errnos are host errnos; we rely on QEMU_ERESTARTSYS not clashing * with any of the host errno values.) */
@@ -81,7 +81,7 @@* which are only technically blocking (ie which we know in practice won't * stay in the host kernel indefinitely) it's OK to use libc if necessary. * You must be able to cope with backing out correctly if some safe_syscall -* you make in the implementation returns either -TARGET_ERESTARTSYS or +* you make in the implementation returns either -QEMU_ERESTARTSYS or * EINTR though.) * * block_signals() cannot be used for interruptible syscalls.
@@ -94,7 +94,7 @@* handler checks the interrupted host PC against the addresse of that * known section. If the PC is before or at the address of the syscall * instruction then we change the PC to point at a "return -* -TARGET_ERESTARTSYS" code path instead, and then exit the signal handler +* -QEMU_ERESTARTSYS" code path instead, and then exit the signal handler * (causing the safe_syscall() call to immediately return that value). * Then in the main.c loop if we see this magic return value we adjust * the guest PC to wind it back to before the system call, and invoke
linux-user/signal-common.h +1 -1
@@ -76,7 +76,7 @@ abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx,* Block all signals, and arrange that the signal mask is returned to * its correct value for the guest before we resume execution of guest code. * If this function returns non-zero, then the caller should immediately -* return -TARGET_ERESTARTSYS to the main loop, which will take the pending +* return -QEMU_ERESTARTSYS to the main loop, which will take the pending * signal and restart execution of the syscall. * If block_signals() returns zero, then the caller can continue with * emulation of the system call knowing that no signals can be taken
linux-user/aarch64/cpu_loop.c +1 -1
@@ -99,7 +99,7 @@ void cpu_loop(CPUARMState *env) env->xregs[4 ], env->xregs[5 ], 0, 0); -if (ret == -TARGET_ERESTARTSYS ) { +if (ret == -QEMU_ERESTARTSYS ) { env->pc -=4 ; }else if (ret != -TARGET_QEMU_ESIGRETURN ) { env->xregs[0 ] = ret;
linux-user/alpha/cpu_loop.c +1 -1
@@ -98,7 +98,7 @@ void cpu_loop(CPUAlphaState *env) env->ir[IR_A2 ], env->ir[IR_A3 ], env->ir[IR_A4 ], env->ir[IR_A5 ], 0, 0); -if (sysret == -TARGET_ERESTARTSYS ) { +if (sysret == -QEMU_ERESTARTSYS ) { env->pc -=4 ;break ; }
linux-user/arm/cpu_loop.c +1 -1
@@ -407,7 +407,7 @@ void cpu_loop(CPUARMState *env) env->regs[4 ], env->regs[5 ], 0, 0); -if (ret == -TARGET_ERESTARTSYS ) { +if (ret == -QEMU_ERESTARTSYS ) { env->regs[15 ] -= env->thumb ?2 :4 ; }else if (ret != -TARGET_QEMU_ESIGRETURN ) { env->regs[0 ] = ret;
linux-user/cris/cpu_loop.c +1 -1
@@ -50,7 +50,7 @@ void cpu_loop(CPUCRISState *env) env->pregs[7 ], env->pregs[11 ], 0, 0); -if (ret == -TARGET_ERESTARTSYS ) { +if (ret == -QEMU_ERESTARTSYS ) { env->pc -=2 ; }else if (ret != -TARGET_QEMU_ESIGRETURN ) { env->regs[10 ] = ret;
linux-user/hexagon/cpu_loop.c +1 -1
@@ -55,7 +55,7 @@ void cpu_loop(CPUHexagonState *env) env->gpr[4 ], env->gpr[5 ], 0, 0); -if (ret == -TARGET_ERESTARTSYS ) { +if (ret == -QEMU_ERESTARTSYS ) { env->gpr[HEX_REG_PC ] -=4 ; }else if (ret != -TARGET_QEMU_ESIGRETURN ) { env->gpr[0 ] = ret;
linux-user/hppa/cpu_loop.c +1 -1
@@ -133,7 +133,7 @@ void cpu_loop(CPUHPPAState *env) env->iaoq_f = env->gr[31 ]; env->iaoq_b = env->gr[31 ] +4 ;break ; -case -TARGET_ERESTARTSYS : +case -QEMU_ERESTARTSYS :case -TARGET_QEMU_ESIGRETURN :break ; }
linux-user/i386/cpu_loop.c +3 -3
@@ -180,7 +180,7 @@ static void emulate_vsyscall(CPUX86State *env) ret =do_syscall (env, syscall, env->regs[R_EDI ], env->regs[R_ESI ], env->regs[R_EDX ], env->regs[10 ], env->regs[8 ], env->regs[9 ],0 ,0 ); -g_assert (ret != -TARGET_ERESTARTSYS ); +g_assert (ret != -QEMU_ERESTARTSYS );g_assert (ret != -TARGET_QEMU_ESIGRETURN );if (ret == -TARGET_EFAULT ) { goto sigsegv;
@@ -223,7 +223,7 @@ void cpu_loop(CPUX86State *env) env->regs[R_EDI ], env->regs[R_EBP ], 0, 0); -if (ret == -TARGET_ERESTARTSYS ) { +if (ret == -QEMU_ERESTARTSYS ) { env->eip -=2 ; }else if (ret != -TARGET_QEMU_ESIGRETURN ) { env->regs[R_EAX ] = ret;
@@ -241,7 +241,7 @@ void cpu_loop(CPUX86State *env) env->regs[8 ], env->regs[9 ], 0, 0); -if (ret == -TARGET_ERESTARTSYS ) { +if (ret == -QEMU_ERESTARTSYS ) { env->eip -=2 ; }else if (ret != -TARGET_QEMU_ESIGRETURN ) { env->regs[R_EAX ] = ret;
linux-user/m68k/cpu_loop.c +1 -1
@@ -80,7 +80,7 @@ void cpu_loop(CPUM68KState *env) env->dregs[5 ], env->aregs[0 ], 0, 0); -if (ret == -TARGET_ERESTARTSYS ) { +if (ret == -QEMU_ERESTARTSYS ) { env->pc -=2 ; }else if (ret != -TARGET_QEMU_ESIGRETURN ) { env->dregs[0 ] = ret;
linux-user/microblaze/cpu_loop.c +1 -1
@@ -53,7 +53,7 @@ void cpu_loop(CPUMBState *env) env->regs[9 ], env->regs[10 ], 0, 0); -if (ret == -TARGET_ERESTARTSYS ) { +if (ret == -QEMU_ERESTARTSYS ) {/* Wind back to before the syscall. */ env->pc -=4 ; }else if (ret != -TARGET_QEMU_ESIGRETURN ) {
linux-user/mips/cpu_loop.c +1 -1
@@ -141,7 +141,7 @@ done_syscall: env->active_tc.gpr[8 ], env->active_tc.gpr[9 ], env->active_tc.gpr[10], env->active_tc.gpr[11]);# endif /* O32 */ -if (ret == -TARGET_ERESTARTSYS ) { +if (ret == -QEMU_ERESTARTSYS ) { env->active_tc.PC -=4 ;break ; }
linux-user/openrisc/cpu_loop.c +1 -1
@@ -48,7 +48,7 @@ void cpu_loop(CPUOpenRISCState *env)cpu_get_gpr (env,6 ),cpu_get_gpr (env,7 ), cpu_get_gpr(env, 8), 0, 0); -if (ret == -TARGET_ERESTARTSYS ) { +if (ret == -QEMU_ERESTARTSYS ) { env->pc -=4 ; }else if (ret != -TARGET_QEMU_ESIGRETURN ) {cpu_set_gpr (env,11 , ret);
linux-user/ppc/cpu_loop.c +1 -1
@@ -428,7 +428,7 @@ void cpu_loop(CPUPPCState *env) ret =do_syscall (env, env->gpr[0 ], env->gpr[3 ], env->gpr[4 ], env->gpr[5 ], env->gpr[6 ], env->gpr[7 ], env->gpr[8 ],0 ,0 ); -if (ret == -TARGET_ERESTARTSYS ) { +if (ret == -QEMU_ERESTARTSYS ) { env->nip -=4 ;break ; }
linux-user/riscv/cpu_loop.c +1 -1
@@ -69,7 +69,7 @@ void cpu_loop(CPURISCVState *env) env->gpr[xA5], 0, 0); } -if (ret == -TARGET_ERESTARTSYS ) { +if (ret == -QEMU_ERESTARTSYS ) { env->pc -=4 ; }else if (ret != -TARGET_QEMU_ESIGRETURN ) { env->gpr[xA0] = ret;
linux-user/s390x/cpu_loop.c +1 -1
@@ -83,7 +83,7 @@ void cpu_loop(CPUS390XState *env) ret =do_syscall (env, n, env->regs[2 ], env->regs[3 ], env->regs[4 ], env->regs[5 ], env->regs[6 ], env->regs[7 ],0 ,0 ); -if (ret == -TARGET_ERESTARTSYS ) { +if (ret == -QEMU_ERESTARTSYS ) { env->psw.addr -= env->int_svc_ilen; }else if (ret != -TARGET_QEMU_ESIGRETURN ) { env->regs[2 ] = ret;
linux-user/sh4/cpu_loop.c +1 -1
@@ -50,7 +50,7 @@ void cpu_loop(CPUSH4State *env) env->gregs[0 ], env->gregs[1 ], 0, 0); -if (ret == -TARGET_ERESTARTSYS ) { +if (ret == -QEMU_ERESTARTSYS ) { env->pc -=2 ; }else if (ret != -TARGET_QEMU_ESIGRETURN ) { env->gregs[0 ] = ret;
linux-user/signal.c +3 -3
@@ -213,7 +213,7 @@ int block_signals(void)/* Wrapper for sigprocmask function * Emulates a sigprocmask in a safe way for the guest. Note that set and oldset -* are host signal set, not guest ones. Returns -TARGET_ERESTARTSYS if +* are host signal set, not guest ones. Returns -QEMU_ERESTARTSYS if * a signal was already pending and the syscall must be restarted, or * 0 on success. * If set is NULL, this is guaranteed not to fail.
@@ -230,7 +230,7 @@ int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset)int i;if (block_signals ()) { -return -TARGET_ERESTARTSYS ; +return -QEMU_ERESTARTSYS ; }switch (how) {
@@ -985,7 +985,7 @@ int do_sigaction(int sig, const struct target_sigaction *act, }if (block_signals ()) { -return -TARGET_ERESTARTSYS ; +return -QEMU_ERESTARTSYS ; } k = &sigact_table[sig -1 ];
linux-user/sparc/cpu_loop.c +1 -1
@@ -181,7 +181,7 @@ void cpu_loop (CPUSPARCState *env) env->regwptr[2 ], env->regwptr[3 ], env->regwptr[4 ], env->regwptr[5 ], 0, 0); -if (ret == -TARGET_ERESTARTSYS || ret == -TARGET_QEMU_ESIGRETURN ) { +if (ret == -QEMU_ERESTARTSYS || ret == -TARGET_QEMU_ESIGRETURN ) {break ; }if ((abi_ulong )ret >= (abi_ulong)(-515 )) {
linux-user/syscall.c +8 -8
@@ -547,7 +547,7 @@ static inline abi_long get_errno(abi_long ret)const char *target_strerror (int err) { -if (err ==TARGET_ERESTARTSYS ) { +if (err ==QEMU_ERESTARTSYS ) {return "To be restarted" ; }if (err ==TARGET_QEMU_ESIGRETURN ) {
@@ -6458,7 +6458,7 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, }if (block_signals ()) { -return -TARGET_ERESTARTSYS ; +return -QEMU_ERESTARTSYS ; }fork_start ();
@@ -8328,7 +8328,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,Do thread termination if we have more then one thread. */ if (block_signals ()) { -return -TARGET_ERESTARTSYS ; +return -QEMU_ERESTARTSYS ; }pthread_mutex_lock (&clone_lock);
@@ -9317,7 +9317,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif ret =get_errno (safe_rt_sigsuspend (&ts->sigsuspend_mask,SIGSET_T_SIZE )); -if (ret != -TARGET_ERESTARTSYS ) { +if (ret != -QEMU_ERESTARTSYS ) { ts->in_sigsuspend =1 ; } }
@@ -9336,7 +9336,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg1,0 ); ret =get_errno (safe_rt_sigsuspend (&ts->sigsuspend_mask,SIGSET_T_SIZE )); -if (ret != -TARGET_ERESTARTSYS ) { +if (ret != -QEMU_ERESTARTSYS ) { ts->in_sigsuspend =1 ; } }
@@ -9452,13 +9452,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_sigreturncase TARGET_NR_sigreturn:if (block_signals ()) { -return -TARGET_ERESTARTSYS ; +return -QEMU_ERESTARTSYS ; }return do_sigreturn (cpu_env);#endif case TARGET_NR_rt_sigreturn:if (block_signals ()) { -return -TARGET_ERESTARTSYS ; +return -QEMU_ERESTARTSYS ; }return do_rt_sigreturn (cpu_env);case TARGET_NR_sethostname:
@@ -13145,7 +13145,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,static bool flag; flag = !flag;if (flag) { -return -TARGET_ERESTARTSYS ; +return -QEMU_ERESTARTSYS ; } }#endif
linux-user/xtensa/cpu_loop.c +1 -1
@@ -184,7 +184,7 @@ void cpu_loop(CPUXtensaState *env) env->regs[2 ] = ret;break ; -case -TARGET_ERESTARTSYS : +case -QEMU_ERESTARTSYS : env->pc -=3 ;break ;
linux-user/host/aarch64/safe-syscall.inc.S +1 -2
@@ -70,8 +70,7 @@ safe_syscall_end: b safe_syscall_set_errno_tail /* code path when we didn't execute the syscall */ -2: mov w0, #TARGET_ERESTARTSYS +2: mov w0, #QEMU_ERESTARTSYS b safe_syscall_set_errno_tail - .cfi_endproc .size safe_syscall_base, .-safe_syscall_base
linux-user/host/arm/safe-syscall.inc.S +1 -1
@@ -81,7 +81,7 @@ safe_syscall_end: pop { r4, r5, r6, r7, r8, pc } /* code path when we didn't execute the syscall */ -2: mov r0, #TARGET_ERESTARTSYS +2: mov r0, #QEMU_ERESTARTSYS /* code path setting errno */ 1: pop { r4, r5, r6, r7, r8, lr }
linux-user/host/i386/safe-syscall.inc.S +1 -1
@@ -94,7 +94,7 @@ safe_syscall_end: jmp 1f /* code path when we didn't execute the syscall */ -2: mov $TARGET_ERESTARTSYS, %eax +2: mov $QEMU_ERESTARTSYS, %eax /* code path setting errno */ 1: pop %ebx
linux-user/host/mips/safe-syscall.inc.S +1 -1
@@ -127,7 +127,7 @@ safe_syscall_end: PTR_ADDIU sp, sp, FRAME .cfi_adjust_cfa_offset -FRAME .cfi_restore s0 - li v0, TARGET_ERESTARTSYS + li v0, QEMU_ERESTARTSYS /* code path setting errno */ /*
linux-user/host/ppc64/safe-syscall.inc.S +1 -1
@@ -78,7 +78,7 @@ safe_syscall_end: /* code path when we didn't execute the syscall */ 2: ld 14, 16(1) /* restore r14 */ - addi 3, 0, TARGET_ERESTARTSYS + addi 3, 0, QEMU_ERESTARTSYS /* code path setting errno */ 1: b safe_syscall_set_errno_tail
linux-user/host/riscv/safe-syscall.inc.S +1 -1
@@ -72,7 +72,7 @@ safe_syscall_end: j safe_syscall_set_errno_tail /* code path when we didn't execute the syscall */ -2: li a0, TARGET_ERESTARTSYS +2: li a0, QEMU_ERESTARTSYS j safe_syscall_set_errno_tail .cfi_endproc
linux-user/host/s390x/safe-syscall.inc.S +1 -1
@@ -91,7 +91,7 @@ safe_syscall_end: 2: lg %r15,0(%r15) /* load back chain */ .cfi_adjust_cfa_offset -160 lmg %r6,%r15,48(%r15) /* load saved registers */ - lghi %r2, TARGET_ERESTARTSYS + lghi %r2, QEMU_ERESTARTSYS jg safe_syscall_set_errno_tail .cfi_endproc
linux-user/host/sparc64/safe-syscall.inc.S +1 -1
@@ -78,7 +78,7 @@ safe_syscall_end: nop /* code path when we didn't execute the syscall */ -2: set TARGET_ERESTARTSYS, %o0 +2: set QEMU_ERESTARTSYS, %o0 /* code path setting errno */ 1: mov %o7, %g1
linux-user/host/x86_64/safe-syscall.inc.S +1 -1
@@ -82,7 +82,7 @@ safe_syscall_end: jmp 1f /* code path when we didn't execute the syscall */ -2: mov $TARGET_ERESTARTSYS, %eax +2: mov $QEMU_ERESTARTSYS, %eax /* code path setting errno */ 1: pop %rbp
Signature · 1 line
2.25.1
[PULL 15/15] meson: Move bsd_user_ss to bsd-user/
In reply to Richard HendersonWe have no need to reference bsd_user_ss outside of bsd-user. Go ahead and merge it directly into specific_ss.
--- meson.build | 3 --- bsd-user/meson.build | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-)
meson.build +0 -3
@@ -2375,7 +2375,6 @@ genh += hxdep authz_ss = ss.source_set() blockdev_ss = ss.source_set() block_ss = ss.source_set() -bsd_user_ss = ss.source_set() chardev_ss = ss.source_set() common_ss = ss.source_set() common_user_ss = ss.source_set()
@@ -2630,8 +2629,6 @@ subdir('common-user') subdir('bsd-user') subdir('linux-user') -specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss) - common_user_ss = common_user_ss.apply(config_all, strict: false) common_user = static_library('common-user', sources: common_user_ss.sources(),
bsd-user/meson.build +4 -0
@@ -2,6 +2,8 @@ if not have_bsd_user subdir_done() endif +bsd_user_ss = ss.source_set() + common_user_inc += include_directories('.') bsd_user_ss.add(files(
@@ -17,3 +19,5 @@ bsd_user_ss.add(files( # Pull in the OS-specific build glue, if any subdir(targetos) + +specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss)
Signature · 1 line
2.25.1
[PULL 12/15] common-user: Adjust system call return on FreeBSD
In reply to Richard HendersonFreeBSD system calls return positive errno. On the 4 hosts for which we have support, error is indicated by the C bit set or clear.
--- common-user/host/aarch64/safe-syscall.inc.S | 14 +++++++++++++- common-user/host/arm/safe-syscall.inc.S | 9 +++++++++ common-user/host/i386/safe-syscall.inc.S | 11 +++++++++++ common-user/host/x86_64/safe-syscall.inc.S | 11 +++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-)
common-user/host/aarch64/safe-syscall.inc.S +13 -1
@@ -60,17 +60,29 @@ safe_syscall_start: cbnz w10, 2f svc 0x0 safe_syscall_end: + /* code path for having successfully executed the syscall */ +#if defined(__linux__) + /* Linux kernel returns (small) negative errno. */ cmp x0, #-4096 b.hi 0f +#elif defined(__FreeBSD__) + /* FreeBSD kernel returns positive errno and C bit set. */ + b.cs 1f +#else +#error "unsupported os" +#endif ret +#if defined(__linux__) /* code path setting errno */ 0: neg w0, w0 b safe_syscall_set_errno_tail +#endif /* code path when we didn't execute the syscall */ 2: mov w0, #QEMU_ERESTARTSYS - b safe_syscall_set_errno_tail +1: b safe_syscall_set_errno_tail + .cfi_endproc .size safe_syscall_base, .-safe_syscall_base
common-user/host/arm/safe-syscall.inc.S +9 -0
@@ -74,10 +74,19 @@ safe_syscall_start: bne 2f swi 0 safe_syscall_end: + /* code path for having successfully executed the syscall */ +#if defined(__linux__) + /* Linux kernel returns (small) negative errno. */ cmp r0, #-4096 neghi r0, r0 bhi 1f +#elif defined(__FreeBSD__) + /* FreeBSD kernel returns positive errno and C bit set. */ + bcs 1f +#else +#error "unsupported os" +#endif pop { r4, r5, r6, r7, r8, pc } /* code path when we didn't execute the syscall */
common-user/host/i386/safe-syscall.inc.S +11 -0
@@ -71,9 +71,18 @@ safe_syscall_start: mov 8+16(%esp), %eax /* syscall number */ int $0x80 safe_syscall_end: + /* code path for having successfully executed the syscall */ +#if defined(__linux__) + /* Linux kernel returns (small) negative errno. */ cmp $-4095, %eax jae 0f +#elif defined(__FreeBSD__) + /* FreeBSD kernel returns positive errno and C bit set. */ + jc 1f +#else +#error "unsupported os" +#endif pop %ebx .cfi_remember_state .cfi_adjust_cfa_offset -4
@@ -90,8 +99,10 @@ safe_syscall_end: ret .cfi_restore_state +#if defined(__linux__) 0: neg %eax jmp 1f +#endif /* code path when we didn't execute the syscall */ 2: mov $QEMU_ERESTARTSYS, %eax
common-user/host/x86_64/safe-syscall.inc.S +11 -0
@@ -68,9 +68,18 @@ safe_syscall_start: jnz 2f syscall safe_syscall_end: + /* code path for having successfully executed the syscall */ +#if defined(__linux__) + /* Linux kernel returns (small) negative errno. */ cmp $-4095, %rax jae 0f +#elif defined(__FreeBSD__) + /* FreeBSD kernel returns positive errno and C bit set. */ + jc 1f +#else +#error "unsupported os" +#endif pop %rbp .cfi_remember_state .cfi_def_cfa_offset 8
@@ -78,8 +87,10 @@ safe_syscall_end: ret .cfi_restore_state +#if defined(__linux__) 0: neg %eax jmp 1f +#endif /* code path when we didn't execute the syscall */ 2: mov $QEMU_ERESTARTSYS, %eax
Signature · 1 line
2.25.1
[PULL 13/15] linux-user: Move thunk.c from top-level
In reply to Richard HendersonSo far, linux-user is the only user of these functions. Clean up the build machinery by restricting it to linux-user.
--- meson.build | 1 - thunk.c => linux-user/thunk.c | 0 MAINTAINERS | 1 - linux-user/meson.build | 1 + 4 files changed, 1 insertion(+), 2 deletions(-) rename thunk.c => linux-user/thunk.c (100%)
meson.build +0 -1
@@ -2633,7 +2633,6 @@ subdir('linux-user') specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss) -linux_user_ss.add(files('thunk.c')) specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss) common_user_ss = common_user_ss.apply(config_all, strict: false)
linux-user/thunk.c renamed from thunk.c +0 -0
MAINTAINERS +0 -1
@@ -3077,7 +3077,6 @@ Usermode Emulation Overall usermode emulation M: Riku Voipio <[email protected]> S: Maintained -F: thunk.c F: accel/tcg/user-exec*.c F: include/user/ F: common-user/
linux-user/meson.build +1 -0
@@ -15,6 +15,7 @@ linux_user_ss.add(files( 'signal.c', 'strace.c', 'syscall.c', + 'thunk.c', 'uaccess.c', 'uname.c', ))
Signature · 1 line
2.25.1
[PULL 05/15] linux-user: Remove HAVE_SAFE_SYSCALL and hostdep.h
In reply to Richard HendersonAll supported hosts now define HAVE_SAFE_SYSCALL, so remove the ifdefs. This leaves hostdep.h empty, so remove it.
--- linux-user/host/aarch64/hostdep.h | 18 ------------------ linux-user/host/arm/hostdep.h | 18 ------------------ linux-user/host/i386/hostdep.h | 18 ------------------ linux-user/host/ia64/hostdep.h | 15 --------------- linux-user/host/mips/hostdep.h | 18 ------------------ linux-user/host/ppc/hostdep.h | 15 --------------- linux-user/host/ppc64/hostdep.h | 18 ------------------ linux-user/host/riscv/hostdep.h | 14 -------------- linux-user/host/s390/hostdep.h | 15 --------------- linux-user/host/s390x/hostdep.h | 18 ------------------ linux-user/host/sparc/hostdep.h | 15 --------------- linux-user/host/sparc64/hostdep.h | 18 ------------------ linux-user/host/x32/hostdep.h | 15 --------------- linux-user/host/x86_64/hostdep.h | 18 ------------------ linux-user/safe-syscall.h | 13 +------------ linux-user/user-internals.h | 1 - linux-user/safe-syscall-error.c | 3 --- linux-user/signal.c | 2 -- linux-user/safe-syscall.S | 3 --- 19 files changed, 1 insertion(+), 254 deletions(-) delete mode 100644 linux-user/host/aarch64/hostdep.h delete mode 100644 linux-user/host/arm/hostdep.h delete mode 100644 linux-user/host/i386/hostdep.h delete mode 100644 linux-user/host/ia64/hostdep.h delete mode 100644 linux-user/host/mips/hostdep.h delete mode 100644 linux-user/host/ppc/hostdep.h delete mode 100644 linux-user/host/ppc64/hostdep.h delete mode 100644 linux-user/host/riscv/hostdep.h delete mode 100644 linux-user/host/s390/hostdep.h delete mode 100644 linux-user/host/s390x/hostdep.h delete mode 100644 linux-user/host/sparc/hostdep.h delete mode 100644 linux-user/host/sparc64/hostdep.h delete mode 100644 linux-user/host/x32/hostdep.h delete mode 100644 linux-user/host/x86_64/hostdep.h
linux-user/host/aarch64/hostdep.h deleted +0 -18
@@ -1,18 +0,0 @@ -/* -* hostdep.h : things which are dependent on the host architecture -* -* * Written by Peter Maydell <[email protected]> -* -* Copyright (C) 2016 Linaro Limited -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef AARCH64_HOSTDEP_H -#define AARCH64_HOSTDEP_H - -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL - -#endif
linux-user/host/arm/hostdep.h deleted +0 -18
@@ -1,18 +0,0 @@ -/* -* hostdep.h : things which are dependent on the host architecture -* -* * Written by Peter Maydell <[email protected]> -* -* Copyright (C) 2016 Linaro Limited -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef ARM_HOSTDEP_H -#define ARM_HOSTDEP_H - -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL - -#endif
linux-user/host/i386/hostdep.h deleted +0 -18
@@ -1,18 +0,0 @@ -/* -* hostdep.h : things which are dependent on the host architecture -* -* * Written by Peter Maydell <[email protected]> -* -* Copyright (C) 2016 Linaro Limited -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef I386_HOSTDEP_H -#define I386_HOSTDEP_H - -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL - -#endif
linux-user/host/ia64/hostdep.h deleted +0 -15
@@ -1,15 +0,0 @@ -/* -* hostdep.h : things which are dependent on the host architecture -* -* * Written by Peter Maydell <[email protected]> -* -* Copyright (C) 2016 Linaro Limited -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef IA64_HOSTDEP_H -#define IA64_HOSTDEP_H - -#endif
linux-user/host/mips/hostdep.h deleted +0 -18
@@ -1,18 +0,0 @@ -/* -* hostdep.h : things which are dependent on the host architecture -* -* * Written by Peter Maydell <[email protected]> -* -* Copyright (C) 2016 Linaro Limited -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef MIPS_HOSTDEP_H -#define MIPS_HOSTDEP_H - -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL - -#endif
linux-user/host/ppc/hostdep.h deleted +0 -15
@@ -1,15 +0,0 @@ -/* -* hostdep.h : things which are dependent on the host architecture -* -* * Written by Peter Maydell <[email protected]> -* -* Copyright (C) 2016 Linaro Limited -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef PPC_HOSTDEP_H -#define PPC_HOSTDEP_H - -#endif
linux-user/host/ppc64/hostdep.h deleted +0 -18
@@ -1,18 +0,0 @@ -/* -* hostdep.h : things which are dependent on the host architecture -* -* * Written by Peter Maydell <[email protected]> -* -* Copyright (C) 2016 Linaro Limited -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef PPC64_HOSTDEP_H -#define PPC64_HOSTDEP_H - -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL - -#endif
linux-user/host/riscv/hostdep.h deleted +0 -14
@@ -1,14 +0,0 @@ -/* -* hostdep.h : things which are dependent on the host architecture -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef RISCV_HOSTDEP_H -#define RISCV_HOSTDEP_H - -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL - -#endif
linux-user/host/s390/hostdep.h deleted +0 -15
@@ -1,15 +0,0 @@ -/* -* hostdep.h : things which are dependent on the host architecture -* -* * Written by Peter Maydell <[email protected]> -* -* Copyright (C) 2016 Linaro Limited -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef S390_HOSTDEP_H -#define S390_HOSTDEP_H - -#endif
linux-user/host/s390x/hostdep.h deleted +0 -18
@@ -1,18 +0,0 @@ -/* -* hostdep.h : things which are dependent on the host architecture -* -* * Written by Peter Maydell <[email protected]> -* -* Copyright (C) 2016 Linaro Limited -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef S390X_HOSTDEP_H -#define S390X_HOSTDEP_H - -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL - -#endif
linux-user/host/sparc/hostdep.h deleted +0 -15
@@ -1,15 +0,0 @@ -/* -* hostdep.h : things which are dependent on the host architecture -* -* * Written by Peter Maydell <[email protected]> -* -* Copyright (C) 2016 Linaro Limited -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef SPARC_HOSTDEP_H -#define SPARC_HOSTDEP_H - -#endif
linux-user/host/sparc64/hostdep.h deleted +0 -18
@@ -1,18 +0,0 @@ -/* -* hostdep.h : things which are dependent on the host architecture -* -* * Written by Peter Maydell <[email protected]> -* -* Copyright (C) 2016 Linaro Limited -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef SPARC64_HOSTDEP_H -#define SPARC64_HOSTDEP_H - -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL - -#endif
linux-user/host/x32/hostdep.h deleted +0 -15
@@ -1,15 +0,0 @@ -/* -* hostdep.h : things which are dependent on the host architecture -* -* * Written by Peter Maydell <[email protected]> -* -* Copyright (C) 2016 Linaro Limited -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef X32_HOSTDEP_H -#define X32_HOSTDEP_H - -#endif
linux-user/host/x86_64/hostdep.h deleted +0 -18
@@ -1,18 +0,0 @@ -/* -* hostdep.h : things which are dependent on the host architecture -* -* * Written by Peter Maydell <[email protected]> -* -* Copyright (C) 2016 Linaro Limited -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef X86_64_HOSTDEP_H -#define X86_64_HOSTDEP_H - -/* We have a safe-syscall.inc.S */ -#define HAVE_SAFE_SYSCALL - -#endif
linux-user/safe-syscall.h +1 -12
@@ -124,7 +124,7 @@* need to check SA_RESTART flags in QEMU or distinguish the various * kinds of restartability. */ -#ifdef HAVE_SAFE_SYSCALL +/* The core part of this function is implemented in assembly */ extern long safe_syscall_base (int *pending,long number, ...);extern long safe_syscall_set_errno_tail (int value);
@@ -137,15 +137,4 @@ extern char safe_syscall_end[];safe_syscall_base (&((TaskState *)thread_cpu->opaque)->signal_pending, \ __VA_ARGS__) -#else - -/* -* Fallback for architectures which don't yet provide a safe-syscall assembly -* fragment; note that this is racy! -* This should go away when all host architectures have been updated. -*/ -#define safe_syscall syscall - -#endif -#endif
linux-user/user-internals.h +0 -1
@@ -18,7 +18,6 @@#ifndef LINUX_USER_USER_INTERNALS_H #define LINUX_USER_USER_INTERNALS_H -#include "hostdep.h" #include "exec/user/thunk.h" #include "exec/exec-all.h" #include "qemu/log.h"
linux-user/safe-syscall-error.c +0 -3
@@ -10,10 +10,8 @@*/ #include "qemu/osdep.h" -#include "hostdep.h" #include "safe-syscall.h" -#ifdef HAVE_SAFE_SYSCALL /* * This is intended to be invoked via tail-call on the error path * from the assembly in host/arch/safe-syscall.inc.S. This takes
@@ -25,4 +23,3 @@ long safe_syscall_set_errno_tail(int value) errno = value;return -1 ; } -#endif
linux-user/signal.c +0 -2
@@ -798,7 +798,6 @@ int queue_signal(CPUArchState *env, int sig, int si_type,/* Adjust the signal context to rewind out of safe-syscall if we're in it */ static inline void rewind_if_in_safe_syscall (void *puc) { -#ifdef HAVE_SAFE_SYSCALL ucontext_t *uc = (ucontext_t *)puc;uintptr_t pcreg =host_signal_pc (uc);
@@ -806,7 +805,6 @@ static inline void rewind_if_in_safe_syscall(void *puc) && pcreg < (uintptr_t)safe_syscall_end) {host_signal_set_pc (uc, (uintptr_t )safe_syscall_start); } -#endif }static void host_signal_handler (int host_sig,siginfo_t *info,void *puc)
linux-user/safe-syscall.S +0 -3
@@ -10,15 +10,12 @@ * See the COPYING file in the top-level directory. */ -#include "hostdep.h" #include "target_errno_defs.h" /* We have the correct host directory on our include path * so that this will pull in the right fragment for the architecture. */ -#ifdef HAVE_SAFE_SYSCALL #include "safe-syscall.inc.S" -#endif /* We must specifically say that we're happy for the stack to not be * executable, otherwise the toolchain will default to assuming our
Signature · 1 line
2.25.1
[PULL 11/15] common-user: Move safe-syscall.* from linux-user
In reply to Richard HendersonMove linux-user safe-syscall.S and safe-syscall-error.c to common-user so that bsd-user can also use it. Also move safe-syscall.h to include/user/. Since there is nothing here that is related to the guest, as opposed to the host, build it once.
---
meson.build | 18 +++++++++++++++++-
{linux-user => include/user}/safe-syscall.h | 0
.../safe-syscall-error.c | 2 +-
linux-user/signal.c | 2 +-
linux-user/syscall.c | 2 +-
MAINTAINERS | 2 ++
bsd-user/meson.build | 2 ++
.../host/aarch64/safe-syscall.inc.S | 2 +-
.../host/arm/safe-syscall.inc.S | 2 +-
.../host/i386/safe-syscall.inc.S | 2 +-
.../host/mips/safe-syscall.inc.S | 2 +-
.../host/ppc64/safe-syscall.inc.S | 2 +-
.../host/riscv/safe-syscall.inc.S | 2 +-
.../host/s390x/safe-syscall.inc.S | 2 +-
.../host/sparc64/safe-syscall.inc.S | 2 +-
.../host/x86_64/safe-syscall.inc.S | 2 +-
common-user/meson.build | 6 ++++++
{linux-user => common-user}/safe-syscall.S | 0
linux-user/meson.build | 5 +++--
19 files changed, 42 insertions(+), 15 deletions(-)
rename {linux-user => include/user}/safe-syscall.h (100%)
rename {linux-user => common-user}/safe-syscall-error.c (95%)
rename {linux-user => common-user}/host/aarch64/safe-syscall.inc.S (97%)
rename {linux-user => common-user}/host/arm/safe-syscall.inc.S (98%)
rename {linux-user => common-user}/host/i386/safe-syscall.inc.S (98%)
rename {linux-user => common-user}/host/mips/safe-syscall.inc.S (98%)
rename {linux-user => common-user}/host/ppc64/safe-syscall.inc.S (98%)
rename {linux-user => common-user}/host/riscv/safe-syscall.inc.S (97%)
rename {linux-user => common-user}/host/s390x/safe-syscall.inc.S (98%)
rename {linux-user => common-user}/host/sparc64/safe-syscall.inc.S (97%)
rename {linux-user => common-user}/host/x86_64/safe-syscall.inc.S (98%)
create mode 100644 common-user/meson.build
rename {linux-user => common-user}/safe-syscall.S (100%)meson.build +17 -1
@@ -2378,6 +2378,7 @@ block_ss = ss.source_set() bsd_user_ss = ss.source_set() chardev_ss = ss.source_set() common_ss = ss.source_set() +common_user_ss = ss.source_set() crypto_ss = ss.source_set() hwcore_ss = ss.source_set() io_ss = ss.source_set()
@@ -2622,15 +2623,30 @@ subdir('tcg') subdir('fpu') subdir('accel') subdir('plugins') +subdir('ebpf') + +common_user_inc = [] + +subdir('common-user') subdir('bsd-user') subdir('linux-user') -subdir('ebpf') specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss) linux_user_ss.add(files('thunk.c')) specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss) +common_user_ss = common_user_ss.apply(config_all, strict: false) +common_user = static_library('common-user', + sources: common_user_ss.sources(), + dependencies: common_user_ss.dependencies(), + include_directories: common_user_inc, + name_suffix: 'fa', + build_by_default: false) +common_user = declare_dependency(link_with: common_user) + +user_ss.add(common_user) + # needed for fuzzing binaries subdir('tests/qtest/libqos') subdir('tests/qtest/fuzz')
include/user/safe-syscall.h renamed from linux-user/safe-syscall.h +0 -0
common-user/safe-syscall-error.c renamed from linux-user/safe-syscall-error.c +1 -1
@@ -10,7 +10,7 @@*/ #include "qemu/osdep.h" -#include "safe-syscall.h" +#include "user/safe-syscall.h" /* * This is intended to be invoked via tail-call on the error path
linux-user/signal.c +1 -1
@@ -31,7 +31,7 @@#include "trace.h" #include "signal-common.h" #include "host-signal.h" -#include "safe-syscall.h" +#include "user/safe-syscall.h" static struct target_sigaction sigact_table[TARGET_NSIG ];
linux-user/syscall.c +1 -1
@@ -132,7 +132,7 @@#include "signal-common.h" #include "loader.h" #include "user-mmap.h" -#include "safe-syscall.h" +#include "user/safe-syscall.h" #include "qemu/guest-random.h" #include "qemu/selfmap.h" #include "user/syscall-trace.h"
MAINTAINERS +2 -0
@@ -3079,6 +3079,8 @@ M: Riku Voipio <[email protected]> S: Maintained F: thunk.c F: accel/tcg/user-exec*.c +F: include/user/ +F: common-user/ BSD user M: Warner Losh <[email protected]>
bsd-user/meson.build +2 -0
@@ -2,6 +2,8 @@ if not have_bsd_user subdir_done() endif +common_user_inc += include_directories('.') + bsd_user_ss.add(files( 'bsdload.c', 'elfload.c',
common-user/host/aarch64/safe-syscall.inc.S renamed from linux-user/host/aarch64/safe-syscall.inc.S +1 -1
@@ -1,7 +1,7 @@ /* * safe-syscall.inc.S : host-specific assembly fragment * to handle signals occurring at the same time as system calls. - * This is intended to be included by linux-user/safe-syscall.S + * This is intended to be included by common-user/safe-syscall.S * * Written by Richard Henderson <[email protected]> * Copyright (C) 2016 Red Hat, Inc.
common-user/host/arm/safe-syscall.inc.S renamed from linux-user/host/arm/safe-syscall.inc.S +1 -1
@@ -1,7 +1,7 @@ /* * safe-syscall.inc.S : host-specific assembly fragment * to handle signals occurring at the same time as system calls. - * This is intended to be included by linux-user/safe-syscall.S + * This is intended to be included by common-user/safe-syscall.S * * Written by Richard Henderson <[email protected]> * Copyright (C) 2016 Red Hat, Inc.
common-user/host/i386/safe-syscall.inc.S renamed from linux-user/host/i386/safe-syscall.inc.S +1 -1
@@ -1,7 +1,7 @@ /* * safe-syscall.inc.S : host-specific assembly fragment * to handle signals occurring at the same time as system calls. - * This is intended to be included by linux-user/safe-syscall.S + * This is intended to be included by common-user/safe-syscall.S * * Written by Richard Henderson <[email protected]> * Copyright (C) 2016 Red Hat, Inc.
common-user/host/mips/safe-syscall.inc.S renamed from linux-user/host/mips/safe-syscall.inc.S +1 -1
@@ -1,7 +1,7 @@ /* * safe-syscall.inc.S : host-specific assembly fragment * to handle signals occurring at the same time as system calls. - * This is intended to be included by linux-user/safe-syscall.S + * This is intended to be included by common-user/safe-syscall.S * * Written by Richard Henderson <[email protected]> * Copyright (C) 2021 Linaro, Inc.
common-user/host/ppc64/safe-syscall.inc.S renamed from linux-user/host/ppc64/safe-syscall.inc.S +1 -1
@@ -1,7 +1,7 @@ /* * safe-syscall.inc.S : host-specific assembly fragment * to handle signals occurring at the same time as system calls. - * This is intended to be included by linux-user/safe-syscall.S + * This is intended to be included by common-user/safe-syscall.S * * Written by Richard Henderson <[email protected]> * Copyright (C) 2016 Red Hat, Inc.
common-user/host/riscv/safe-syscall.inc.S renamed from linux-user/host/riscv/safe-syscall.inc.S +1 -1
@@ -1,7 +1,7 @@ /* * safe-syscall.inc.S : host-specific assembly fragment * to handle signals occurring at the same time as system calls. - * This is intended to be included by linux-user/safe-syscall.S + * This is intended to be included by common-user/safe-syscall.S * * Written by Richard Henderson <[email protected]> * Copyright (C) 2018 Linaro, Inc.
common-user/host/s390x/safe-syscall.inc.S renamed from linux-user/host/s390x/safe-syscall.inc.S +1 -1
@@ -1,7 +1,7 @@ /* * safe-syscall.inc.S : host-specific assembly fragment * to handle signals occurring at the same time as system calls. - * This is intended to be included by linux-user/safe-syscall.S + * This is intended to be included by common-user/safe-syscall.S * * Written by Richard Henderson <[email protected]> * Copyright (C) 2016 Red Hat, Inc.
common-user/host/sparc64/safe-syscall.inc.S renamed from linux-user/host/sparc64/safe-syscall.inc.S +1 -1
@@ -1,7 +1,7 @@ /* * safe-syscall.inc.S : host-specific assembly fragment * to handle signals occurring at the same time as system calls. - * This is intended to be included by linux-user/safe-syscall.S + * This is intended to be included by common-user/safe-syscall.S * * Written by Richard Henderson <[email protected]> * Copyright (C) 2021 Linaro, Inc.
common-user/host/x86_64/safe-syscall.inc.S renamed from linux-user/host/x86_64/safe-syscall.inc.S +1 -1
@@ -1,7 +1,7 @@ /* * safe-syscall.inc.S : host-specific assembly fragment * to handle signals occurring at the same time as system calls. - * This is intended to be included by linux-user/safe-syscall.S + * This is intended to be included by common-user/safe-syscall.S * * Copyright (C) 2015 Timothy Edward Baldwin <[email protected]> *
common-user/meson.build new file +6 -0
@@ -0,0 +1,6 @@ +common_user_inc += include_directories('host/' / host_arch) + +common_user_ss.add(files( + 'safe-syscall.S', + 'safe-syscall-error.c', +))
common-user/safe-syscall.S renamed from linux-user/safe-syscall.S +0 -0
linux-user/meson.build +3 -2
@@ -2,6 +2,9 @@ if not have_linux_user subdir_done() endif +common_user_inc += include_directories('host/' / host_arch) +common_user_inc += include_directories('.') + linux_user_ss.add(files( 'elfload.c', 'exit.c',
@@ -9,8 +12,6 @@ linux_user_ss.add(files( 'linuxload.c', 'main.c', 'mmap.c', - 'safe-syscall.S', - 'safe-syscall-error.c', 'signal.c', 'strace.c', 'syscall.c',
Signature · 1 line
2.25.1
[PULL 10/15] bsd-user: Create special-errno.h
In reply to Richard HendersonPull the internal errno used by qemu internally its own header file, for use by safe-syscall.S.
--- bsd-user/errno_defs.h | 6 +++++- bsd-user/special-errno.h | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 bsd-user/special-errno.h
bsd-user/errno_defs.h +5 -1
@@ -151,6 +151,10 @@/* Internal errors: */ #define TARGET_EJUSTRETURN 254/* Just return without modifing regs */ #define TARGET_ERESTART 255/* Restart syscall */ -#define QEMU_ERESTARTSYS TARGET_ERESTART + +#include "special-errno.h" + +_Static_assert (TARGET_ERESTART ==QEMU_ERESTARTSYS , +"TARGET_ERESTART and QEMU_ERESTARTSYS expected to match" );#endif /* ! _ERRNO_DEFS_H_ */
bsd-user/special-errno.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* +* QEMU internal errno values for implementing user-only POSIX. +* +* Copyright (c) 2021 Linaro, Ltd. +*/ + +#ifndef SPECIAL_ERRNO_H +#define SPECIAL_ERRNO_H + +/* +* All of these are QEMU internal, not visible to the guest. +* They should be chosen so as to not overlap with any host +* or guest errno. +*/ + +/* +* This is returned when a system call should be restarted, to tell the +* main loop that it should wind the guest PC backwards so it will +* re-execute the syscall after handling any pending signals. +*/ +#define QEMU_ERESTARTSYS 255 + +#endif /* SPECIAL_ERRNO_H */
Signature · 1 line
2.25.1
[PULL 09/15] linux-user: Create special-errno.h
In reply to Richard HendersonPull the two internal errno used by qemu internally into their own header file. This includes the one define required by safe-syscall.S.
--- linux-user/cpu_loop-common.h | 1 + linux-user/generic/target_errno_defs.h | 17 -------------- linux-user/signal-common.h | 2 ++ linux-user/special-errno.h | 32 ++++++++++++++++++++++++++ linux-user/syscall.c | 1 + linux-user/safe-syscall.S | 2 +- 6 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 linux-user/special-errno.h
linux-user/cpu_loop-common.h +1 -0
@@ -21,6 +21,7 @@#define CPU_LOOP_COMMON_H #include "exec/log.h" +#include "special-errno.h" #define EXCP_DUMP (env, fmt, ...) \ do { \
linux-user/generic/target_errno_defs.h +0 -17
@@ -147,21 +147,4 @@#define TARGET_ERFKILL 132/* Operation not possible due to RF-kill */ #define TARGET_EHWPOISON 133/* Memory page has hardware error */ -/* QEMU internal, not visible to the guest. This is returned when a -* system call should be restarted, to tell the main loop that it -* should wind the guest PC backwards so it will re-execute the syscall -* after handling any pending signals. They match with the ones the guest -* kernel uses for the same purpose. -*/ -#define QEMU_ERESTARTSYS 512/* Restart system call (if SA_RESTART) */ - -/* QEMU internal, not visible to the guest. This is returned by the -* do_sigreturn() code after a successful sigreturn syscall, to indicate -* that it has correctly set the guest registers and so the main loop -* should not touch them. We use the value the guest would use for -* ERESTART_NOINTR (which is kernel internal) to guarantee that we won't -* clash with a valid guest errno now or in the future. -*/ -#define QEMU_ESIGRETURN 513/* Return from signal */ -#endif
linux-user/signal-common.h +2 -0
@@ -20,6 +20,8 @@#ifndef SIGNAL_COMMON_H #define SIGNAL_COMMON_H +#include "special-errno.h" +/* Fallback addresses into sigtramp page. */ extern abi_ulong default_sigreturn;extern abi_ulong default_rt_sigreturn;
linux-user/special-errno.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* QEMU internal errno values for implementing user-only POSIX. +* +* Copyright (c) 2003 Fabrice Bellard +* Copyright (c) 2021 Linaro, Ltd. +*/ + +#ifndef SPECIAL_ERRNO_H +#define SPECIAL_ERRNO_H + +/* +* All of these are QEMU internal, not visible to the guest. +* They should be chosen so as to not overlap with any host +* or guest errno. +*/ + +/* +* This is returned when a system call should be restarted, to tell the +* main loop that it should wind the guest PC backwards so it will +* re-execute the syscall after handling any pending signals. +*/ +#define QEMU_ERESTARTSYS 512 + +/* +* This is returned after a successful sigreturn syscall, to indicate +* that it has correctly set the guest registers and so the main loop +* should not touch them. +*/ +#define QEMU_ESIGRETURN 513 + +#endif /* SPECIAL_ERRNO_H */
linux-user/syscall.c +1 -0
@@ -136,6 +136,7 @@#include "qemu/guest-random.h" #include "qemu/selfmap.h" #include "user/syscall-trace.h" +#include "special-errno.h" #include "qapi/error.h" #include "fd-trans.h" #include "tcg/tcg.h"
linux-user/safe-syscall.S +1 -1
@@ -10,7 +10,7 @@ * See the COPYING file in the top-level directory. */ -#include "target_errno_defs.h" +#include "special-errno.h" /* We have the correct host directory on our include path * so that this will pull in the right fragment for the architecture.
Signature · 1 line
2.25.1
Richard Henderson
AppliedQuoted 145 lines · Richard Henderson
The following changes since commit
212a33d3b0c65ae2583bb1d06cb140cd0890894c:Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2021-12-19 16:36:10 -0800)are available in the Git repository at:
https://gitlab.com/rth7680/qemu.git tags/pull-user-20211220for you to fetch changes up to
3363615a65af8a09d8adbd19ed3ae6b52f26ca7a:meson: Move bsd_user_ss to bsd-user/ (2021-12-20 10:13:43 -0800)----------------------------------------------------------------
Move errno processing fromsafe_syscall()tosafe_syscall_base(). Movesafe_syscall()from linux-user to common-user.
Add FreeBSD support tosafe_syscall_base().
Tidy top-level meson.build wrt {bsd,linux}-user.----------------------------------------------------------------
Richard Henderson (15):
linux-user: Untabify allsafe-syscall.inc.S
linux-user: Move syscall error detection intosafe_syscall_baselinux-user/host/mips: Addsafe-syscall.inc.Slinux-user/host/sparc64: Addsafe-syscall.inc.S
linux-user: RemoveHAVE_SAFE_SYSCALLandhostdep.h
linux-user: RenameTARGET_ERESTARTSYStoQEMU_ERESTARTSYS
bsd-user: RenameTARGET_ERESTARTSYStoQEMU_ERESTARTSYS
linux-user: RenameTARGET_QEMU_ESIGRETURNtoQEMU_ESIGRETURN
linux-user: Createspecial-errno.h
bsd-user: Createspecial-errno.h
common-user: Move safe-syscall.* from linux-user
common-user: Adjust system call return on FreeBSD
linux-user: Movethunk.cfrom top-level
meson: Movelinux_user_ssto linux-user/
meson: Movebsd_user_ssto bsd-user/meson.build | 23 +++- bsd-user/errno_defs.h | 6 +- bsd-user/special-errno.h | 24 ++++ {linux-user => include/user}/safe-syscall.h | 37 ++---- linux-user/cpu_loop-common.h | 1 + linux-user/generic/target_errno_defs.h | 17 --- linux-user/host/aarch64/hostdep.h | 18 --- linux-user/host/arm/hostdep.h | 18 --- linux-user/host/i386/hostdep.h | 18 --- linux-user/host/ia64/hostdep.h | 15 --- linux-user/host/mips/hostdep.h | 15 --- linux-user/host/ppc/hostdep.h | 15 --- linux-user/host/ppc64/hostdep.h | 18 --- linux-user/host/riscv/hostdep.h | 14 -- linux-user/host/s390/hostdep.h | 15 --- linux-user/host/s390x/hostdep.h | 18 --- linux-user/host/sparc/hostdep.h | 15 --- linux-user/host/sparc64/hostdep.h | 15 --- linux-user/host/x32/hostdep.h | 15 --- linux-user/host/x86_64/hostdep.h | 18 --- linux-user/signal-common.h | 4 +- linux-user/special-errno.h | 32 +++++ linux-user/user-internals.h | 1 - common-user/safe-syscall-error.c | 25 ++++ linux-user/aarch64/cpu_loop.c | 4 +- linux-user/aarch64/signal.c | 4 +- linux-user/alpha/cpu_loop.c | 4 +- linux-user/alpha/signal.c | 8 +- linux-user/arm/cpu_loop.c | 4 +- linux-user/arm/signal.c | 8 +- linux-user/cris/cpu_loop.c | 4 +- linux-user/cris/signal.c | 4 +- linux-user/hexagon/cpu_loop.c | 4 +- linux-user/hexagon/signal.c | 2 +- linux-user/hppa/cpu_loop.c | 4 +- linux-user/hppa/signal.c | 4 +- linux-user/i386/cpu_loop.c | 12 +- linux-user/i386/signal.c | 8 +- linux-user/m68k/cpu_loop.c | 4 +- linux-user/m68k/signal.c | 8 +- linux-user/microblaze/cpu_loop.c | 4 +- linux-user/microblaze/signal.c | 4 +- linux-user/mips/cpu_loop.c | 4 +- linux-user/mips/signal.c | 8 +- linux-user/openrisc/cpu_loop.c | 4 +- linux-user/ppc/cpu_loop.c | 4 +- linux-user/ppc/signal.c | 10 +- linux-user/riscv/cpu_loop.c | 4 +- linux-user/riscv/signal.c | 2 +- linux-user/s390x/cpu_loop.c | 4 +- linux-user/s390x/signal.c | 8 +- linux-user/sh4/cpu_loop.c | 4 +- linux-user/sh4/signal.c | 8 +- linux-user/signal.c | 10 +- linux-user/sparc/cpu_loop.c | 2 +- linux-user/sparc/signal.c | 8 +- linux-user/syscall.c | 21 +-- thunk.c => linux-user/thunk.c | 0 linux-user/xtensa/cpu_loop.c | 4 +- linux-user/xtensa/signal.c | 4 +- MAINTAINERS | 3 +- bsd-user/meson.build | 6 + common-user/host/aarch64/safe-syscall.inc.S | 88 ++++++++++++ common-user/host/arm/safe-syscall.inc.S | 108 +++++++++++++++ common-user/host/i386/safe-syscall.inc.S | 126 ++++++++++++++++++ common-user/host/mips/safe-syscall.inc.S | 148 +++++++++++++++++++++ common-user/host/ppc64/safe-syscall.inc.S | 94 +++++++++++++ common-user/host/riscv/safe-syscall.inc.S | 79 +++++++++++ common-user/host/s390x/safe-syscall.inc.S | 98 ++++++++++++++ common-user/host/sparc64/safe-syscall.inc.S | 89 +++++++++++++ .../host/x86_64/safe-syscall.inc.S | 44 +++--- common-user/meson.build | 6 + {linux-user => common-user}/safe-syscall.S | 5 +- linux-user/host/aarch64/safe-syscall.inc.S | 75 ----------- linux-user/host/arm/safe-syscall.inc.S | 90 ------------- linux-user/host/i386/safe-syscall.inc.S | 100 -------------- linux-user/host/ppc64/safe-syscall.inc.S | 96 ------------- linux-user/host/riscv/safe-syscall.inc.S | 77 ----------- linux-user/host/s390x/safe-syscall.inc.S | 90 ------------- linux-user/meson.build | 9 +- 80 files changed, 1099 insertions(+), 932 deletions(-)create mode 100644
bsd-user/special-errno.h
rename {linux-user =>include/user}/safe-syscall.h(83%) delete mode 100644linux-user/host/aarch64/hostdep.h
delete mode 100644linux-user/host/arm/hostdep.h
delete mode 100644linux-user/host/i386/hostdep.h
delete mode 100644linux-user/host/ia64/hostdep.h
delete mode 100644linux-user/host/mips/hostdep.h
delete mode 100644linux-user/host/ppc/hostdep.h
delete mode 100644linux-user/host/ppc64/hostdep.h
delete mode 100644linux-user/host/riscv/hostdep.h
delete mode 100644linux-user/host/s390/hostdep.h
delete mode 100644linux-user/host/s390x/hostdep.h
delete mode 100644linux-user/host/sparc/hostdep.h
delete mode 100644linux-user/host/sparc64/hostdep.h
delete mode 100644linux-user/host/x32/hostdep.h
delete mode 100644linux-user/host/x86_64/hostdep.h
create mode 100644linux-user/special-errno.h
create mode 100644common-user/safe-syscall-error.c
renamethunk.c=>linux-user/thunk.c(100%)
create mode 100644common-user/host/aarch64/safe-syscall.inc.Screate mode 100644common-user/host/arm/safe-syscall.inc.Screate mode 100644common-user/host/i386/safe-syscall.inc.Screate mode 100644common-user/host/mips/safe-syscall.inc.Screate mode 100644common-user/host/ppc64/safe-syscall.inc.Screate mode 100644common-user/host/riscv/safe-syscall.inc.Screate mode 100644common-user/host/s390x/safe-syscall.inc.Screate mode 100644common-user/host/sparc64/safe-syscall.inc.Srename {linux-user =>common-user}/host/x86_64/safe-syscall.inc.S(81%)
Quoted 8 lines
create mode 100644 common-user/meson.build
rename {linux-user =>common-user}/safe-syscall.S(91%) delete mode 100644linux-user/host/aarch64/safe-syscall.inc.Sdelete mode 100644linux-user/host/arm/safe-syscall.inc.Sdelete mode 100644linux-user/host/i386/safe-syscall.inc.Sdelete mode 100644linux-user/host/ppc64/safe-syscall.inc.Sdelete mode 100644linux-user/host/riscv/safe-syscall.inc.Sdelete mode 100644linux-user/host/s390x/safe-syscall.inc.S
Applied.
r~