* [PATCH v5 00/17] linux-user: simplify safe signal handling
@ 2021-11-17 16:03 Richard Henderson
2021-11-17 16:03 ` [PATCH v5 01/17] linux-user: Add host_signal_set_pc to set pc in mcontext Richard Henderson
` (17 more replies)
0 siblings, 18 replies; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:03 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp
Warner's v3:
https://patchew.org/QEMU/20211113045603.60391-1-imp@bsdimp.com/
Changes for v5:
* Fix safe-syscall.S FreeBSD typos.
* Rename special TARGET_EFOO to QEMU_EFOO.
* Create *-user/special-errno.h.
* Build safe-syscall.o only once.
* meson.build cleanups.
* bsd-user builds without modification on master.
Changes for v4:
* Move errno handling into the assembly. While returning the
raw -errno is handy for x86 linux (and a few others), it is
in fact more complex for other hosts that return a separate
error indicator. At which point we wind up jumping through
hoops to return -errno, only to have the caller put it right
back into +errno with -1 result, just like syscall(3).
Pass in &errno, because the method of calculating this
varies wildly between glibc, musl, etc. This means that
the assembly need only store to a provided pointer.
* Add mips and sparc safe-syscall implementations.
Both of which, btw, have separate error indicators. ;-)
* All hosts now have it, so remove HAVE_SAFE_SYSCALL.
* Add meson.build rules for common-user/safe-syscall.S, so
that we don't have to have weird includes from *-user.
r~
Richard Henderson (13):
common-user: Move syscall error detection into safe_syscall_base
common-user/host/mips: Add safe-syscall.inc.S
common-user/host/sparc64: Add safe-syscall.inc.S
linux-user: Remove HAVE_SAFE_SYSCALL and hostdep.h
*-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS
linux-user: Rename TARGET_QEMU_ESIGRETURN to QEMU_ESIGRETURN
bsd-user: Create special-errno.h
linux-user: Create special-errno.h
meson: Add build infrastructure for common-user
common-user: Move safe-syscall.* from linux-user
linux-user: Move thunk.c from top-level
meson: Move linux_user_ss to linux-user/
meson: Move bsd_user_ss to bsd-user/
Warner Losh (4):
linux-user: Add host_signal_set_pc to set pc in mcontext
linux-user/signal.c: Create a common rewind_if_in_safe_syscall
linux-user/safe-syscall.inc.S: Move to common-user
common-user: Adjust system call return on FreeBSD
meson.build | 23 ++-
bsd-user/errno_defs.h | 6 +-
bsd-user/special-errno.h | 24 ++++
{linux-user => include/user}/safe-syscall.h | 39 ++---
linux-user/cpu_loop-common.h | 1 +
linux-user/generic/target_errno_defs.h | 17 ---
linux-user/host/aarch64/host-signal.h | 5 +
linux-user/host/aarch64/hostdep.h | 38 -----
linux-user/host/alpha/host-signal.h | 5 +
linux-user/host/arm/host-signal.h | 5 +
linux-user/host/arm/hostdep.h | 38 -----
linux-user/host/i386/host-signal.h | 5 +
linux-user/host/i386/hostdep.h | 38 -----
linux-user/host/ia64/hostdep.h | 15 --
linux-user/host/mips/host-signal.h | 5 +
linux-user/host/mips/hostdep.h | 15 --
linux-user/host/ppc/host-signal.h | 5 +
linux-user/host/ppc/hostdep.h | 15 --
linux-user/host/ppc64/hostdep.h | 38 -----
linux-user/host/riscv/host-signal.h | 5 +
linux-user/host/riscv/hostdep.h | 34 -----
linux-user/host/s390/host-signal.h | 5 +
linux-user/host/s390/hostdep.h | 15 --
linux-user/host/s390x/hostdep.h | 38 -----
linux-user/host/sparc/host-signal.h | 9 ++
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/host-signal.h | 5 +
linux-user/host/x86_64/hostdep.h | 38 -----
linux-user/signal-common.h | 4 +-
linux-user/special-errno.h | 32 +++++
linux-user/user-internals.h | 1 -
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 | 19 ++-
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 +-
bsd-user/meson.build | 6 +
.../host/aarch64/safe-syscall.inc.S | 65 ++++++---
.../host/arm/safe-syscall.inc.S | 69 ++++++---
.../host/i386/safe-syscall.inc.S | 61 +++++---
common-user/host/mips/safe-syscall.inc.S | 135 ++++++++++++++++++
.../host/ppc64/safe-syscall.inc.S | 63 ++++----
.../host/riscv/safe-syscall.inc.S | 50 ++++---
.../host/s390x/safe-syscall.inc.S | 50 ++++---
common-user/host/sparc64/safe-syscall.inc.S | 91 ++++++++++++
.../host/x86_64/safe-syscall.inc.S | 80 +++++++----
common-user/meson.build | 3 +
{linux-user => common-user}/safe-syscall.S | 5 +-
linux-user/meson.build | 9 +-
82 files changed, 778 insertions(+), 689 deletions(-)
create mode 100644 bsd-user/special-errno.h
rename {linux-user => include/user}/safe-syscall.h (81%)
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
rename thunk.c => linux-user/thunk.c (100%)
rename {linux-user => common-user}/host/aarch64/safe-syscall.inc.S (64%)
rename {linux-user => common-user}/host/arm/safe-syscall.inc.S (64%)
rename {linux-user => common-user}/host/i386/safe-syscall.inc.S (71%)
create mode 100644 common-user/host/mips/safe-syscall.inc.S
rename {linux-user => common-user}/host/ppc64/safe-syscall.inc.S (68%)
rename {linux-user => common-user}/host/riscv/safe-syscall.inc.S (77%)
rename {linux-user => common-user}/host/s390x/safe-syscall.inc.S (71%)
create mode 100644 common-user/host/sparc64/safe-syscall.inc.S
rename {linux-user => common-user}/host/x86_64/safe-syscall.inc.S (64%)
create mode 100644 common-user/meson.build
rename {linux-user => common-user}/safe-syscall.S (91%)
--
2.25.1
^ permalink raw reply [flat|nested] 46+ messages in thread
* [PATCH v5 01/17] linux-user: Add host_signal_set_pc to set pc in mcontext
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
@ 2021-11-17 16:03 ` Richard Henderson
2021-11-17 16:23 ` Warner Losh
2021-11-17 16:37 ` Alex Bennée
2021-11-17 16:03 ` [PATCH v5 02/17] linux-user/signal.c: Create a common rewind_if_in_safe_syscall Richard Henderson
` (16 subsequent siblings)
17 siblings, 2 replies; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:03 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp, Philippe Mathieu-Daudé
From: Warner Losh <imp@bsdimp.com>
Add a new function host_signal_set_pc to set the next pc in an
mcontext. The caller should ensure this is a valid PC for execution.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20211113045603.60391-2-imp@bsdimp.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/host/aarch64/host-signal.h | 5 +++++
linux-user/host/alpha/host-signal.h | 5 +++++
linux-user/host/arm/host-signal.h | 5 +++++
linux-user/host/i386/host-signal.h | 5 +++++
linux-user/host/mips/host-signal.h | 5 +++++
linux-user/host/ppc/host-signal.h | 5 +++++
linux-user/host/riscv/host-signal.h | 5 +++++
linux-user/host/s390/host-signal.h | 5 +++++
linux-user/host/sparc/host-signal.h | 9 +++++++++
linux-user/host/x86_64/host-signal.h | 5 +++++
10 files changed, 54 insertions(+)
diff --git a/linux-user/host/aarch64/host-signal.h b/linux-user/host/aarch64/host-signal.h
index 0c0b08383a..9770b36dc1 100644
--- a/linux-user/host/aarch64/host-signal.h
+++ b/linux-user/host/aarch64/host-signal.h
@@ -35,6 +35,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
return uc->uc_mcontext.pc;
}
+static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+{
+ uc->uc_mcontext.pc = pc;
+}
+
static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
{
struct _aarch64_ctx *hdr;
diff --git a/linux-user/host/alpha/host-signal.h b/linux-user/host/alpha/host-signal.h
index e080be412f..f4c942948a 100644
--- a/linux-user/host/alpha/host-signal.h
+++ b/linux-user/host/alpha/host-signal.h
@@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
return uc->uc_mcontext.sc_pc;
}
+static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+{
+ uc->uc_mcontext.sc_pc = pc;
+}
+
static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
{
uint32_t *pc = (uint32_t *)host_signal_pc(uc);
diff --git a/linux-user/host/arm/host-signal.h b/linux-user/host/arm/host-signal.h
index efb165c0c5..6c095773c0 100644
--- a/linux-user/host/arm/host-signal.h
+++ b/linux-user/host/arm/host-signal.h
@@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
return uc->uc_mcontext.arm_pc;
}
+static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+{
+ uc->uc_mcontext.arm_pc = pc;
+}
+
static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
{
/*
diff --git a/linux-user/host/i386/host-signal.h b/linux-user/host/i386/host-signal.h
index 4c8eef99ce..abe1ece5c9 100644
--- a/linux-user/host/i386/host-signal.h
+++ b/linux-user/host/i386/host-signal.h
@@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
return uc->uc_mcontext.gregs[REG_EIP];
}
+static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+{
+ uc->uc_mcontext.gregs[REG_EIP] = pc;
+}
+
static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
{
return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe
diff --git a/linux-user/host/mips/host-signal.h b/linux-user/host/mips/host-signal.h
index ef341f7c20..c666ed8c3f 100644
--- a/linux-user/host/mips/host-signal.h
+++ b/linux-user/host/mips/host-signal.h
@@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
return uc->uc_mcontext.pc;
}
+static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+{
+ uc->uc_mcontext.pc = pc;
+}
+
#if defined(__misp16) || defined(__mips_micromips)
#error "Unsupported encoding"
#endif
diff --git a/linux-user/host/ppc/host-signal.h b/linux-user/host/ppc/host-signal.h
index a491c413dc..1d8e658ff7 100644
--- a/linux-user/host/ppc/host-signal.h
+++ b/linux-user/host/ppc/host-signal.h
@@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
return uc->uc_mcontext.regs->nip;
}
+static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+{
+ uc->uc_mcontext.regs->nip = pc;
+}
+
static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
{
return uc->uc_mcontext.regs->trap != 0x400
diff --git a/linux-user/host/riscv/host-signal.h b/linux-user/host/riscv/host-signal.h
index 3b168cb58b..a4f170efb0 100644
--- a/linux-user/host/riscv/host-signal.h
+++ b/linux-user/host/riscv/host-signal.h
@@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
return uc->uc_mcontext.__gregs[REG_PC];
}
+static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+{
+ uc->uc_mcontext.__gregs[REG_PC] = pc;
+}
+
static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
{
/*
diff --git a/linux-user/host/s390/host-signal.h b/linux-user/host/s390/host-signal.h
index 26990e4893..a524f2ab00 100644
--- a/linux-user/host/s390/host-signal.h
+++ b/linux-user/host/s390/host-signal.h
@@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
return uc->uc_mcontext.psw.addr;
}
+static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+{
+ uc->uc_mcontext.psw.addr = pc;
+}
+
static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
{
uint16_t *pinsn = (uint16_t *)host_signal_pc(uc);
diff --git a/linux-user/host/sparc/host-signal.h b/linux-user/host/sparc/host-signal.h
index 5e71d33f8e..7342936071 100644
--- a/linux-user/host/sparc/host-signal.h
+++ b/linux-user/host/sparc/host-signal.h
@@ -20,6 +20,15 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
#endif
}
+static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+{
+#ifdef __arch64__
+ uc->uc_mcontext.mc_gregs[MC_PC] = pc;
+#else
+ uc->uc_mcontext.gregs[REG_PC] = pc;
+#endif
+}
+
static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
{
uint32_t insn = *(uint32_t *)host_signal_pc(uc);
diff --git a/linux-user/host/x86_64/host-signal.h b/linux-user/host/x86_64/host-signal.h
index 883d2fcf65..c71d597eb2 100644
--- a/linux-user/host/x86_64/host-signal.h
+++ b/linux-user/host/x86_64/host-signal.h
@@ -15,6 +15,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
return uc->uc_mcontext.gregs[REG_RIP];
}
+static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+{
+ uc->uc_mcontext.gregs[REG_RIP] = pc;
+}
+
static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
{
return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v5 02/17] linux-user/signal.c: Create a common rewind_if_in_safe_syscall
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
2021-11-17 16:03 ` [PATCH v5 01/17] linux-user: Add host_signal_set_pc to set pc in mcontext Richard Henderson
@ 2021-11-17 16:03 ` Richard Henderson
2021-11-17 16:24 ` Warner Losh
2021-11-17 16:37 ` Alex Bennée
2021-11-17 16:03 ` [PATCH v5 03/17] linux-user/safe-syscall.inc.S: Move to common-user Richard Henderson
` (15 subsequent siblings)
17 siblings, 2 replies; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:03 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp, Philippe Mathieu-Daudé
From: Warner Losh <imp@bsdimp.com>
All instances of rewind_if_in_safe_syscall are the same, differing only
in how the instruction point is fetched from the ucontext and the size
of the registers. Use host_signal_pc and new host_signal_set_pc
interfaces to fetch the pointer to the PC and adjust if needed. Delete
all the old copies of rewind_if_in_safe_syscall.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20211113045603.60391-3-imp@bsdimp.com>
[rth: include safe-syscall.h, simplify ifdefs]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/host/aarch64/hostdep.h | 20 --------------------
linux-user/host/arm/hostdep.h | 20 --------------------
linux-user/host/i386/hostdep.h | 20 --------------------
linux-user/host/ppc64/hostdep.h | 20 --------------------
linux-user/host/riscv/hostdep.h | 20 --------------------
linux-user/host/s390x/hostdep.h | 20 --------------------
linux-user/host/x86_64/hostdep.h | 20 --------------------
linux-user/safe-syscall.h | 3 +++
linux-user/signal.c | 15 ++++++++++++---
9 files changed, 15 insertions(+), 143 deletions(-)
diff --git a/linux-user/host/aarch64/hostdep.h b/linux-user/host/aarch64/hostdep.h
index a8d41a21ad..39299d798a 100644
--- a/linux-user/host/aarch64/hostdep.h
+++ b/linux-user/host/aarch64/hostdep.h
@@ -15,24 +15,4 @@
/* We have a safe-syscall.inc.S */
#define HAVE_SAFE_SYSCALL
-#ifndef __ASSEMBLER__
-
-/* These are defined by the safe-syscall.inc.S file */
-extern char safe_syscall_start[];
-extern char safe_syscall_end[];
-
-/* 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)
-{
- ucontext_t *uc = puc;
- __u64 *pcreg = &uc->uc_mcontext.pc;
-
- if (*pcreg > (uintptr_t)safe_syscall_start
- && *pcreg < (uintptr_t)safe_syscall_end) {
- *pcreg = (uintptr_t)safe_syscall_start;
- }
-}
-
-#endif /* __ASSEMBLER__ */
-
#endif
diff --git a/linux-user/host/arm/hostdep.h b/linux-user/host/arm/hostdep.h
index 9276fe6ceb..86b137875a 100644
--- a/linux-user/host/arm/hostdep.h
+++ b/linux-user/host/arm/hostdep.h
@@ -15,24 +15,4 @@
/* We have a safe-syscall.inc.S */
#define HAVE_SAFE_SYSCALL
-#ifndef __ASSEMBLER__
-
-/* These are defined by the safe-syscall.inc.S file */
-extern char safe_syscall_start[];
-extern char safe_syscall_end[];
-
-/* 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)
-{
- ucontext_t *uc = puc;
- unsigned long *pcreg = &uc->uc_mcontext.arm_pc;
-
- if (*pcreg > (uintptr_t)safe_syscall_start
- && *pcreg < (uintptr_t)safe_syscall_end) {
- *pcreg = (uintptr_t)safe_syscall_start;
- }
-}
-
-#endif /* __ASSEMBLER__ */
-
#endif
diff --git a/linux-user/host/i386/hostdep.h b/linux-user/host/i386/hostdep.h
index 073be74d87..ce7136501f 100644
--- a/linux-user/host/i386/hostdep.h
+++ b/linux-user/host/i386/hostdep.h
@@ -15,24 +15,4 @@
/* We have a safe-syscall.inc.S */
#define HAVE_SAFE_SYSCALL
-#ifndef __ASSEMBLER__
-
-/* These are defined by the safe-syscall.inc.S file */
-extern char safe_syscall_start[];
-extern char safe_syscall_end[];
-
-/* 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)
-{
- ucontext_t *uc = puc;
- greg_t *pcreg = &uc->uc_mcontext.gregs[REG_EIP];
-
- if (*pcreg > (uintptr_t)safe_syscall_start
- && *pcreg < (uintptr_t)safe_syscall_end) {
- *pcreg = (uintptr_t)safe_syscall_start;
- }
-}
-
-#endif /* __ASSEMBLER__ */
-
#endif
diff --git a/linux-user/host/ppc64/hostdep.h b/linux-user/host/ppc64/hostdep.h
index 98979ad917..0c290dd904 100644
--- a/linux-user/host/ppc64/hostdep.h
+++ b/linux-user/host/ppc64/hostdep.h
@@ -15,24 +15,4 @@
/* We have a safe-syscall.inc.S */
#define HAVE_SAFE_SYSCALL
-#ifndef __ASSEMBLER__
-
-/* These are defined by the safe-syscall.inc.S file */
-extern char safe_syscall_start[];
-extern char safe_syscall_end[];
-
-/* 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)
-{
- ucontext_t *uc = puc;
- unsigned long *pcreg = &uc->uc_mcontext.gp_regs[PT_NIP];
-
- if (*pcreg > (uintptr_t)safe_syscall_start
- && *pcreg < (uintptr_t)safe_syscall_end) {
- *pcreg = (uintptr_t)safe_syscall_start;
- }
-}
-
-#endif /* __ASSEMBLER__ */
-
#endif
diff --git a/linux-user/host/riscv/hostdep.h b/linux-user/host/riscv/hostdep.h
index 2ba07456ae..7f67c22868 100644
--- a/linux-user/host/riscv/hostdep.h
+++ b/linux-user/host/riscv/hostdep.h
@@ -11,24 +11,4 @@
/* We have a safe-syscall.inc.S */
#define HAVE_SAFE_SYSCALL
-#ifndef __ASSEMBLER__
-
-/* These are defined by the safe-syscall.inc.S file */
-extern char safe_syscall_start[];
-extern char safe_syscall_end[];
-
-/* 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)
-{
- ucontext_t *uc = puc;
- unsigned long *pcreg = &uc->uc_mcontext.__gregs[REG_PC];
-
- if (*pcreg > (uintptr_t)safe_syscall_start
- && *pcreg < (uintptr_t)safe_syscall_end) {
- *pcreg = (uintptr_t)safe_syscall_start;
- }
-}
-
-#endif /* __ASSEMBLER__ */
-
#endif
diff --git a/linux-user/host/s390x/hostdep.h b/linux-user/host/s390x/hostdep.h
index 4f0171f36f..d801145854 100644
--- a/linux-user/host/s390x/hostdep.h
+++ b/linux-user/host/s390x/hostdep.h
@@ -15,24 +15,4 @@
/* We have a safe-syscall.inc.S */
#define HAVE_SAFE_SYSCALL
-#ifndef __ASSEMBLER__
-
-/* These are defined by the safe-syscall.inc.S file */
-extern char safe_syscall_start[];
-extern char safe_syscall_end[];
-
-/* 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)
-{
- ucontext_t *uc = puc;
- unsigned long *pcreg = &uc->uc_mcontext.psw.addr;
-
- if (*pcreg > (uintptr_t)safe_syscall_start
- && *pcreg < (uintptr_t)safe_syscall_end) {
- *pcreg = (uintptr_t)safe_syscall_start;
- }
-}
-
-#endif /* __ASSEMBLER__ */
-
#endif
diff --git a/linux-user/host/x86_64/hostdep.h b/linux-user/host/x86_64/hostdep.h
index a4fefb5114..9c62bd26bd 100644
--- a/linux-user/host/x86_64/hostdep.h
+++ b/linux-user/host/x86_64/hostdep.h
@@ -15,24 +15,4 @@
/* We have a safe-syscall.inc.S */
#define HAVE_SAFE_SYSCALL
-#ifndef __ASSEMBLER__
-
-/* These are defined by the safe-syscall.inc.S file */
-extern char safe_syscall_start[];
-extern char safe_syscall_end[];
-
-/* 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)
-{
- ucontext_t *uc = puc;
- greg_t *pcreg = &uc->uc_mcontext.gregs[REG_RIP];
-
- if (*pcreg > (uintptr_t)safe_syscall_start
- && *pcreg < (uintptr_t)safe_syscall_end) {
- *pcreg = (uintptr_t)safe_syscall_start;
- }
-}
-
-#endif /* __ASSEMBLER__ */
-
#endif
diff --git a/linux-user/safe-syscall.h b/linux-user/safe-syscall.h
index 6bc0390262..aaa9ffc0e2 100644
--- a/linux-user/safe-syscall.h
+++ b/linux-user/safe-syscall.h
@@ -127,6 +127,9 @@
#ifdef HAVE_SAFE_SYSCALL
/* The core part of this function is implemented in assembly */
extern long safe_syscall_base(int *pending, long number, ...);
+/* These are defined by the safe-syscall.inc.S file */
+extern char safe_syscall_start[];
+extern char safe_syscall_end[];
#define safe_syscall(...) \
({ \
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 81c45bfce9..6d5e5b698c 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -31,6 +31,7 @@
#include "trace.h"
#include "signal-common.h"
#include "host-signal.h"
+#include "safe-syscall.h"
static struct target_sigaction sigact_table[TARGET_NSIG];
@@ -793,12 +794,20 @@ int queue_signal(CPUArchState *env, int sig, int si_type,
return 1; /* indicates that the signal was queued */
}
-#ifndef HAVE_SAFE_SYSCALL
+
+/* 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)
{
- /* Default version: never rewind */
-}
+#ifdef HAVE_SAFE_SYSCALL
+ ucontext_t *uc = (ucontext_t *)puc;
+ uintptr_t pcreg = host_signal_pc(uc);
+
+ if (pcreg > (uintptr_t)safe_syscall_start
+ && 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)
{
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v5 03/17] linux-user/safe-syscall.inc.S: Move to common-user
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
2021-11-17 16:03 ` [PATCH v5 01/17] linux-user: Add host_signal_set_pc to set pc in mcontext Richard Henderson
2021-11-17 16:03 ` [PATCH v5 02/17] linux-user/signal.c: Create a common rewind_if_in_safe_syscall Richard Henderson
@ 2021-11-17 16:03 ` Richard Henderson
2021-11-17 16:25 ` Warner Losh
2021-11-17 16:38 ` Alex Bennée
2021-11-17 16:03 ` [PATCH v5 04/17] common-user: Move syscall error detection into safe_syscall_base Richard Henderson
` (14 subsequent siblings)
17 siblings, 2 replies; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:03 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp, Philippe Mathieu-Daudé
From: Warner Losh <imp@bsdimp.com>
Move all the safe_syscall.inc.S files to common-user. They are almost
identical between linux-user and bsd-user to re-use.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20211113045603.60391-4-imp@bsdimp.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
meson.build | 2 ++
{linux-user => common-user}/host/aarch64/hostdep.h | 0
{linux-user => common-user}/host/arm/hostdep.h | 0
{linux-user => common-user}/host/i386/hostdep.h | 0
{linux-user => common-user}/host/ppc64/hostdep.h | 0
{linux-user => common-user}/host/riscv/hostdep.h | 0
{linux-user => common-user}/host/s390x/hostdep.h | 0
{linux-user => common-user}/host/x86_64/hostdep.h | 0
{linux-user => common-user}/host/aarch64/safe-syscall.inc.S | 0
{linux-user => common-user}/host/arm/safe-syscall.inc.S | 0
{linux-user => common-user}/host/i386/safe-syscall.inc.S | 0
{linux-user => common-user}/host/ppc64/safe-syscall.inc.S | 0
{linux-user => common-user}/host/riscv/safe-syscall.inc.S | 0
{linux-user => common-user}/host/s390x/safe-syscall.inc.S | 0
{linux-user => common-user}/host/x86_64/safe-syscall.inc.S | 0
15 files changed, 2 insertions(+)
rename {linux-user => common-user}/host/aarch64/hostdep.h (100%)
rename {linux-user => common-user}/host/arm/hostdep.h (100%)
rename {linux-user => common-user}/host/i386/hostdep.h (100%)
rename {linux-user => common-user}/host/ppc64/hostdep.h (100%)
rename {linux-user => common-user}/host/riscv/hostdep.h (100%)
rename {linux-user => common-user}/host/s390x/hostdep.h (100%)
rename {linux-user => common-user}/host/x86_64/hostdep.h (100%)
rename {linux-user => common-user}/host/aarch64/safe-syscall.inc.S (100%)
rename {linux-user => common-user}/host/arm/safe-syscall.inc.S (100%)
rename {linux-user => common-user}/host/i386/safe-syscall.inc.S (100%)
rename {linux-user => common-user}/host/ppc64/safe-syscall.inc.S (100%)
rename {linux-user => common-user}/host/riscv/safe-syscall.inc.S (100%)
rename {linux-user => common-user}/host/s390x/safe-syscall.inc.S (100%)
rename {linux-user => common-user}/host/x86_64/safe-syscall.inc.S (100%)
diff --git a/meson.build b/meson.build
index e2d38a43e6..c58abf0d0d 100644
--- a/meson.build
+++ b/meson.build
@@ -2878,10 +2878,12 @@ foreach target : target_dirs
if 'CONFIG_LINUX_USER' in config_target
base_dir = 'linux-user'
target_inc += include_directories('linux-user/host/' / config_host['ARCH'])
+ target_inc += include_directories('common-user/host/' / config_host['ARCH'])
endif
if 'CONFIG_BSD_USER' in config_target
base_dir = 'bsd-user'
target_inc += include_directories('bsd-user/' / targetos)
+ target_inc += include_directories('common-user/host/' / config_host['ARCH'])
dir = base_dir / abi
arch_srcs += files(dir / 'target_arch_cpu.c')
endif
diff --git a/linux-user/host/aarch64/hostdep.h b/common-user/host/aarch64/hostdep.h
similarity index 100%
rename from linux-user/host/aarch64/hostdep.h
rename to common-user/host/aarch64/hostdep.h
diff --git a/linux-user/host/arm/hostdep.h b/common-user/host/arm/hostdep.h
similarity index 100%
rename from linux-user/host/arm/hostdep.h
rename to common-user/host/arm/hostdep.h
diff --git a/linux-user/host/i386/hostdep.h b/common-user/host/i386/hostdep.h
similarity index 100%
rename from linux-user/host/i386/hostdep.h
rename to common-user/host/i386/hostdep.h
diff --git a/linux-user/host/ppc64/hostdep.h b/common-user/host/ppc64/hostdep.h
similarity index 100%
rename from linux-user/host/ppc64/hostdep.h
rename to common-user/host/ppc64/hostdep.h
diff --git a/linux-user/host/riscv/hostdep.h b/common-user/host/riscv/hostdep.h
similarity index 100%
rename from linux-user/host/riscv/hostdep.h
rename to common-user/host/riscv/hostdep.h
diff --git a/linux-user/host/s390x/hostdep.h b/common-user/host/s390x/hostdep.h
similarity index 100%
rename from linux-user/host/s390x/hostdep.h
rename to common-user/host/s390x/hostdep.h
diff --git a/linux-user/host/x86_64/hostdep.h b/common-user/host/x86_64/hostdep.h
similarity index 100%
rename from linux-user/host/x86_64/hostdep.h
rename to common-user/host/x86_64/hostdep.h
diff --git a/linux-user/host/aarch64/safe-syscall.inc.S b/common-user/host/aarch64/safe-syscall.inc.S
similarity index 100%
rename from linux-user/host/aarch64/safe-syscall.inc.S
rename to common-user/host/aarch64/safe-syscall.inc.S
diff --git a/linux-user/host/arm/safe-syscall.inc.S b/common-user/host/arm/safe-syscall.inc.S
similarity index 100%
rename from linux-user/host/arm/safe-syscall.inc.S
rename to common-user/host/arm/safe-syscall.inc.S
diff --git a/linux-user/host/i386/safe-syscall.inc.S b/common-user/host/i386/safe-syscall.inc.S
similarity index 100%
rename from linux-user/host/i386/safe-syscall.inc.S
rename to common-user/host/i386/safe-syscall.inc.S
diff --git a/linux-user/host/ppc64/safe-syscall.inc.S b/common-user/host/ppc64/safe-syscall.inc.S
similarity index 100%
rename from linux-user/host/ppc64/safe-syscall.inc.S
rename to common-user/host/ppc64/safe-syscall.inc.S
diff --git a/linux-user/host/riscv/safe-syscall.inc.S b/common-user/host/riscv/safe-syscall.inc.S
similarity index 100%
rename from linux-user/host/riscv/safe-syscall.inc.S
rename to common-user/host/riscv/safe-syscall.inc.S
diff --git a/linux-user/host/s390x/safe-syscall.inc.S b/common-user/host/s390x/safe-syscall.inc.S
similarity index 100%
rename from linux-user/host/s390x/safe-syscall.inc.S
rename to common-user/host/s390x/safe-syscall.inc.S
diff --git a/linux-user/host/x86_64/safe-syscall.inc.S b/common-user/host/x86_64/safe-syscall.inc.S
similarity index 100%
rename from linux-user/host/x86_64/safe-syscall.inc.S
rename to common-user/host/x86_64/safe-syscall.inc.S
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v5 04/17] common-user: Move syscall error detection into safe_syscall_base
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
` (2 preceding siblings ...)
2021-11-17 16:03 ` [PATCH v5 03/17] linux-user/safe-syscall.inc.S: Move to common-user Richard Henderson
@ 2021-11-17 16:03 ` Richard Henderson
2021-11-17 16:28 ` Warner Losh
2021-11-22 11:55 ` Peter Maydell
2021-11-17 16:04 ` [PATCH v5 05/17] common-user/host/mips: Add safe-syscall.inc.S Richard Henderson
` (13 subsequent siblings)
17 siblings, 2 replies; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:03 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp
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 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.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/safe-syscall.h | 20 +++---
common-user/host/aarch64/safe-syscall.inc.S | 55 +++++++++-------
common-user/host/arm/safe-syscall.inc.S | 58 ++++++++++-------
common-user/host/i386/safe-syscall.inc.S | 51 +++++++++------
common-user/host/ppc64/safe-syscall.inc.S | 63 +++++++++++--------
common-user/host/riscv/safe-syscall.inc.S | 50 +++++++++------
common-user/host/s390x/safe-syscall.inc.S | 50 +++++++++------
common-user/host/x86_64/safe-syscall.inc.S | 70 ++++++++++++---------
8 files changed, 243 insertions(+), 174 deletions(-)
diff --git a/linux-user/safe-syscall.h b/linux-user/safe-syscall.h
index aaa9ffc0e2..ea0e8a8d24 100644
--- a/linux-user/safe-syscall.h
+++ b/linux-user/safe-syscall.h
@@ -125,23 +125,17 @@
* 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, ...);
+
+/* The core part of this function is implemented in assembly. */
+extern long safe_syscall_base(int *pending, int *errnop, long number, ...);
+
/* 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, \
+ &errno, __VA_ARGS__)
#else
diff --git a/common-user/host/aarch64/safe-syscall.inc.S b/common-user/host/aarch64/safe-syscall.inc.S
index bc1f5a9792..95c60d8609 100644
--- a/common-user/host/aarch64/safe-syscall.inc.S
+++ b/common-user/host/aarch64/safe-syscall.inc.S
@@ -17,22 +17,21 @@
.type safe_syscall_start, #function
.type safe_syscall_end, #function
- /* This is the entry point for making a system call. The calling
+ /*
+ * 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:
+ /*
+ * 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
+ * x1 == errno
+ * x2 == syscall number
+ * x3 ... x7, (stack) == syscall arguments
* and return the result in x0
* and the syscall instruction needs
* x8 == syscall number
@@ -40,17 +39,18 @@ safe_syscall_base:
* 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]
+ mov x10, x0 /* signal_pending pointer */
+ mov x11, x1 /* errno pointer */
+ mov x8, x2 /* syscall number */
+ mov x0, x3 /* syscall arguments */
+ mov x1, x4
+ mov x2, x5
+ mov x3, x6
+ mov x4, x7
+ ldp x5, x6, [sp]
- /* This next sequence of code works in conjunction with the
+ /*
+ * 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'.
@@ -59,17 +59,26 @@ safe_syscall_base:
*/
safe_syscall_start:
/* if signal_pending is non-zero, don't do the call */
- ldr w10, [x9]
- cbnz w10, 0f
+ ldr w9, [x10]
+ cbnz w9, 2f
svc 0x0
safe_syscall_end:
+
/* code path for having successfully executed the syscall */
+ cmn x0, #4095
+ b.cs 1f
ret
-0:
- /* code path when we didn't execute the syscall */
- mov x0, #-TARGET_ERESTARTSYS
+ /* code path setting errno */
+0: neg w0, w0 /* create positive errno */
+1: str w0, [x11] /* store errno */
+ mov x0, #-1
ret
+
+ /* code path when we didn't execute the syscall */
+2: mov w0, #TARGET_ERESTARTSYS
+ b 1b
+
.cfi_endproc
.size safe_syscall_base, .-safe_syscall_base
diff --git a/common-user/host/arm/safe-syscall.inc.S b/common-user/host/arm/safe-syscall.inc.S
index 88c4958504..17839c6486 100644
--- a/common-user/host/arm/safe-syscall.inc.S
+++ b/common-user/host/arm/safe-syscall.inc.S
@@ -22,33 +22,35 @@
.arm
.align 2
- /* This is the entry point for making a system call. The calling
+ /*
+ * 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:
.fnstart
.cfi_startproc
mov r12, sp /* save entry stack */
- push { r4, r5, r6, r7, r8, lr }
- .save { r4, r5, r6, r7, r8, lr }
- .cfi_adjust_cfa_offset 24
+ push { r4, r5, r6, r7, r8, r9, r10, lr }
+ .save { r4, r5, r6, r7, r8, r9, r10, lr }
+ .cfi_adjust_cfa_offset 32
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
.cfi_rel_offset r6, 8
.cfi_rel_offset r7, 12
.cfi_rel_offset r8, 16
- .cfi_rel_offset lr, 20
+ .cfi_rel_offset r9, 20
+ .cfi_rel_offset r10, 24
+ .cfi_rel_offset lr, 28
- /* The syscall calling convention isn't the same as the C one:
- * we enter with r0 == *signal_pending
- * r1 == syscall number
- * r2, r3, [sp+0] ... [sp+12] == syscall arguments
+ /*
+ * The syscall calling convention isn't the same as the C one:
+ * we enter with r0 == &signal_pending
+ * r1 == &errno
+ * r2 == syscall number
+ * r3, [sp+0] ... [sp+16] == syscall arguments
* and return the result in r0
* and the syscall instruction needs
* r7 == syscall number
@@ -58,12 +60,13 @@ safe_syscall_base:
* Note the 16 bytes that we pushed to save registers.
*/
mov r8, r0 /* copy signal_pending */
- mov r7, r1 /* syscall number */
- mov r0, r2 /* syscall args */
- mov r1, r3
- ldm r12, { r2, r3, r4, r5, r6 }
+ mov r9, r1 /* copy errnop */
+ mov r7, r2 /* syscall number */
+ mov r0, r3 /* syscall args */
+ ldm r12, { r1, r2, r3, r4, r5, r6 }
- /* This next sequence of code works in conjunction with the
+ /*
+ * 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'.
@@ -74,16 +77,25 @@ 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 */
- pop { r4, r5, r6, r7, r8, pc }
-1:
+ /* code path for having successfully executed the syscall */
+ cmp r0, #-4096
+ bhi 0f
+9: pop { r4, r5, r6, r7, r8, r9, r10, pc }
+
+ /* code path setting errno */
+0: neg r0, r0 /* create positive errno */
+1: str r0, [r9] /* store errno */
+ mov r0, #-1
+ b 9b
+
/* code path when we didn't execute the syscall */
- ldr r0, =-TARGET_ERESTARTSYS
- pop { r4, r5, r6, r7, r8, pc }
+2: ldr r0, =TARGET_ERESTARTSYS
+ b 1b
+
.fnend
.cfi_endproc
diff --git a/common-user/host/i386/safe-syscall.inc.S b/common-user/host/i386/safe-syscall.inc.S
index 9e58fc6504..ad89521783 100644
--- a/common-user/host/i386/safe-syscall.inc.S
+++ b/common-user/host/i386/safe-syscall.inc.S
@@ -15,14 +15,12 @@
.global safe_syscall_end
.type safe_syscall_base, @function
- /* This is the entry point for making a system call. The calling
+ /*
+ * 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
@@ -41,9 +39,10 @@ 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
- * 8(%esp) == syscall number
- * 12(%esp) ... 32(%esp) == syscall arguments
+ * 4(%esp) == &signal_pending
+ * 8(%esp) == &errno
+ * 12(%esp) == syscall number
+ * 16(%esp) ... 36(%esp) == syscall arguments
* and return the result in eax
* and the syscall instruction needs
* eax == syscall number
@@ -52,14 +51,15 @@ safe_syscall_base:
* Shuffle everything around appropriately.
* Note the 16 bytes that we pushed to save registers.
*/
- mov 12+16(%esp), %ebx /* the syscall arguments */
- mov 16+16(%esp), %ecx
- mov 20+16(%esp), %edx
- mov 24+16(%esp), %esi
- mov 28+16(%esp), %edi
- mov 32+16(%esp), %ebp
+ mov 16+16(%esp), %ebx /* the syscall arguments */
+ mov 20+16(%esp), %ecx
+ mov 24+16(%esp), %edx
+ mov 28+16(%esp), %esi
+ mov 32+16(%esp), %edi
+ mov 36+16(%esp), %ebp
- /* This next sequence of code works in conjunction with the
+ /*
+ * 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'.
@@ -70,12 +70,16 @@ 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 */
- pop %ebx
+ cmp $-4095, %eax
+ jae 0f
+
+9: pop %ebx
.cfi_remember_state
.cfi_adjust_cfa_offset -4
.cfi_restore ebx
@@ -90,11 +94,18 @@ safe_syscall_end:
.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
+
+ /* code path setting errno */
+0: neg %eax /* create positive errno */
+1: mov 8+16(%esp), %ebx /* load errno pointer */
+ mov %eax, (%ebx) /* store errno */
+ mov $-1, %eax
+ jmp 9b
+
+ /* code path when we didn't execute the syscall */
+2: mov $TARGET_ERESTARTSYS, %eax
+ jmp 1b
.cfi_endproc
.size safe_syscall_base, .-safe_syscall_base
diff --git a/common-user/host/ppc64/safe-syscall.inc.S b/common-user/host/ppc64/safe-syscall.inc.S
index 875133173b..e35408c5fb 100644
--- a/common-user/host/ppc64/safe-syscall.inc.S
+++ b/common-user/host/ppc64/safe-syscall.inc.S
@@ -17,14 +17,19 @@
.text
- /* This is the entry point for making a system call. The calling
+#if _CALL_ELF == 2
+#define PARAM_OFS 32
+#else
+#define PARAM_OFS 48
+#endif
+#define PARAM(X) PARAM_OFS + X*8
+
+ /*
+ * 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.
*/
#if _CALL_ELF == 2
safe_syscall_base:
@@ -39,9 +44,11 @@ safe_syscall_base:
.L.safe_syscall_base:
.cfi_startproc
#endif
- /* We enter with r3 == *signal_pending
- * r4 == syscall number
- * r5 ... r10 == syscall arguments
+ /*
+ * We enter with r3 == &signal_pending
+ * r4 == &errno
+ * r5 == syscall number
+ * r6 ... r10, (stack) == syscall arguments
* and return the result in r3
* and the syscall instruction needs
* r0 == syscall number
@@ -49,18 +56,18 @@ safe_syscall_base:
* and returns the result in r3
* Shuffle everything around appropriately.
*/
- std 14, 16(1) /* Preserve r14 in SP+16 */
- .cfi_offset 14, 16
- mr 14, 3 /* signal_pending */
- mr 0, 4 /* syscall number */
- mr 3, 5 /* syscall arguments */
- mr 4, 6
- mr 5, 7
- mr 6, 8
- mr 7, 9
- mr 8, 10
+ mr 11, 3 /* signal_pending pointer */
+ std 4, PARAM(1)(1) /* save errno pointer in param slot */
+ mr 0, 5 /* syscall number */
+ mr 3, 6 /* syscall arguments */
+ mr 4, 7
+ mr 5, 8
+ mr 6, 9
+ mr 7, 10
+ ld 8, PARAM(8)(1)
- /* This next sequence of code works in conjunction with the
+ /*
+ * 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'.
@@ -69,23 +76,25 @@ safe_syscall_base:
*/
safe_syscall_start:
/* if signal_pending is non-zero, don't do the call */
- lwz 12, 0(14)
+ lwz 12, 0(11)
cmpwi 0, 12, 0
bne- 0f
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
+ /* code path for having successfully executed the syscall */
+ bnslr+ /* SO set for syscall error */
+
+ /* code path setting errno */
+1: ld 11, PARAM(1)(1) /* restore errno pointer */
+ stw 3, 0(11) /* store errno */
+ li 3, -1
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
+0: li 3, TARGET_ERESTARTSYS
+ b 1b
+
.cfi_endproc
#if _CALL_ELF == 2
diff --git a/common-user/host/riscv/safe-syscall.inc.S b/common-user/host/riscv/safe-syscall.inc.S
index 9ca3fbfd1e..eddede702b 100644
--- a/common-user/host/riscv/safe-syscall.inc.S
+++ b/common-user/host/riscv/safe-syscall.inc.S
@@ -23,17 +23,15 @@
* 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
- * a1 == syscall number
- * a2 ... a7 == syscall arguments
+ * we enter with a0 == &signal_pending
+ * a1 == &errno
+ * a2 == syscall number
+ * a3 ... a7, [sp] == syscall arguments
* and return the result in a0
* and the syscall instruction needs
* a7 == syscall number
@@ -42,14 +40,19 @@ safe_syscall_base:
* Shuffle everything around appropriately.
*/
mv t0, a0 /* signal_pending pointer */
- mv t1, a1 /* syscall number */
- mv a0, a2 /* syscall arguments */
- mv a1, a3
- mv a2, a4
- mv a3, a5
- mv a4, a6
- mv a5, a7
- mv a7, t1
+ mv t1, a1 /* errno pointer */
+ mv t2, a2 /* syscall number */
+ mv a0, a3 /* syscall arguments */
+ mv a1, a4
+ mv a2, a5
+ mv a3, a6
+ mv a4, a7
+#if __riscv_xlen == 32
+ lw a5, 0(sp)
+#else
+ ld a5, 0(sp)
+#endif
+ mv a7, t2
/*
* This next sequence of code works in conjunction with the
@@ -61,17 +64,26 @@ safe_syscall_base:
*/
safe_syscall_start:
/* If signal_pending is non-zero, don't do the call */
- lw t1, 0(t0)
- bnez t1, 0f
+ lw t2, 0(t0)
+ bnez t2, 2f
scall
safe_syscall_end:
+
/* code path for having successfully executed the syscall */
+ li t2, -4096
+ bgtu a0, t2, 0f
ret
-0:
- /* code path when we didn't execute the syscall */
- li a0, -TARGET_ERESTARTSYS
+ /* code path setting errno */
+0: neg a0, a0 /* create positive errno */
+1: sw a0, 0(t1) /* store errno */
+ li a0, -1
ret
+
+ /* code path when we didn't execute the syscall */
+2: li a0, TARGET_ERESTARTSYS
+ j 1b
+
.cfi_endproc
.size safe_syscall_base, .-safe_syscall_base
diff --git a/common-user/host/s390x/safe-syscall.inc.S b/common-user/host/s390x/safe-syscall.inc.S
index 414b44ad38..f2a3bccc13 100644
--- a/common-user/host/s390x/safe-syscall.inc.S
+++ b/common-user/host/s390x/safe-syscall.inc.S
@@ -15,14 +15,12 @@
.global safe_syscall_end
.type safe_syscall_base, @function
- /* This is the entry point for making a system call. The calling
+ /*
+ * 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
@@ -44,11 +42,13 @@ 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
+ /*
+ * 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
+ * we enter with r2 == &signal_pending
+ * r3 == &errno
+ * r4 == syscall number
+ * r5, r6, (stack) == syscall arguments
* and return the result in r2
* and the syscall instruction needs
* r1 == syscall number
@@ -57,13 +57,14 @@ safe_syscall_base:
* Shuffle everything around appropriately.
*/
lgr %r8,%r2 /* signal_pending pointer */
- lgr %r1,%r3 /* syscall number */
- lgr %r2,%r4 /* syscall args */
- lgr %r3,%r5
- lgr %r4,%r6
- lmg %r5,%r7,320(%r15)
+ lgr %r9,%r3 /* errno pointer */
+ lgr %r1,%r4 /* syscall number */
+ lgr %r2,%r5 /* syscall args */
+ lgr %r3,%r6
+ lmg %r4,%r7,320(%r15)
- /* This next sequence of code works in conjunction with the
+ /*
+ * 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'.
@@ -73,18 +74,31 @@ safe_syscall_base:
safe_syscall_start:
/* if signal_pending is non-zero, don't do the call */
icm %r0,15,0(%r8)
- jne 2f
+ jne 1f
svc 0
safe_syscall_end:
-1: lg %r15,0(%r15) /* load back chain */
+ /* code path for having successfully executed the syscall */
+ lghi %r0, -4095 /* check for syscall error */
+ clgr %r2, %r0
+ jgnl 0f
+
+9: 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
+
+ /* code path when we didn't execute the syscall */
+1: lghi %r2, -TARGET_ERESTARTSYS
+
+ /* code path setting errno */
+0: lcr %r2, %r2 /* create positive errno */
+ st %r2, 0(%r9) /* store errno */
+ lghi %r2, -1
+ j 9b
+
.cfi_endproc
.size safe_syscall_base, .-safe_syscall_base
diff --git a/common-user/host/x86_64/safe-syscall.inc.S b/common-user/host/x86_64/safe-syscall.inc.S
index f36992daa3..9a0c4c93b4 100644
--- a/common-user/host/x86_64/safe-syscall.inc.S
+++ b/common-user/host/x86_64/safe-syscall.inc.S
@@ -14,18 +14,17 @@
.global safe_syscall_end
.type safe_syscall_base, @function
- /* This is the entry point for making a system call. The calling
+ /*
+ * 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
- /* This saves a frame pointer and aligns the stack for the syscall.
+ /*
+ * This saves a frame pointer and aligns the stack for the syscall.
* (It's unclear if the syscall ABI has the same stack alignment
* requirements as the userspace function call ABI, but better safe than
* sorry. Appendix A2 of http://www.x86-64.org/documentation/abi.pdf
@@ -35,11 +34,12 @@ 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
- * rsi == syscall number
- * rdx, rcx, r8, r9, (stack), (stack) == syscall arguments
+ /*
+ * The syscall calling convention isn't the same as the C one:
+ * we enter with rdi == &signal_pending
+ * rsi == &errno
+ * rdx == syscall number
+ * rcx, r8, r9, (stack...) == syscall arguments
* and return the result in rax
* and the syscall instruction needs
* rax == syscall number
@@ -48,17 +48,19 @@ safe_syscall_base:
* Shuffle everything around appropriately.
* Note that syscall will trash rcx and r11.
*/
- mov %rsi, %rax /* syscall number */
- mov %rdi, %rbp /* signal_pending pointer */
+ mov %rdi, %r11 /* signal_pending pointer */
+ mov %rsi, %rbp /* errno pointer */
+ mov %rdx, %rax /* syscall number */
/* and the syscall arguments */
- mov %rdx, %rdi
- mov %rcx, %rsi
- mov %r8, %rdx
- mov %r9, %r10
- mov 16(%rsp), %r8
- mov 24(%rsp), %r9
+ mov %rcx, %rdi
+ mov %r8, %rsi
+ mov %r9, %rdx
+ mov 16(%rsp), %r10
+ mov 24(%rsp), %r8
+ mov 32(%rsp), %r9
- /* This next sequence of code works in conjunction with the
+ /*
+ * 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'.
@@ -67,25 +69,31 @@ safe_syscall_base:
*/
safe_syscall_start:
/* if signal_pending is non-zero, don't do the call */
- cmpl $0, (%rbp)
- jnz 1f
+ cmpl $0, (%r11)
+ jnz 2f
syscall
safe_syscall_end:
+
/* code path for having successfully executed the syscall */
- pop %rbp
+ cmp $-4095, %rax
+ jae 0f
+
+9: 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
- .cfi_def_cfa_offset 8
- .cfi_restore rbp
- ret
- .cfi_endproc
+ /* code path setting errno */
+0: neg %eax /* create positive errno */
+1: mov %eax, (%rbp) /* store errno */
+ mov $-1, %rax
+ jmp 9b
+
+ /* code path when we didn't execute the syscall */
+2: mov $TARGET_ERESTARTSYS, %eax
+ jmp 1b
+
+ .cfi_endproc
.size safe_syscall_base, .-safe_syscall_base
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v5 05/17] common-user/host/mips: Add safe-syscall.inc.S
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
` (3 preceding siblings ...)
2021-11-17 16:03 ` [PATCH v5 04/17] common-user: Move syscall error detection into safe_syscall_base Richard Henderson
@ 2021-11-17 16:04 ` Richard Henderson
2021-11-17 16:31 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 06/17] common-user/host/sparc64: " Richard Henderson
` (12 subsequent siblings)
17 siblings, 1 reply; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:04 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
common-user/host/mips/hostdep.h | 2 +
common-user/host/mips/safe-syscall.inc.S | 135 +++++++++++++++++++++++
2 files changed, 137 insertions(+)
create mode 100644 common-user/host/mips/hostdep.h
create mode 100644 common-user/host/mips/safe-syscall.inc.S
diff --git a/common-user/host/mips/hostdep.h b/common-user/host/mips/hostdep.h
new file mode 100644
index 0000000000..b18aca1deb
--- /dev/null
+++ b/common-user/host/mips/hostdep.h
@@ -0,0 +1,2 @@
+/* We have a safe-syscall.inc.S */
+#define HAVE_SAFE_SYSCALL
diff --git a/common-user/host/mips/safe-syscall.inc.S b/common-user/host/mips/safe-syscall.inc.S
new file mode 100644
index 0000000000..1e2f5a079c
--- /dev/null
+++ b/common-user/host/mips/safe-syscall.inc.S
@@ -0,0 +1,135 @@
+/*
+ * 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
+ *
+ * Written by Richard Henderson <rth@twiddle.net>
+ * Copyright (C) 2021 Linaro, 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 "sys/regdef.h"
+#include "sys/asm.h"
+
+ .text
+ .set nomips16
+ .set noreorder
+
+ .global safe_syscall_start
+ .global safe_syscall_end
+ .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').
+ */
+
+#if _MIPS_SIM == _ABIO32
+/* Do not allocate a stack frame and store into the parameter space. */
+#define FRAME 0
+#define ERRNOP 4
+#else
+/* Allocate a stack frame and store into the first allocated slot. */
+#define FRAME 16
+#define ERRNOP 0
+#endif
+
+NESTED(safe_syscall_base, FRAME, ra)
+ .cfi_startproc
+#if _MIPS_SIM == _ABIO32
+ /*
+ * The syscall calling convention is nearly the same as C:
+ * we enter with a0 == &signal_pending
+ * a1 == &errno
+ * a2 == syscall number
+ * a3, stack == syscall arguments
+ * and return the result in a0
+ * and the syscall instruction needs
+ * v0 == syscall number
+ * a0 ... a3, stack == syscall arguments
+ * and returns the result in v0
+ * Shuffle everything around appropriately.
+ */
+ move t0, a0 /* signal_pending pointer */
+ sw a1, ERRNOP(sp) /* errno pointer */
+ move v0, a2 /* syscall number */
+ move a0, a3 /* syscall arguments */
+ lw a1, 16(sp)
+ lw a2, 20(sp)
+ lw a3, 24(sp)
+ lw t4, 28(sp)
+ lw t5, 32(sp)
+ lw t6, 40(sp)
+ lw t7, 44(sp)
+ sw t4, 16(sp)
+ sw t5, 20(sp)
+ sw t6, 24(sp)
+ sw t7, 28(sp)
+#else
+ PTR_ADDIU sp, sp, -FRAME
+ .cfi_adjust_cfa_offset FRAME
+
+ /*
+ * The syscall calling convention is nearly the same as C:
+ * we enter with a0 == &signal_pending
+ * a1 == &errno
+ * a2 == syscall number
+ * a3 ... a7, stack == syscall arguments
+ * and return the result in a0
+ * and the syscall instruction needs
+ * v0 == syscall number
+ * a0 ... a5 == syscall arguments
+ * and returns the result in v0
+ * Shuffle everything around appropriately.
+ */
+ move t0, a0 /* signal_pending pointer */
+ PTR_S a1, ERRNOP(sp) /* save errno pointer */
+ move v0, a2 /* syscall number */
+ move a0, a3 /* syscall arguments */
+ move a1, a4
+ move a2, a5
+ move a3, a6
+ move a4, a7
+ ld a5, 16(sp)
+#endif
+
+ /*
+ * 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 */
+ lw t1, 0(t0)
+ bnez t1, 0f
+ nop
+ syscall
+safe_syscall_end:
+
+ /* code path for having successfully executed the syscall */
+ bnez a3, 1f
+ nop
+ jr ra
+ PTR_ADDIU sp, sp, FRAME
+
+ /* code path when we didn't execute the syscall */
+0: li v0, TARGET_ERESTARTSYS
+
+ /* code path setting errno */
+1: PTR_L t0, ERRNOP(sp)
+ sw v0, 0(t0) /* store errno */
+ li v0, -1
+ jr ra
+ PTR_ADDIU sp, sp, FRAME
+
+ .cfi_endproc
+END(safe_syscall_base)
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v5 06/17] common-user/host/sparc64: Add safe-syscall.inc.S
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
` (4 preceding siblings ...)
2021-11-17 16:04 ` [PATCH v5 05/17] common-user/host/mips: Add safe-syscall.inc.S Richard Henderson
@ 2021-11-17 16:04 ` Richard Henderson
2021-11-17 16:04 ` [PATCH v5 07/17] linux-user: Remove HAVE_SAFE_SYSCALL and hostdep.h Richard Henderson
` (11 subsequent siblings)
17 siblings, 0 replies; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:04 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
common-user/host/sparc64/hostdep.h | 2 +
common-user/host/sparc64/safe-syscall.inc.S | 91 +++++++++++++++++++++
2 files changed, 93 insertions(+)
create mode 100644 common-user/host/sparc64/hostdep.h
create mode 100644 common-user/host/sparc64/safe-syscall.inc.S
diff --git a/common-user/host/sparc64/hostdep.h b/common-user/host/sparc64/hostdep.h
new file mode 100644
index 0000000000..b18aca1deb
--- /dev/null
+++ b/common-user/host/sparc64/hostdep.h
@@ -0,0 +1,2 @@
+/* We have a safe-syscall.inc.S */
+#define HAVE_SAFE_SYSCALL
diff --git a/common-user/host/sparc64/safe-syscall.inc.S b/common-user/host/sparc64/safe-syscall.inc.S
new file mode 100644
index 0000000000..2492fcbd9e
--- /dev/null
+++ b/common-user/host/sparc64/safe-syscall.inc.S
@@ -0,0 +1,91 @@
+/*
+ * 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
+ *
+ * Written by Richard Henderson <rth@twiddle.net>
+ * 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.
+ */
+
+ .text
+ .balign 4
+
+ .global safe_syscall_base
+ .global safe_syscall_start
+ .global safe_syscall_end
+ .type safe_syscall_base, @function
+ .type safe_syscall_start, @object
+ .type safe_syscall_end, @object
+
+#define STACK_BIAS 2047
+#define PARAM(N) STACK_BIAS + N*8
+
+ /*
+ * 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').
+ */
+safe_syscall_base:
+ .cfi_startproc
+ /*
+ * The syscall calling convention isn't the same as the C one:
+ * we enter with o0 == *signal_pending
+ * o1 == errno
+ * o2 == syscall number
+ * o3 ... o5, (stack) == syscall arguments
+ * and return the result in x0
+ * and the syscall instruction needs
+ * g1 == syscall number
+ * o0 ... o5 == syscall arguments
+ * and returns the result in o0
+ * Shuffle everything around appropriately.
+ */
+ mov %o0, %g2 /* signal_pending pointer */
+ stx %o1, [%sp + PARAM(1)] /* save errno pointer */
+ mov %o2, %g1 /* syscall number */
+ mov %o3, %o0 /* syscall arguments */
+ mov %o4, %o1
+ mov %o5, %o2
+ ldx [%sp + PARAM(6)], %o3
+ ldx [%sp + PARAM(7)], %o4
+ ldx [%sp + PARAM(8)], %o5
+
+ /*
+ * 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 */
+ lduw [%g2], %g3
+ brnz,pn %g3, 2f
+ nop
+ ta 0x6d
+safe_syscall_end:
+
+ /* code path for having successfully executed the syscall */
+ bcc,pt %xcc, 9f
+ nop
+
+ /* code path setting errno */
+1: ldx [%sp + PARAM(1)], %g2
+ stw %o0, [%g2] /* store errno */
+ set -1, %o0
+
+9: ret
+ nop
+
+ /* code path when we didn't execute the syscall */
+2: ba,pt %xcc, 1b
+ set TARGET_ERESTARTSYS, %o0
+
+ .cfi_endproc
+ .size safe_syscall_base, .-safe_syscall_base
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v5 07/17] linux-user: Remove HAVE_SAFE_SYSCALL and hostdep.h
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
` (5 preceding siblings ...)
2021-11-17 16:04 ` [PATCH v5 06/17] common-user/host/sparc64: " Richard Henderson
@ 2021-11-17 16:04 ` Richard Henderson
2021-11-17 16:04 ` [PATCH v5 08/17] common-user: Adjust system call return on FreeBSD Richard Henderson
` (10 subsequent siblings)
17 siblings, 0 replies; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:04 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp, Philippe Mathieu-Daudé
All supported hosts now define HAVE_SAFE_SYSCALL, so remove
the ifdefs. This leaves hostdep.h empty, so remove it.
Reviewed-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
common-user/host/aarch64/hostdep.h | 18 ------------------
common-user/host/arm/hostdep.h | 18 ------------------
common-user/host/i386/hostdep.h | 18 ------------------
common-user/host/mips/hostdep.h | 2 --
common-user/host/ppc64/hostdep.h | 18 ------------------
common-user/host/riscv/hostdep.h | 14 --------------
common-user/host/s390x/hostdep.h | 18 ------------------
common-user/host/sparc64/hostdep.h | 2 --
common-user/host/x86_64/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/s390/hostdep.h | 15 ---------------
linux-user/host/sparc/hostdep.h | 15 ---------------
linux-user/host/sparc64/hostdep.h | 15 ---------------
linux-user/host/x32/hostdep.h | 15 ---------------
linux-user/safe-syscall.h | 12 ------------
linux-user/user-internals.h | 1 -
linux-user/signal.c | 2 --
linux-user/safe-syscall.S | 3 ---
20 files changed, 249 deletions(-)
delete mode 100644 common-user/host/aarch64/hostdep.h
delete mode 100644 common-user/host/arm/hostdep.h
delete mode 100644 common-user/host/i386/hostdep.h
delete mode 100644 common-user/host/mips/hostdep.h
delete mode 100644 common-user/host/ppc64/hostdep.h
delete mode 100644 common-user/host/riscv/hostdep.h
delete mode 100644 common-user/host/s390x/hostdep.h
delete mode 100644 common-user/host/sparc64/hostdep.h
delete mode 100644 common-user/host/x86_64/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/s390/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
diff --git a/common-user/host/aarch64/hostdep.h b/common-user/host/aarch64/hostdep.h
deleted file mode 100644
index 39299d798a..0000000000
--- a/common-user/host/aarch64/hostdep.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * hostdep.h : things which are dependent on the host architecture
- *
- * * Written by Peter Maydell <peter.maydell@linaro.org>
- *
- * 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
diff --git a/common-user/host/arm/hostdep.h b/common-user/host/arm/hostdep.h
deleted file mode 100644
index 86b137875a..0000000000
--- a/common-user/host/arm/hostdep.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * hostdep.h : things which are dependent on the host architecture
- *
- * * Written by Peter Maydell <peter.maydell@linaro.org>
- *
- * 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
diff --git a/common-user/host/i386/hostdep.h b/common-user/host/i386/hostdep.h
deleted file mode 100644
index ce7136501f..0000000000
--- a/common-user/host/i386/hostdep.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * hostdep.h : things which are dependent on the host architecture
- *
- * * Written by Peter Maydell <peter.maydell@linaro.org>
- *
- * 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
diff --git a/common-user/host/mips/hostdep.h b/common-user/host/mips/hostdep.h
deleted file mode 100644
index b18aca1deb..0000000000
--- a/common-user/host/mips/hostdep.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* We have a safe-syscall.inc.S */
-#define HAVE_SAFE_SYSCALL
diff --git a/common-user/host/ppc64/hostdep.h b/common-user/host/ppc64/hostdep.h
deleted file mode 100644
index 0c290dd904..0000000000
--- a/common-user/host/ppc64/hostdep.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * hostdep.h : things which are dependent on the host architecture
- *
- * * Written by Peter Maydell <peter.maydell@linaro.org>
- *
- * 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
diff --git a/common-user/host/riscv/hostdep.h b/common-user/host/riscv/hostdep.h
deleted file mode 100644
index 7f67c22868..0000000000
--- a/common-user/host/riscv/hostdep.h
+++ /dev/null
@@ -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
diff --git a/common-user/host/s390x/hostdep.h b/common-user/host/s390x/hostdep.h
deleted file mode 100644
index d801145854..0000000000
--- a/common-user/host/s390x/hostdep.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * hostdep.h : things which are dependent on the host architecture
- *
- * * Written by Peter Maydell <peter.maydell@linaro.org>
- *
- * 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
diff --git a/common-user/host/sparc64/hostdep.h b/common-user/host/sparc64/hostdep.h
deleted file mode 100644
index b18aca1deb..0000000000
--- a/common-user/host/sparc64/hostdep.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* We have a safe-syscall.inc.S */
-#define HAVE_SAFE_SYSCALL
diff --git a/common-user/host/x86_64/hostdep.h b/common-user/host/x86_64/hostdep.h
deleted file mode 100644
index 9c62bd26bd..0000000000
--- a/common-user/host/x86_64/hostdep.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * hostdep.h : things which are dependent on the host architecture
- *
- * * Written by Peter Maydell <peter.maydell@linaro.org>
- *
- * 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
diff --git a/linux-user/host/ia64/hostdep.h b/linux-user/host/ia64/hostdep.h
deleted file mode 100644
index 263bf7658e..0000000000
--- a/linux-user/host/ia64/hostdep.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * hostdep.h : things which are dependent on the host architecture
- *
- * * Written by Peter Maydell <peter.maydell@linaro.org>
- *
- * 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
diff --git a/linux-user/host/mips/hostdep.h b/linux-user/host/mips/hostdep.h
deleted file mode 100644
index ba111d75c3..0000000000
--- a/linux-user/host/mips/hostdep.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * hostdep.h : things which are dependent on the host architecture
- *
- * * Written by Peter Maydell <peter.maydell@linaro.org>
- *
- * 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
-
-#endif
diff --git a/linux-user/host/ppc/hostdep.h b/linux-user/host/ppc/hostdep.h
deleted file mode 100644
index 23d8bd9d47..0000000000
--- a/linux-user/host/ppc/hostdep.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * hostdep.h : things which are dependent on the host architecture
- *
- * * Written by Peter Maydell <peter.maydell@linaro.org>
- *
- * 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
diff --git a/linux-user/host/s390/hostdep.h b/linux-user/host/s390/hostdep.h
deleted file mode 100644
index afcba5a16a..0000000000
--- a/linux-user/host/s390/hostdep.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * hostdep.h : things which are dependent on the host architecture
- *
- * * Written by Peter Maydell <peter.maydell@linaro.org>
- *
- * 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
diff --git a/linux-user/host/sparc/hostdep.h b/linux-user/host/sparc/hostdep.h
deleted file mode 100644
index 391ad923cf..0000000000
--- a/linux-user/host/sparc/hostdep.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * hostdep.h : things which are dependent on the host architecture
- *
- * * Written by Peter Maydell <peter.maydell@linaro.org>
- *
- * 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
diff --git a/linux-user/host/sparc64/hostdep.h b/linux-user/host/sparc64/hostdep.h
deleted file mode 100644
index ce3968fca0..0000000000
--- a/linux-user/host/sparc64/hostdep.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * hostdep.h : things which are dependent on the host architecture
- *
- * * Written by Peter Maydell <peter.maydell@linaro.org>
- *
- * 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
-
-#endif
diff --git a/linux-user/host/x32/hostdep.h b/linux-user/host/x32/hostdep.h
deleted file mode 100644
index 2c2d6d37da..0000000000
--- a/linux-user/host/x32/hostdep.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * hostdep.h : things which are dependent on the host architecture
- *
- * * Written by Peter Maydell <peter.maydell@linaro.org>
- *
- * 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
diff --git a/linux-user/safe-syscall.h b/linux-user/safe-syscall.h
index ea0e8a8d24..0deb87e51a 100644
--- a/linux-user/safe-syscall.h
+++ b/linux-user/safe-syscall.h
@@ -124,7 +124,6 @@
* 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, int *errnop, long number, ...);
@@ -137,15 +136,4 @@ extern char safe_syscall_end[];
safe_syscall_base(&((TaskState *)thread_cpu->opaque)->signal_pending, \
&errno, __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
diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h
index 661612a088..f71f372829 100644
--- a/linux-user/user-internals.h
+++ b/linux-user/user-internals.h
@@ -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"
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 6d5e5b698c..ca8f24b9ec 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -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)
diff --git a/linux-user/safe-syscall.S b/linux-user/safe-syscall.S
index 42ea7c40ba..7ddc997801 100644
--- a/linux-user/safe-syscall.S
+++ b/linux-user/safe-syscall.S
@@ -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
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v5 08/17] common-user: Adjust system call return on FreeBSD
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
` (6 preceding siblings ...)
2021-11-17 16:04 ` [PATCH v5 07/17] linux-user: Remove HAVE_SAFE_SYSCALL and hostdep.h Richard Henderson
@ 2021-11-17 16:04 ` Richard Henderson
2021-11-17 16:44 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 09/17] *-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS Richard Henderson
` (9 subsequent siblings)
17 siblings, 1 reply; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:04 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp
From: Warner Losh <imp@bsdimp.com>
FreeBSD system calls return positive errno. On the 4 hosts for
which we have support, error is indicated by the C bit set or clear.
Signed-off-by: Warner Losh <imp@bsdimp.com>
[rth: Rebase on new safe_syscall_base api; add #error check.]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
common-user/host/aarch64/safe-syscall.inc.S | 12 +++++++++++-
common-user/host/arm/safe-syscall.inc.S | 11 +++++++++++
common-user/host/i386/safe-syscall.inc.S | 10 ++++++++++
common-user/host/x86_64/safe-syscall.inc.S | 10 ++++++++++
4 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/common-user/host/aarch64/safe-syscall.inc.S b/common-user/host/aarch64/safe-syscall.inc.S
index 95c60d8609..d3f065cdef 100644
--- a/common-user/host/aarch64/safe-syscall.inc.S
+++ b/common-user/host/aarch64/safe-syscall.inc.S
@@ -65,12 +65,22 @@ safe_syscall_start:
safe_syscall_end:
/* code path for having successfully executed the syscall */
- cmn x0, #4095
+#if defined(__linux__)
+ /* Linux kernel returns (small) negative errno. */
+ cmn 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
/* code path setting errno */
+#ifdef __linux__
0: neg w0, w0 /* create positive errno */
+#endif
1: str w0, [x11] /* store errno */
mov x0, #-1
ret
diff --git a/common-user/host/arm/safe-syscall.inc.S b/common-user/host/arm/safe-syscall.inc.S
index 17839c6486..328299021d 100644
--- a/common-user/host/arm/safe-syscall.inc.S
+++ b/common-user/host/arm/safe-syscall.inc.S
@@ -82,12 +82,23 @@ safe_syscall_start:
safe_syscall_end:
/* code path for having successfully executed the syscall */
+#if defined(__linux__)
+ /* Linux kernel returns (small) negative errno. */
cmp r0, #-4096
bhi 0f
+#elif defined(__FreeBSD__)
+ /* FreeBSD kernel returns positive errno and C bit set. */
+ bcs 1f
+#else
+#error "unsupported os"
+#endif
+
9: pop { r4, r5, r6, r7, r8, r9, r10, pc }
/* code path setting errno */
+#ifdef __linux__
0: neg r0, r0 /* create positive errno */
+#endif
1: str r0, [r9] /* store errno */
mov r0, #-1
b 9b
diff --git a/common-user/host/i386/safe-syscall.inc.S b/common-user/host/i386/safe-syscall.inc.S
index ad89521783..c27207492a 100644
--- a/common-user/host/i386/safe-syscall.inc.S
+++ b/common-user/host/i386/safe-syscall.inc.S
@@ -76,8 +76,16 @@ safe_syscall_start:
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
9: pop %ebx
.cfi_remember_state
@@ -97,7 +105,9 @@ safe_syscall_end:
.cfi_restore_state
/* code path setting errno */
+#ifdef __linux__
0: neg %eax /* create positive errno */
+#endif
1: mov 8+16(%esp), %ebx /* load errno pointer */
mov %eax, (%ebx) /* store errno */
mov $-1, %eax
diff --git a/common-user/host/x86_64/safe-syscall.inc.S b/common-user/host/x86_64/safe-syscall.inc.S
index 9a0c4c93b4..e3f920fa5c 100644
--- a/common-user/host/x86_64/safe-syscall.inc.S
+++ b/common-user/host/x86_64/safe-syscall.inc.S
@@ -75,8 +75,16 @@ safe_syscall_start:
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
9: pop %rbp
.cfi_remember_state
@@ -86,7 +94,9 @@ safe_syscall_end:
.cfi_restore_state
/* code path setting errno */
+#ifdef __linux__
0: neg %eax /* create positive errno */
+#endif
1: mov %eax, (%rbp) /* store errno */
mov $-1, %rax
jmp 9b
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v5 09/17] *-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
` (7 preceding siblings ...)
2021-11-17 16:04 ` [PATCH v5 08/17] common-user: Adjust system call return on FreeBSD Richard Henderson
@ 2021-11-17 16:04 ` Richard Henderson
2021-11-17 16:46 ` Warner Losh
2021-11-17 16:51 ` Philippe Mathieu-Daudé
2021-11-17 16:04 ` [PATCH v5 10/17] linux-user: Rename TARGET_QEMU_ESIGRETURN to QEMU_ESIGRETURN Richard Henderson
` (8 subsequent siblings)
17 siblings, 2 replies; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:04 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp
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.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/errno_defs.h | 2 +-
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 +-
common-user/host/aarch64/safe-syscall.inc.S | 2 +-
common-user/host/arm/safe-syscall.inc.S | 2 +-
common-user/host/i386/safe-syscall.inc.S | 2 +-
common-user/host/mips/safe-syscall.inc.S | 2 +-
common-user/host/ppc64/safe-syscall.inc.S | 2 +-
common-user/host/riscv/safe-syscall.inc.S | 2 +-
common-user/host/s390x/safe-syscall.inc.S | 2 +-
common-user/host/sparc64/safe-syscall.inc.S | 2 +-
common-user/host/x86_64/safe-syscall.inc.S | 2 +-
32 files changed, 46 insertions(+), 46 deletions(-)
diff --git a/bsd-user/errno_defs.h b/bsd-user/errno_defs.h
index 832671354f..583ebe8cee 100644
--- a/bsd-user/errno_defs.h
+++ b/bsd-user/errno_defs.h
@@ -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 /* compat */
#endif /* ! _ERRNO_DEFS_H_ */
diff --git a/linux-user/generic/target_errno_defs.h b/linux-user/generic/target_errno_defs.h
index 17d85e0b61..58a06a10d6 100644
--- a/linux-user/generic/target_errno_defs.h
+++ b/linux-user/generic/target_errno_defs.h
@@ -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
diff --git a/linux-user/safe-syscall.h b/linux-user/safe-syscall.h
index 0deb87e51a..70c2dec408 100644
--- a/linux-user/safe-syscall.h
+++ b/linux-user/safe-syscall.h
@@ -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
diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h
index 7457f8025c..b9f33bb44f 100644
--- a/linux-user/signal-common.h
+++ b/linux-user/signal-common.h
@@ -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
diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c
index 97e0728b67..775ba43913 100644
--- a/linux-user/aarch64/cpu_loop.c
+++ b/linux-user/aarch64/cpu_loop.c
@@ -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;
diff --git a/linux-user/alpha/cpu_loop.c b/linux-user/alpha/cpu_loop.c
index 4029849d5c..ce9b251ce3 100644
--- a/linux-user/alpha/cpu_loop.c
+++ b/linux-user/alpha/cpu_loop.c
@@ -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;
}
diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c
index 01cb6eb534..1fcf19750e 100644
--- a/linux-user/arm/cpu_loop.c
+++ b/linux-user/arm/cpu_loop.c
@@ -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;
diff --git a/linux-user/cris/cpu_loop.c b/linux-user/cris/cpu_loop.c
index 0d5d268609..f3e5b13f89 100644
--- a/linux-user/cris/cpu_loop.c
+++ b/linux-user/cris/cpu_loop.c
@@ -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;
diff --git a/linux-user/hexagon/cpu_loop.c b/linux-user/hexagon/cpu_loop.c
index 6b24cbaba9..1cacbf42f1 100644
--- a/linux-user/hexagon/cpu_loop.c
+++ b/linux-user/hexagon/cpu_loop.c
@@ -54,7 +54,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;
diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c
index 375576c8f0..5315224d12 100644
--- a/linux-user/hppa/cpu_loop.c
+++ b/linux-user/hppa/cpu_loop.c
@@ -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;
}
diff --git a/linux-user/i386/cpu_loop.c b/linux-user/i386/cpu_loop.c
index f6a1cc632b..fbd9a353e5 100644
--- a/linux-user/i386/cpu_loop.c
+++ b/linux-user/i386/cpu_loop.c
@@ -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;
diff --git a/linux-user/m68k/cpu_loop.c b/linux-user/m68k/cpu_loop.c
index 790bd558c3..b03c21a3dc 100644
--- a/linux-user/m68k/cpu_loop.c
+++ b/linux-user/m68k/cpu_loop.c
@@ -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;
diff --git a/linux-user/microblaze/cpu_loop.c b/linux-user/microblaze/cpu_loop.c
index a94467dd2d..6e368f986e 100644
--- a/linux-user/microblaze/cpu_loop.c
+++ b/linux-user/microblaze/cpu_loop.c
@@ -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) {
diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c
index b735c99a24..64f308c6ad 100644
--- a/linux-user/mips/cpu_loop.c
+++ b/linux-user/mips/cpu_loop.c
@@ -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;
}
diff --git a/linux-user/openrisc/cpu_loop.c b/linux-user/openrisc/cpu_loop.c
index 3cfdbbf037..3147ab2b62 100644
--- a/linux-user/openrisc/cpu_loop.c
+++ b/linux-user/openrisc/cpu_loop.c
@@ -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);
diff --git a/linux-user/ppc/cpu_loop.c b/linux-user/ppc/cpu_loop.c
index 483e669300..5348641e9e 100644
--- a/linux-user/ppc/cpu_loop.c
+++ b/linux-user/ppc/cpu_loop.c
@@ -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;
}
diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c
index b301dac802..20f8c48b1d 100644
--- a/linux-user/riscv/cpu_loop.c
+++ b/linux-user/riscv/cpu_loop.c
@@ -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;
diff --git a/linux-user/s390x/cpu_loop.c b/linux-user/s390x/cpu_loop.c
index d089c8417e..043582ca7c 100644
--- a/linux-user/s390x/cpu_loop.c
+++ b/linux-user/s390x/cpu_loop.c
@@ -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;
diff --git a/linux-user/sh4/cpu_loop.c b/linux-user/sh4/cpu_loop.c
index ac9b01840c..6c4ebfa969 100644
--- a/linux-user/sh4/cpu_loop.c
+++ b/linux-user/sh4/cpu_loop.c
@@ -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;
diff --git a/linux-user/signal.c b/linux-user/signal.c
index ca8f24b9ec..12b1705287 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -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];
diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c
index 0ba65e431c..529337c5e0 100644
--- a/linux-user/sparc/cpu_loop.c
+++ b/linux-user/sparc/cpu_loop.c
@@ -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)) {
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 544f5b662f..3c0e341e45 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -545,7 +545,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) {
@@ -6456,7 +6456,7 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
}
if (block_signals()) {
- return -TARGET_ERESTARTSYS;
+ return -QEMU_ERESTARTSYS;
}
fork_start();
@@ -8173,7 +8173,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);
@@ -9162,7 +9162,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;
}
}
@@ -9181,7 +9181,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;
}
}
@@ -9297,13 +9297,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
#ifdef TARGET_NR_sigreturn
case 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:
@@ -13141,7 +13141,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
diff --git a/linux-user/xtensa/cpu_loop.c b/linux-user/xtensa/cpu_loop.c
index a83490ab35..29cc6f3830 100644
--- a/linux-user/xtensa/cpu_loop.c
+++ b/linux-user/xtensa/cpu_loop.c
@@ -184,7 +184,7 @@ void cpu_loop(CPUXtensaState *env)
env->regs[2] = ret;
break;
- case -TARGET_ERESTARTSYS:
+ case -QEMU_ERESTARTSYS:
env->pc -= 3;
break;
diff --git a/common-user/host/aarch64/safe-syscall.inc.S b/common-user/host/aarch64/safe-syscall.inc.S
index d3f065cdef..6b405be448 100644
--- a/common-user/host/aarch64/safe-syscall.inc.S
+++ b/common-user/host/aarch64/safe-syscall.inc.S
@@ -86,7 +86,7 @@ safe_syscall_end:
ret
/* code path when we didn't execute the syscall */
-2: mov w0, #TARGET_ERESTARTSYS
+2: mov w0, #QEMU_ERESTARTSYS
b 1b
.cfi_endproc
diff --git a/common-user/host/arm/safe-syscall.inc.S b/common-user/host/arm/safe-syscall.inc.S
index 328299021d..e9b8d49d7c 100644
--- a/common-user/host/arm/safe-syscall.inc.S
+++ b/common-user/host/arm/safe-syscall.inc.S
@@ -104,7 +104,7 @@ safe_syscall_end:
b 9b
/* code path when we didn't execute the syscall */
-2: ldr r0, =TARGET_ERESTARTSYS
+2: ldr r0, =QEMU_ERESTARTSYS
b 1b
.fnend
diff --git a/common-user/host/i386/safe-syscall.inc.S b/common-user/host/i386/safe-syscall.inc.S
index c27207492a..3f928764db 100644
--- a/common-user/host/i386/safe-syscall.inc.S
+++ b/common-user/host/i386/safe-syscall.inc.S
@@ -114,7 +114,7 @@ safe_syscall_end:
jmp 9b
/* code path when we didn't execute the syscall */
-2: mov $TARGET_ERESTARTSYS, %eax
+2: mov $QEMU_ERESTARTSYS, %eax
jmp 1b
.cfi_endproc
diff --git a/common-user/host/mips/safe-syscall.inc.S b/common-user/host/mips/safe-syscall.inc.S
index 1e2f5a079c..90bf3cc03e 100644
--- a/common-user/host/mips/safe-syscall.inc.S
+++ b/common-user/host/mips/safe-syscall.inc.S
@@ -122,7 +122,7 @@ safe_syscall_end:
PTR_ADDIU sp, sp, FRAME
/* code path when we didn't execute the syscall */
-0: li v0, TARGET_ERESTARTSYS
+0: li v0, QEMU_ERESTARTSYS
/* code path setting errno */
1: PTR_L t0, ERRNOP(sp)
diff --git a/common-user/host/ppc64/safe-syscall.inc.S b/common-user/host/ppc64/safe-syscall.inc.S
index e35408c5fb..11c4672f71 100644
--- a/common-user/host/ppc64/safe-syscall.inc.S
+++ b/common-user/host/ppc64/safe-syscall.inc.S
@@ -92,7 +92,7 @@ safe_syscall_end:
blr
/* code path when we didn't execute the syscall */
-0: li 3, TARGET_ERESTARTSYS
+0: li 3, QEMU_ERESTARTSYS
b 1b
.cfi_endproc
diff --git a/common-user/host/riscv/safe-syscall.inc.S b/common-user/host/riscv/safe-syscall.inc.S
index eddede702b..2f07c729c4 100644
--- a/common-user/host/riscv/safe-syscall.inc.S
+++ b/common-user/host/riscv/safe-syscall.inc.S
@@ -81,7 +81,7 @@ safe_syscall_end:
ret
/* code path when we didn't execute the syscall */
-2: li a0, TARGET_ERESTARTSYS
+2: li a0, QEMU_ERESTARTSYS
j 1b
.cfi_endproc
diff --git a/common-user/host/s390x/safe-syscall.inc.S b/common-user/host/s390x/safe-syscall.inc.S
index f2a3bccc13..c1cc127e85 100644
--- a/common-user/host/s390x/safe-syscall.inc.S
+++ b/common-user/host/s390x/safe-syscall.inc.S
@@ -91,7 +91,7 @@ safe_syscall_end:
.cfi_restore_state
/* code path when we didn't execute the syscall */
-1: lghi %r2, -TARGET_ERESTARTSYS
+1: lghi %r2, -QEMU_ERESTARTSYS
/* code path setting errno */
0: lcr %r2, %r2 /* create positive errno */
diff --git a/common-user/host/sparc64/safe-syscall.inc.S b/common-user/host/sparc64/safe-syscall.inc.S
index 2492fcbd9e..55e32b30eb 100644
--- a/common-user/host/sparc64/safe-syscall.inc.S
+++ b/common-user/host/sparc64/safe-syscall.inc.S
@@ -85,7 +85,7 @@ safe_syscall_end:
/* code path when we didn't execute the syscall */
2: ba,pt %xcc, 1b
- set TARGET_ERESTARTSYS, %o0
+ set QEMU_ERESTARTSYS, %o0
.cfi_endproc
.size safe_syscall_base, .-safe_syscall_base
diff --git a/common-user/host/x86_64/safe-syscall.inc.S b/common-user/host/x86_64/safe-syscall.inc.S
index e3f920fa5c..b93d684e66 100644
--- a/common-user/host/x86_64/safe-syscall.inc.S
+++ b/common-user/host/x86_64/safe-syscall.inc.S
@@ -102,7 +102,7 @@ safe_syscall_end:
jmp 9b
/* code path when we didn't execute the syscall */
-2: mov $TARGET_ERESTARTSYS, %eax
+2: mov $QEMU_ERESTARTSYS, %eax
jmp 1b
.cfi_endproc
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v5 10/17] linux-user: Rename TARGET_QEMU_ESIGRETURN to QEMU_ESIGRETURN
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
` (8 preceding siblings ...)
2021-11-17 16:04 ` [PATCH v5 09/17] *-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS Richard Henderson
@ 2021-11-17 16:04 ` Richard Henderson
2021-11-17 17:01 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 11/17] bsd-user: Create special-errno.h Richard Henderson
` (7 subsequent siblings)
17 siblings, 1 reply; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:04 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp
This value is fully internal to qemu, and so is not a TARGET define.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
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(-)
diff --git a/linux-user/generic/target_errno_defs.h b/linux-user/generic/target_errno_defs.h
index 58a06a10d6..bb37d88be9 100644
--- a/linux-user/generic/target_errno_defs.h
+++ b/linux-user/generic/target_errno_defs.h
@@ -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
diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c
index 775ba43913..98b53962cd 100644
--- a/linux-user/aarch64/cpu_loop.c
+++ b/linux-user/aarch64/cpu_loop.c
@@ -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;
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
index 29c52db3f1..df9e39a4ba 100644
--- a/linux-user/aarch64/signal.c
+++ b/linux-user/aarch64/signal.c
@@ -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)
diff --git a/linux-user/alpha/cpu_loop.c b/linux-user/alpha/cpu_loop.c
index ce9b251ce3..37c33f0ccd 100644
--- a/linux-user/alpha/cpu_loop.c
+++ b/linux-user/alpha/cpu_loop.c
@@ -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
diff --git a/linux-user/alpha/signal.c b/linux-user/alpha/signal.c
index bbe3dd175a..4ec42994d4 100644
--- a/linux-user/alpha/signal.c
+++ b/linux-user/alpha/signal.c
@@ -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)
diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c
index 1fcf19750e..f153ab503a 100644
--- a/linux-user/arm/cpu_loop.c
+++ b/linux-user/arm/cpu_loop.c
@@ -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;
}
}
diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c
index df9f8e8eb2..cf99fd7b8a 100644
--- a/linux-user/arm/signal.c
+++ b/linux-user/arm/signal.c
@@ -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;
}
/*
diff --git a/linux-user/cris/cpu_loop.c b/linux-user/cris/cpu_loop.c
index f3e5b13f89..5213aebf55 100644
--- a/linux-user/cris/cpu_loop.c
+++ b/linux-user/cris/cpu_loop.c
@@ -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;
diff --git a/linux-user/cris/signal.c b/linux-user/cris/signal.c
index 7f6aca934e..4f532b2903 100644
--- a/linux-user/cris/signal.c
+++ b/linux-user/cris/signal.c
@@ -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)
diff --git a/linux-user/hexagon/cpu_loop.c b/linux-user/hexagon/cpu_loop.c
index 1cacbf42f1..b84e25bf71 100644
--- a/linux-user/hexagon/cpu_loop.c
+++ b/linux-user/hexagon/cpu_loop.c
@@ -56,7 +56,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;
diff --git a/linux-user/hexagon/signal.c b/linux-user/hexagon/signal.c
index 74e61739a0..ad4e3822d5 100644
--- a/linux-user/hexagon/signal.c
+++ b/linux-user/hexagon/signal.c
@@ -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);
diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c
index 5315224d12..a47a63176b 100644
--- a/linux-user/hppa/cpu_loop.c
+++ b/linux-user/hppa/cpu_loop.c
@@ -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;
diff --git a/linux-user/hppa/signal.c b/linux-user/hppa/signal.c
index c2fbc26ebb..962f551c04 100644
--- a/linux-user/hppa/signal.c
+++ b/linux-user/hppa/signal.c
@@ -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;
}
diff --git a/linux-user/i386/cpu_loop.c b/linux-user/i386/cpu_loop.c
index fbd9a353e5..9aaae93e2f 100644
--- a/linux-user/i386/cpu_loop.c
+++ b/linux-user/i386/cpu_loop.c
@@ -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;
diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c
index 433efa3d69..4372621a4d 100644
--- a/linux-user/i386/signal.c
+++ b/linux-user/i386/signal.c
@@ -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
diff --git a/linux-user/m68k/cpu_loop.c b/linux-user/m68k/cpu_loop.c
index b03c21a3dc..3181594414 100644
--- a/linux-user/m68k/cpu_loop.c
+++ b/linux-user/m68k/cpu_loop.c
@@ -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;
}
}
diff --git a/linux-user/m68k/signal.c b/linux-user/m68k/signal.c
index ec33482e14..5f35354487 100644
--- a/linux-user/m68k/signal.c
+++ b/linux-user/m68k/signal.c
@@ -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)
diff --git a/linux-user/microblaze/cpu_loop.c b/linux-user/microblaze/cpu_loop.c
index 6e368f986e..ff1fb26c8b 100644
--- a/linux-user/microblaze/cpu_loop.c
+++ b/linux-user/microblaze/cpu_loop.c
@@ -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
diff --git a/linux-user/microblaze/signal.c b/linux-user/microblaze/signal.c
index 8ebb6a1b7d..5188d74025 100644
--- a/linux-user/microblaze/signal.c
+++ b/linux-user/microblaze/signal.c
@@ -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)
diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c
index 64f308c6ad..32f9fc1c1c 100644
--- a/linux-user/mips/cpu_loop.c
+++ b/linux-user/mips/cpu_loop.c
@@ -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;
diff --git a/linux-user/mips/signal.c b/linux-user/mips/signal.c
index 8f79e405ec..58a9d7a8a3 100644
--- a/linux-user/mips/signal.c
+++ b/linux-user/mips/signal.c
@@ -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)
diff --git a/linux-user/openrisc/cpu_loop.c b/linux-user/openrisc/cpu_loop.c
index 3147ab2b62..592901a68b 100644
--- a/linux-user/openrisc/cpu_loop.c
+++ b/linux-user/openrisc/cpu_loop.c
@@ -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;
diff --git a/linux-user/ppc/cpu_loop.c b/linux-user/ppc/cpu_loop.c
index 5348641e9e..30c82f2354 100644
--- a/linux-user/ppc/cpu_loop.c
+++ b/linux-user/ppc/cpu_loop.c
@@ -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;
diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c
index 90a0369632..176c9d8503 100644
--- a/linux-user/ppc/signal.c
+++ b/linux-user/ppc/signal.c
@@ -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;
diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c
index 20f8c48b1d..0cd8985cb8 100644
--- a/linux-user/riscv/cpu_loop.c
+++ b/linux-user/riscv/cpu_loop.c
@@ -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) {
diff --git a/linux-user/riscv/signal.c b/linux-user/riscv/signal.c
index a0f9542ce3..296e39fbf0 100644
--- a/linux-user/riscv/signal.c
+++ b/linux-user/riscv/signal.c
@@ -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);
diff --git a/linux-user/s390x/cpu_loop.c b/linux-user/s390x/cpu_loop.c
index 043582ca7c..ad0c3cd263 100644
--- a/linux-user/s390x/cpu_loop.c
+++ b/linux-user/s390x/cpu_loop.c
@@ -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;
diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c
index 676b948147..f47713e04a 100644
--- a/linux-user/s390x/signal.c
+++ b/linux-user/s390x/signal.c
@@ -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)
diff --git a/linux-user/sh4/cpu_loop.c b/linux-user/sh4/cpu_loop.c
index 6c4ebfa969..3290f6445c 100644
--- a/linux-user/sh4/cpu_loop.c
+++ b/linux-user/sh4/cpu_loop.c
@@ -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;
diff --git a/linux-user/sh4/signal.c b/linux-user/sh4/signal.c
index faa869fb19..f6a18bc6b5 100644
--- a/linux-user/sh4/signal.c
+++ b/linux-user/sh4/signal.c
@@ -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)
diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c
index 529337c5e0..8765ab6020 100644
--- a/linux-user/sparc/cpu_loop.c
+++ b/linux-user/sparc/cpu_loop.c
@@ -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)) {
diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c
index 23e1e761de..b501750fe0 100644
--- a/linux-user/sparc/signal.c
+++ b/linux-user/sparc/signal.c
@@ -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)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 3c0e341e45..1ef6abb776 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -548,7 +548,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";
}
diff --git a/linux-user/xtensa/cpu_loop.c b/linux-user/xtensa/cpu_loop.c
index 29cc6f3830..6bc6d6dee6 100644
--- a/linux-user/xtensa/cpu_loop.c
+++ b/linux-user/xtensa/cpu_loop.c
@@ -188,7 +188,7 @@ void cpu_loop(CPUXtensaState *env)
env->pc -= 3;
break;
- case -TARGET_QEMU_ESIGRETURN:
+ case -QEMU_ESIGRETURN:
break;
}
break;
diff --git a/linux-user/xtensa/signal.c b/linux-user/xtensa/signal.c
index 81572a5fc7..06d91a37ec 100644
--- a/linux-user/xtensa/signal.c
+++ b/linux-user/xtensa/signal.c
@@ -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)
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v5 11/17] bsd-user: Create special-errno.h
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
` (9 preceding siblings ...)
2021-11-17 16:04 ` [PATCH v5 10/17] linux-user: Rename TARGET_QEMU_ESIGRETURN to QEMU_ESIGRETURN Richard Henderson
@ 2021-11-17 16:04 ` Richard Henderson
2021-11-17 17:21 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 12/17] linux-user: " Richard Henderson
` (6 subsequent siblings)
17 siblings, 1 reply; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:04 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp
Pull the internal errno used by qemu internally its own
header file, for use by safe-syscall.S.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
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
diff --git a/bsd-user/errno_defs.h b/bsd-user/errno_defs.h
index 583ebe8cee..73cfa24b7f 100644
--- a/bsd-user/errno_defs.h
+++ b/bsd-user/errno_defs.h
@@ -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 /* compat */
+
+#include "special-errno.h"
+
+_Static_assert(TARGET_ERESTART == QEMU_ERESTARTSYS,
+ "TARGET_ERESTART and QEMU_ERESTARTSYS expected to match");
#endif /* ! _ERRNO_DEFS_H_ */
diff --git a/bsd-user/special-errno.h b/bsd-user/special-errno.h
new file mode 100644
index 0000000000..03599d9b5a
--- /dev/null
+++ b/bsd-user/special-errno.h
@@ -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 */
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v5 12/17] linux-user: Create special-errno.h
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
` (10 preceding siblings ...)
2021-11-17 16:04 ` [PATCH v5 11/17] bsd-user: Create special-errno.h Richard Henderson
@ 2021-11-17 16:04 ` Richard Henderson
2021-11-17 17:21 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 13/17] meson: Add build infrastructure for common-user Richard Henderson
` (5 subsequent siblings)
17 siblings, 1 reply; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:04 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp
Pull the two internal errno used by qemu internally into their own
header file. This includes the one define required by safe-syscall.S.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
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
diff --git a/linux-user/cpu_loop-common.h b/linux-user/cpu_loop-common.h
index 8828af28a4..dc0042e4de 100644
--- a/linux-user/cpu_loop-common.h
+++ b/linux-user/cpu_loop-common.h
@@ -21,6 +21,7 @@
#define CPU_LOOP_COMMON_H
#include "exec/log.h"
+#include "special-errno.h"
#define EXCP_DUMP(env, fmt, ...) \
do { \
diff --git a/linux-user/generic/target_errno_defs.h b/linux-user/generic/target_errno_defs.h
index bb37d88be9..c2f9d403e7 100644
--- a/linux-user/generic/target_errno_defs.h
+++ b/linux-user/generic/target_errno_defs.h
@@ -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
diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h
index b9f33bb44f..42aa479080 100644
--- a/linux-user/signal-common.h
+++ b/linux-user/signal-common.h
@@ -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;
diff --git a/linux-user/special-errno.h b/linux-user/special-errno.h
new file mode 100644
index 0000000000..4120455baa
--- /dev/null
+++ b/linux-user/special-errno.h
@@ -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 */
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 1ef6abb776..33d342157d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -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"
diff --git a/linux-user/safe-syscall.S b/linux-user/safe-syscall.S
index 7ddc997801..74f7e35694 100644
--- a/linux-user/safe-syscall.S
+++ b/linux-user/safe-syscall.S
@@ -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.
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v5 13/17] meson: Add build infrastructure for common-user
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
` (11 preceding siblings ...)
2021-11-17 16:04 ` [PATCH v5 12/17] linux-user: " Richard Henderson
@ 2021-11-17 16:04 ` Richard Henderson
2021-11-17 17:22 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 14/17] common-user: Move safe-syscall.* from linux-user Richard Henderson
` (4 subsequent siblings)
17 siblings, 1 reply; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:04 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp
The first objects to be added will be target-independent,
and so built once for the host.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
meson.build | 16 +++++++++++++++-
bsd-user/meson.build | 2 ++
common-user/meson.build | 1 +
linux-user/meson.build | 3 +++
4 files changed, 21 insertions(+), 1 deletion(-)
create mode 100644 common-user/meson.build
diff --git a/meson.build b/meson.build
index c58abf0d0d..387f7fe1c9 100644
--- a/meson.build
+++ b/meson.build
@@ -2359,6 +2359,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()
@@ -2603,15 +2604,28 @@ 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)
+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')
diff --git a/bsd-user/meson.build b/bsd-user/meson.build
index 87885d91ed..25c3976ead 100644
--- a/bsd-user/meson.build
+++ b/bsd-user/meson.build
@@ -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',
diff --git a/common-user/meson.build b/common-user/meson.build
new file mode 100644
index 0000000000..4f5c0f2f88
--- /dev/null
+++ b/common-user/meson.build
@@ -0,0 +1 @@
+common_user_inc += include_directories('host/' / config_host['ARCH'])
diff --git a/linux-user/meson.build b/linux-user/meson.build
index bf62c13e37..d6fa4f4d74 100644
--- a/linux-user/meson.build
+++ b/linux-user/meson.build
@@ -2,6 +2,9 @@ if not have_linux_user
subdir_done()
endif
+common_user_inc += include_directories('host/' / config_host['ARCH'])
+common_user_inc += include_directories('.')
+
linux_user_ss.add(files(
'elfload.c',
'exit.c',
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v5 14/17] common-user: Move safe-syscall.* from linux-user
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
` (12 preceding siblings ...)
2021-11-17 16:04 ` [PATCH v5 13/17] meson: Add build infrastructure for common-user Richard Henderson
@ 2021-11-17 16:04 ` Richard Henderson
2021-11-17 17:23 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 15/17] linux-user: Move thunk.c from top-level Richard Henderson
` (3 subsequent siblings)
17 siblings, 1 reply; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:04 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp
Move linux-user/safe-syscall.S 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.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
{linux-user => include/user}/safe-syscall.h | 0
linux-user/signal.c | 2 +-
linux-user/syscall.c | 2 +-
common-user/meson.build | 2 ++
{linux-user => common-user}/safe-syscall.S | 0
linux-user/meson.build | 1 -
6 files changed, 4 insertions(+), 3 deletions(-)
rename {linux-user => include/user}/safe-syscall.h (100%)
rename {linux-user => common-user}/safe-syscall.S (100%)
diff --git a/linux-user/safe-syscall.h b/include/user/safe-syscall.h
similarity index 100%
rename from linux-user/safe-syscall.h
rename to include/user/safe-syscall.h
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 12b1705287..510db73c34 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -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];
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 33d342157d..53deb887ca 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -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"
diff --git a/common-user/meson.build b/common-user/meson.build
index 4f5c0f2f88..c02b5d9cc2 100644
--- a/common-user/meson.build
+++ b/common-user/meson.build
@@ -1 +1,3 @@
common_user_inc += include_directories('host/' / config_host['ARCH'])
+
+common_user_ss.add(files('safe-syscall.S'))
diff --git a/linux-user/safe-syscall.S b/common-user/safe-syscall.S
similarity index 100%
rename from linux-user/safe-syscall.S
rename to common-user/safe-syscall.S
diff --git a/linux-user/meson.build b/linux-user/meson.build
index d6fa4f4d74..bf9d945504 100644
--- a/linux-user/meson.build
+++ b/linux-user/meson.build
@@ -12,7 +12,6 @@ linux_user_ss.add(files(
'linuxload.c',
'main.c',
'mmap.c',
- 'safe-syscall.S',
'signal.c',
'strace.c',
'syscall.c',
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v5 15/17] linux-user: Move thunk.c from top-level
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
` (13 preceding siblings ...)
2021-11-17 16:04 ` [PATCH v5 14/17] common-user: Move safe-syscall.* from linux-user Richard Henderson
@ 2021-11-17 16:04 ` Richard Henderson
2021-11-17 16:52 ` Philippe Mathieu-Daudé
2021-11-17 17:27 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 16/17] meson: Move linux_user_ss to linux-user/ Richard Henderson
` (2 subsequent siblings)
17 siblings, 2 replies; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:04 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp
So far, linux-user is the only user of these functions.
Clean up the build machinery by restricting it to linux-user.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
meson.build | 1 -
thunk.c => linux-user/thunk.c | 0
linux-user/meson.build | 1 +
3 files changed, 1 insertion(+), 1 deletion(-)
rename thunk.c => linux-user/thunk.c (100%)
diff --git a/meson.build b/meson.build
index 387f7fe1c9..9f59c57909 100644
--- a/meson.build
+++ b/meson.build
@@ -2614,7 +2614,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)
diff --git a/thunk.c b/linux-user/thunk.c
similarity index 100%
rename from thunk.c
rename to linux-user/thunk.c
diff --git a/linux-user/meson.build b/linux-user/meson.build
index bf9d945504..fcf7d40f23 100644
--- a/linux-user/meson.build
+++ b/linux-user/meson.build
@@ -15,6 +15,7 @@ linux_user_ss.add(files(
'signal.c',
'strace.c',
'syscall.c',
+ 'thunk.c',
'uaccess.c',
'uname.c',
))
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v5 16/17] meson: Move linux_user_ss to linux-user/
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
` (14 preceding siblings ...)
2021-11-17 16:04 ` [PATCH v5 15/17] linux-user: Move thunk.c from top-level Richard Henderson
@ 2021-11-17 16:04 ` Richard Henderson
2021-11-17 16:56 ` Philippe Mathieu-Daudé
2021-11-17 17:31 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 17/17] meson: Move bsd_user_ss to bsd-user/ Richard Henderson
2021-11-17 17:42 ` [PATCH v5 00/17] linux-user: simplify safe signal handling Warner Losh
17 siblings, 2 replies; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:04 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp
We have no need to reference linux_user_ss outside of linux-user.
Go ahead and merge it directly into specific_ss.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
meson.build | 3 ---
linux-user/meson.build | 4 ++++
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/meson.build b/meson.build
index 9f59c57909..ecc181ea13 100644
--- a/meson.build
+++ b/meson.build
@@ -2363,7 +2363,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()
@@ -2614,8 +2613,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(),
diff --git a/linux-user/meson.build b/linux-user/meson.build
index fcf7d40f23..b89534c49c 100644
--- a/linux-user/meson.build
+++ b/linux-user/meson.build
@@ -2,6 +2,8 @@ if not have_linux_user
subdir_done()
endif
+linux_user_ss = ss.source_set()
+
common_user_inc += include_directories('host/' / config_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)
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v5 17/17] meson: Move bsd_user_ss to bsd-user/
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
` (15 preceding siblings ...)
2021-11-17 16:04 ` [PATCH v5 16/17] meson: Move linux_user_ss to linux-user/ Richard Henderson
@ 2021-11-17 16:04 ` Richard Henderson
2021-11-17 16:56 ` Philippe Mathieu-Daudé
2021-11-17 17:29 ` Warner Losh
2021-11-17 17:42 ` [PATCH v5 00/17] linux-user: simplify safe signal handling Warner Losh
17 siblings, 2 replies; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 16:04 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, imp
We have no need to reference bsd_user_ss outside of bsd-user.
Go ahead and merge it directly into specific_ss.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
meson.build | 3 ---
bsd-user/meson.build | 4 ++++
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/meson.build b/meson.build
index ecc181ea13..9f7756a805 100644
--- a/meson.build
+++ b/meson.build
@@ -2356,7 +2356,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()
@@ -2611,8 +2610,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(),
diff --git a/bsd-user/meson.build b/bsd-user/meson.build
index 25c3976ead..9fcb80c3fa 100644
--- a/bsd-user/meson.build
+++ b/bsd-user/meson.build
@@ -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)
--
2.25.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* Re: [PATCH v5 01/17] linux-user: Add host_signal_set_pc to set pc in mcontext
2021-11-17 16:03 ` [PATCH v5 01/17] linux-user: Add host_signal_set_pc to set pc in mcontext Richard Henderson
@ 2021-11-17 16:23 ` Warner Losh
2021-11-17 16:37 ` Alex Bennée
1 sibling, 0 replies; 46+ messages in thread
From: Warner Losh @ 2021-11-17 16:23 UTC (permalink / raw)
To: Richard Henderson
Cc: Philippe Mathieu-Daudé, QEMU Developers, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 7389 bytes --]
On Wed, Nov 17, 2021 at 9:04 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> From: Warner Losh <imp@bsdimp.com>
>
> Add a new function host_signal_set_pc to set the next pc in an
> mcontext. The caller should ensure this is a valid PC for execution.
>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Message-Id: <20211113045603.60391-2-imp@bsdimp.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> linux-user/host/aarch64/host-signal.h | 5 +++++
> linux-user/host/alpha/host-signal.h | 5 +++++
> linux-user/host/arm/host-signal.h | 5 +++++
> linux-user/host/i386/host-signal.h | 5 +++++
> linux-user/host/mips/host-signal.h | 5 +++++
> linux-user/host/ppc/host-signal.h | 5 +++++
> linux-user/host/riscv/host-signal.h | 5 +++++
> linux-user/host/s390/host-signal.h | 5 +++++
> linux-user/host/sparc/host-signal.h | 9 +++++++++
> linux-user/host/x86_64/host-signal.h | 5 +++++
> 10 files changed, 54 insertions(+)
>
Reviewed-by: Warner Losh <imp@bsdimp.com>
I'm unsure on the protocol for this situation (where I wrote the change,
but someone else picked it up), but the change looks good to me....
> diff --git a/linux-user/host/aarch64/host-signal.h
> b/linux-user/host/aarch64/host-signal.h
> index 0c0b08383a..9770b36dc1 100644
> --- a/linux-user/host/aarch64/host-signal.h
> +++ b/linux-user/host/aarch64/host-signal.h
> @@ -35,6 +35,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
> return uc->uc_mcontext.pc;
> }
>
> +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
> +{
> + uc->uc_mcontext.pc = pc;
> +}
> +
> static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
> {
> struct _aarch64_ctx *hdr;
> diff --git a/linux-user/host/alpha/host-signal.h
> b/linux-user/host/alpha/host-signal.h
> index e080be412f..f4c942948a 100644
> --- a/linux-user/host/alpha/host-signal.h
> +++ b/linux-user/host/alpha/host-signal.h
> @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
> return uc->uc_mcontext.sc_pc;
> }
>
> +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
> +{
> + uc->uc_mcontext.sc_pc = pc;
> +}
> +
> static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
> {
> uint32_t *pc = (uint32_t *)host_signal_pc(uc);
> diff --git a/linux-user/host/arm/host-signal.h
> b/linux-user/host/arm/host-signal.h
> index efb165c0c5..6c095773c0 100644
> --- a/linux-user/host/arm/host-signal.h
> +++ b/linux-user/host/arm/host-signal.h
> @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
> return uc->uc_mcontext.arm_pc;
> }
>
> +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
> +{
> + uc->uc_mcontext.arm_pc = pc;
> +}
> +
> static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
> {
> /*
> diff --git a/linux-user/host/i386/host-signal.h
> b/linux-user/host/i386/host-signal.h
> index 4c8eef99ce..abe1ece5c9 100644
> --- a/linux-user/host/i386/host-signal.h
> +++ b/linux-user/host/i386/host-signal.h
> @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
> return uc->uc_mcontext.gregs[REG_EIP];
> }
>
> +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
> +{
> + uc->uc_mcontext.gregs[REG_EIP] = pc;
> +}
> +
> static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
> {
> return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe
> diff --git a/linux-user/host/mips/host-signal.h
> b/linux-user/host/mips/host-signal.h
> index ef341f7c20..c666ed8c3f 100644
> --- a/linux-user/host/mips/host-signal.h
> +++ b/linux-user/host/mips/host-signal.h
> @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
> return uc->uc_mcontext.pc;
> }
>
> +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
> +{
> + uc->uc_mcontext.pc = pc;
> +}
> +
> #if defined(__misp16) || defined(__mips_micromips)
> #error "Unsupported encoding"
> #endif
> diff --git a/linux-user/host/ppc/host-signal.h
> b/linux-user/host/ppc/host-signal.h
> index a491c413dc..1d8e658ff7 100644
> --- a/linux-user/host/ppc/host-signal.h
> +++ b/linux-user/host/ppc/host-signal.h
> @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
> return uc->uc_mcontext.regs->nip;
> }
>
> +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
> +{
> + uc->uc_mcontext.regs->nip = pc;
> +}
> +
> static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
> {
> return uc->uc_mcontext.regs->trap != 0x400
> diff --git a/linux-user/host/riscv/host-signal.h
> b/linux-user/host/riscv/host-signal.h
> index 3b168cb58b..a4f170efb0 100644
> --- a/linux-user/host/riscv/host-signal.h
> +++ b/linux-user/host/riscv/host-signal.h
> @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
> return uc->uc_mcontext.__gregs[REG_PC];
> }
>
> +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
> +{
> + uc->uc_mcontext.__gregs[REG_PC] = pc;
> +}
> +
> static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
> {
> /*
> diff --git a/linux-user/host/s390/host-signal.h
> b/linux-user/host/s390/host-signal.h
> index 26990e4893..a524f2ab00 100644
> --- a/linux-user/host/s390/host-signal.h
> +++ b/linux-user/host/s390/host-signal.h
> @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
> return uc->uc_mcontext.psw.addr;
> }
>
> +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
> +{
> + uc->uc_mcontext.psw.addr = pc;
> +}
> +
> static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
> {
> uint16_t *pinsn = (uint16_t *)host_signal_pc(uc);
> diff --git a/linux-user/host/sparc/host-signal.h
> b/linux-user/host/sparc/host-signal.h
> index 5e71d33f8e..7342936071 100644
> --- a/linux-user/host/sparc/host-signal.h
> +++ b/linux-user/host/sparc/host-signal.h
> @@ -20,6 +20,15 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
> #endif
> }
>
> +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
> +{
> +#ifdef __arch64__
> + uc->uc_mcontext.mc_gregs[MC_PC] = pc;
> +#else
> + uc->uc_mcontext.gregs[REG_PC] = pc;
> +#endif
> +}
> +
> static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
> {
> uint32_t insn = *(uint32_t *)host_signal_pc(uc);
> diff --git a/linux-user/host/x86_64/host-signal.h
> b/linux-user/host/x86_64/host-signal.h
> index 883d2fcf65..c71d597eb2 100644
> --- a/linux-user/host/x86_64/host-signal.h
> +++ b/linux-user/host/x86_64/host-signal.h
> @@ -15,6 +15,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
> return uc->uc_mcontext.gregs[REG_RIP];
> }
>
> +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
> +{
> + uc->uc_mcontext.gregs[REG_RIP] = pc;
> +}
> +
> static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
> {
> return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 8924 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 02/17] linux-user/signal.c: Create a common rewind_if_in_safe_syscall
2021-11-17 16:03 ` [PATCH v5 02/17] linux-user/signal.c: Create a common rewind_if_in_safe_syscall Richard Henderson
@ 2021-11-17 16:24 ` Warner Losh
2021-11-17 16:37 ` Alex Bennée
1 sibling, 0 replies; 46+ messages in thread
From: Warner Losh @ 2021-11-17 16:24 UTC (permalink / raw)
To: Richard Henderson
Cc: Philippe Mathieu-Daudé, QEMU Developers, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 9984 bytes --]
On Wed, Nov 17, 2021 at 9:04 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> From: Warner Losh <imp@bsdimp.com>
>
> All instances of rewind_if_in_safe_syscall are the same, differing only
> in how the instruction point is fetched from the ucontext and the size
> of the registers. Use host_signal_pc and new host_signal_set_pc
> interfaces to fetch the pointer to the PC and adjust if needed. Delete
> all the old copies of rewind_if_in_safe_syscall.
>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Message-Id: <20211113045603.60391-3-imp@bsdimp.com>
> [rth: include safe-syscall.h, simplify ifdefs]
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> linux-user/host/aarch64/hostdep.h | 20 --------------------
> linux-user/host/arm/hostdep.h | 20 --------------------
> linux-user/host/i386/hostdep.h | 20 --------------------
> linux-user/host/ppc64/hostdep.h | 20 --------------------
> linux-user/host/riscv/hostdep.h | 20 --------------------
> linux-user/host/s390x/hostdep.h | 20 --------------------
> linux-user/host/x86_64/hostdep.h | 20 --------------------
> linux-user/safe-syscall.h | 3 +++
> linux-user/signal.c | 15 ++++++++++++---
> 9 files changed, 15 insertions(+), 143 deletions(-)
>
Reviewed by: Warner Losh <imp@bsdimp.com>
(this one I'm sure it's ok since things changed from my original
and the changes are good).
> diff --git a/linux-user/host/aarch64/hostdep.h
> b/linux-user/host/aarch64/hostdep.h
> index a8d41a21ad..39299d798a 100644
> --- a/linux-user/host/aarch64/hostdep.h
> +++ b/linux-user/host/aarch64/hostdep.h
> @@ -15,24 +15,4 @@
> /* We have a safe-syscall.inc.S */
> #define HAVE_SAFE_SYSCALL
>
> -#ifndef __ASSEMBLER__
> -
> -/* These are defined by the safe-syscall.inc.S file */
> -extern char safe_syscall_start[];
> -extern char safe_syscall_end[];
> -
> -/* 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)
> -{
> - ucontext_t *uc = puc;
> - __u64 *pcreg = &uc->uc_mcontext.pc;
> -
> - if (*pcreg > (uintptr_t)safe_syscall_start
> - && *pcreg < (uintptr_t)safe_syscall_end) {
> - *pcreg = (uintptr_t)safe_syscall_start;
> - }
> -}
> -
> -#endif /* __ASSEMBLER__ */
> -
> #endif
> diff --git a/linux-user/host/arm/hostdep.h b/linux-user/host/arm/hostdep.h
> index 9276fe6ceb..86b137875a 100644
> --- a/linux-user/host/arm/hostdep.h
> +++ b/linux-user/host/arm/hostdep.h
> @@ -15,24 +15,4 @@
> /* We have a safe-syscall.inc.S */
> #define HAVE_SAFE_SYSCALL
>
> -#ifndef __ASSEMBLER__
> -
> -/* These are defined by the safe-syscall.inc.S file */
> -extern char safe_syscall_start[];
> -extern char safe_syscall_end[];
> -
> -/* 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)
> -{
> - ucontext_t *uc = puc;
> - unsigned long *pcreg = &uc->uc_mcontext.arm_pc;
> -
> - if (*pcreg > (uintptr_t)safe_syscall_start
> - && *pcreg < (uintptr_t)safe_syscall_end) {
> - *pcreg = (uintptr_t)safe_syscall_start;
> - }
> -}
> -
> -#endif /* __ASSEMBLER__ */
> -
> #endif
> diff --git a/linux-user/host/i386/hostdep.h
> b/linux-user/host/i386/hostdep.h
> index 073be74d87..ce7136501f 100644
> --- a/linux-user/host/i386/hostdep.h
> +++ b/linux-user/host/i386/hostdep.h
> @@ -15,24 +15,4 @@
> /* We have a safe-syscall.inc.S */
> #define HAVE_SAFE_SYSCALL
>
> -#ifndef __ASSEMBLER__
> -
> -/* These are defined by the safe-syscall.inc.S file */
> -extern char safe_syscall_start[];
> -extern char safe_syscall_end[];
> -
> -/* 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)
> -{
> - ucontext_t *uc = puc;
> - greg_t *pcreg = &uc->uc_mcontext.gregs[REG_EIP];
> -
> - if (*pcreg > (uintptr_t)safe_syscall_start
> - && *pcreg < (uintptr_t)safe_syscall_end) {
> - *pcreg = (uintptr_t)safe_syscall_start;
> - }
> -}
> -
> -#endif /* __ASSEMBLER__ */
> -
> #endif
> diff --git a/linux-user/host/ppc64/hostdep.h
> b/linux-user/host/ppc64/hostdep.h
> index 98979ad917..0c290dd904 100644
> --- a/linux-user/host/ppc64/hostdep.h
> +++ b/linux-user/host/ppc64/hostdep.h
> @@ -15,24 +15,4 @@
> /* We have a safe-syscall.inc.S */
> #define HAVE_SAFE_SYSCALL
>
> -#ifndef __ASSEMBLER__
> -
> -/* These are defined by the safe-syscall.inc.S file */
> -extern char safe_syscall_start[];
> -extern char safe_syscall_end[];
> -
> -/* 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)
> -{
> - ucontext_t *uc = puc;
> - unsigned long *pcreg = &uc->uc_mcontext.gp_regs[PT_NIP];
> -
> - if (*pcreg > (uintptr_t)safe_syscall_start
> - && *pcreg < (uintptr_t)safe_syscall_end) {
> - *pcreg = (uintptr_t)safe_syscall_start;
> - }
> -}
> -
> -#endif /* __ASSEMBLER__ */
> -
> #endif
> diff --git a/linux-user/host/riscv/hostdep.h
> b/linux-user/host/riscv/hostdep.h
> index 2ba07456ae..7f67c22868 100644
> --- a/linux-user/host/riscv/hostdep.h
> +++ b/linux-user/host/riscv/hostdep.h
> @@ -11,24 +11,4 @@
> /* We have a safe-syscall.inc.S */
> #define HAVE_SAFE_SYSCALL
>
> -#ifndef __ASSEMBLER__
> -
> -/* These are defined by the safe-syscall.inc.S file */
> -extern char safe_syscall_start[];
> -extern char safe_syscall_end[];
> -
> -/* 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)
> -{
> - ucontext_t *uc = puc;
> - unsigned long *pcreg = &uc->uc_mcontext.__gregs[REG_PC];
> -
> - if (*pcreg > (uintptr_t)safe_syscall_start
> - && *pcreg < (uintptr_t)safe_syscall_end) {
> - *pcreg = (uintptr_t)safe_syscall_start;
> - }
> -}
> -
> -#endif /* __ASSEMBLER__ */
> -
> #endif
> diff --git a/linux-user/host/s390x/hostdep.h
> b/linux-user/host/s390x/hostdep.h
> index 4f0171f36f..d801145854 100644
> --- a/linux-user/host/s390x/hostdep.h
> +++ b/linux-user/host/s390x/hostdep.h
> @@ -15,24 +15,4 @@
> /* We have a safe-syscall.inc.S */
> #define HAVE_SAFE_SYSCALL
>
> -#ifndef __ASSEMBLER__
> -
> -/* These are defined by the safe-syscall.inc.S file */
> -extern char safe_syscall_start[];
> -extern char safe_syscall_end[];
> -
> -/* 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)
> -{
> - ucontext_t *uc = puc;
> - unsigned long *pcreg = &uc->uc_mcontext.psw.addr;
> -
> - if (*pcreg > (uintptr_t)safe_syscall_start
> - && *pcreg < (uintptr_t)safe_syscall_end) {
> - *pcreg = (uintptr_t)safe_syscall_start;
> - }
> -}
> -
> -#endif /* __ASSEMBLER__ */
> -
> #endif
> diff --git a/linux-user/host/x86_64/hostdep.h
> b/linux-user/host/x86_64/hostdep.h
> index a4fefb5114..9c62bd26bd 100644
> --- a/linux-user/host/x86_64/hostdep.h
> +++ b/linux-user/host/x86_64/hostdep.h
> @@ -15,24 +15,4 @@
> /* We have a safe-syscall.inc.S */
> #define HAVE_SAFE_SYSCALL
>
> -#ifndef __ASSEMBLER__
> -
> -/* These are defined by the safe-syscall.inc.S file */
> -extern char safe_syscall_start[];
> -extern char safe_syscall_end[];
> -
> -/* 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)
> -{
> - ucontext_t *uc = puc;
> - greg_t *pcreg = &uc->uc_mcontext.gregs[REG_RIP];
> -
> - if (*pcreg > (uintptr_t)safe_syscall_start
> - && *pcreg < (uintptr_t)safe_syscall_end) {
> - *pcreg = (uintptr_t)safe_syscall_start;
> - }
> -}
> -
> -#endif /* __ASSEMBLER__ */
> -
> #endif
> diff --git a/linux-user/safe-syscall.h b/linux-user/safe-syscall.h
> index 6bc0390262..aaa9ffc0e2 100644
> --- a/linux-user/safe-syscall.h
> +++ b/linux-user/safe-syscall.h
> @@ -127,6 +127,9 @@
> #ifdef HAVE_SAFE_SYSCALL
> /* The core part of this function is implemented in assembly */
> extern long safe_syscall_base(int *pending, long number, ...);
> +/* These are defined by the safe-syscall.inc.S file */
> +extern char safe_syscall_start[];
> +extern char safe_syscall_end[];
>
> #define safe_syscall(...) \
> ({ \
> diff --git a/linux-user/signal.c b/linux-user/signal.c
> index 81c45bfce9..6d5e5b698c 100644
> --- a/linux-user/signal.c
> +++ b/linux-user/signal.c
> @@ -31,6 +31,7 @@
> #include "trace.h"
> #include "signal-common.h"
> #include "host-signal.h"
> +#include "safe-syscall.h"
>
> static struct target_sigaction sigact_table[TARGET_NSIG];
>
> @@ -793,12 +794,20 @@ int queue_signal(CPUArchState *env, int sig, int
> si_type,
> return 1; /* indicates that the signal was queued */
> }
>
> -#ifndef HAVE_SAFE_SYSCALL
> +
> +/* 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)
> {
> - /* Default version: never rewind */
> -}
> +#ifdef HAVE_SAFE_SYSCALL
> + ucontext_t *uc = (ucontext_t *)puc;
> + uintptr_t pcreg = host_signal_pc(uc);
> +
> + if (pcreg > (uintptr_t)safe_syscall_start
> + && 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)
> {
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 11978 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 03/17] linux-user/safe-syscall.inc.S: Move to common-user
2021-11-17 16:03 ` [PATCH v5 03/17] linux-user/safe-syscall.inc.S: Move to common-user Richard Henderson
@ 2021-11-17 16:25 ` Warner Losh
2021-11-17 16:38 ` Alex Bennée
1 sibling, 0 replies; 46+ messages in thread
From: Warner Losh @ 2021-11-17 16:25 UTC (permalink / raw)
To: Richard Henderson
Cc: Philippe Mathieu-Daudé, QEMU Developers, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 6597 bytes --]
On Wed, Nov 17, 2021 at 9:04 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> From: Warner Losh <imp@bsdimp.com>
>
> Move all the safe_syscall.inc.S files to common-user. They are almost
> identical between linux-user and bsd-user to re-use.
>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Message-Id: <20211113045603.60391-4-imp@bsdimp.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> meson.build | 2 ++
> {linux-user => common-user}/host/aarch64/hostdep.h | 0
> {linux-user => common-user}/host/arm/hostdep.h | 0
> {linux-user => common-user}/host/i386/hostdep.h | 0
> {linux-user => common-user}/host/ppc64/hostdep.h | 0
> {linux-user => common-user}/host/riscv/hostdep.h | 0
> {linux-user => common-user}/host/s390x/hostdep.h | 0
> {linux-user => common-user}/host/x86_64/hostdep.h | 0
> {linux-user => common-user}/host/aarch64/safe-syscall.inc.S | 0
> {linux-user => common-user}/host/arm/safe-syscall.inc.S | 0
> {linux-user => common-user}/host/i386/safe-syscall.inc.S | 0
> {linux-user => common-user}/host/ppc64/safe-syscall.inc.S | 0
> {linux-user => common-user}/host/riscv/safe-syscall.inc.S | 0
> {linux-user => common-user}/host/s390x/safe-syscall.inc.S | 0
> {linux-user => common-user}/host/x86_64/safe-syscall.inc.S | 0
> 15 files changed, 2 insertions(+)
> rename {linux-user => common-user}/host/aarch64/hostdep.h (100%)
> rename {linux-user => common-user}/host/arm/hostdep.h (100%)
> rename {linux-user => common-user}/host/i386/hostdep.h (100%)
> rename {linux-user => common-user}/host/ppc64/hostdep.h (100%)
> rename {linux-user => common-user}/host/riscv/hostdep.h (100%)
> rename {linux-user => common-user}/host/s390x/hostdep.h (100%)
> rename {linux-user => common-user}/host/x86_64/hostdep.h (100%)
> rename {linux-user => common-user}/host/aarch64/safe-syscall.inc.S (100%)
> rename {linux-user => common-user}/host/arm/safe-syscall.inc.S (100%)
> rename {linux-user => common-user}/host/i386/safe-syscall.inc.S (100%)
> rename {linux-user => common-user}/host/ppc64/safe-syscall.inc.S (100%)
> rename {linux-user => common-user}/host/riscv/safe-syscall.inc.S (100%)
> rename {linux-user => common-user}/host/s390x/safe-syscall.inc.S (100%)
> rename {linux-user => common-user}/host/x86_64/safe-syscall.inc.S (100%)
>
Reviewed-by: Warner Losh <imp@bsdimp.com>
> diff --git a/meson.build b/meson.build
> index e2d38a43e6..c58abf0d0d 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2878,10 +2878,12 @@ foreach target : target_dirs
> if 'CONFIG_LINUX_USER' in config_target
> base_dir = 'linux-user'
> target_inc += include_directories('linux-user/host/' /
> config_host['ARCH'])
> + target_inc += include_directories('common-user/host/' /
> config_host['ARCH'])
> endif
> if 'CONFIG_BSD_USER' in config_target
> base_dir = 'bsd-user'
> target_inc += include_directories('bsd-user/' / targetos)
> + target_inc += include_directories('common-user/host/' /
> config_host['ARCH'])
> dir = base_dir / abi
> arch_srcs += files(dir / 'target_arch_cpu.c')
> endif
> diff --git a/linux-user/host/aarch64/hostdep.h
> b/common-user/host/aarch64/hostdep.h
> similarity index 100%
> rename from linux-user/host/aarch64/hostdep.h
> rename to common-user/host/aarch64/hostdep.h
> diff --git a/linux-user/host/arm/hostdep.h b/common-user/host/arm/hostdep.h
> similarity index 100%
> rename from linux-user/host/arm/hostdep.h
> rename to common-user/host/arm/hostdep.h
> diff --git a/linux-user/host/i386/hostdep.h
> b/common-user/host/i386/hostdep.h
> similarity index 100%
> rename from linux-user/host/i386/hostdep.h
> rename to common-user/host/i386/hostdep.h
> diff --git a/linux-user/host/ppc64/hostdep.h
> b/common-user/host/ppc64/hostdep.h
> similarity index 100%
> rename from linux-user/host/ppc64/hostdep.h
> rename to common-user/host/ppc64/hostdep.h
> diff --git a/linux-user/host/riscv/hostdep.h
> b/common-user/host/riscv/hostdep.h
> similarity index 100%
> rename from linux-user/host/riscv/hostdep.h
> rename to common-user/host/riscv/hostdep.h
> diff --git a/linux-user/host/s390x/hostdep.h
> b/common-user/host/s390x/hostdep.h
> similarity index 100%
> rename from linux-user/host/s390x/hostdep.h
> rename to common-user/host/s390x/hostdep.h
> diff --git a/linux-user/host/x86_64/hostdep.h
> b/common-user/host/x86_64/hostdep.h
> similarity index 100%
> rename from linux-user/host/x86_64/hostdep.h
> rename to common-user/host/x86_64/hostdep.h
> diff --git a/linux-user/host/aarch64/safe-syscall.inc.S
> b/common-user/host/aarch64/safe-syscall.inc.S
> similarity index 100%
> rename from linux-user/host/aarch64/safe-syscall.inc.S
> rename to common-user/host/aarch64/safe-syscall.inc.S
> diff --git a/linux-user/host/arm/safe-syscall.inc.S
> b/common-user/host/arm/safe-syscall.inc.S
> similarity index 100%
> rename from linux-user/host/arm/safe-syscall.inc.S
> rename to common-user/host/arm/safe-syscall.inc.S
> diff --git a/linux-user/host/i386/safe-syscall.inc.S
> b/common-user/host/i386/safe-syscall.inc.S
> similarity index 100%
> rename from linux-user/host/i386/safe-syscall.inc.S
> rename to common-user/host/i386/safe-syscall.inc.S
> diff --git a/linux-user/host/ppc64/safe-syscall.inc.S
> b/common-user/host/ppc64/safe-syscall.inc.S
> similarity index 100%
> rename from linux-user/host/ppc64/safe-syscall.inc.S
> rename to common-user/host/ppc64/safe-syscall.inc.S
> diff --git a/linux-user/host/riscv/safe-syscall.inc.S
> b/common-user/host/riscv/safe-syscall.inc.S
> similarity index 100%
> rename from linux-user/host/riscv/safe-syscall.inc.S
> rename to common-user/host/riscv/safe-syscall.inc.S
> diff --git a/linux-user/host/s390x/safe-syscall.inc.S
> b/common-user/host/s390x/safe-syscall.inc.S
> similarity index 100%
> rename from linux-user/host/s390x/safe-syscall.inc.S
> rename to common-user/host/s390x/safe-syscall.inc.S
> diff --git a/linux-user/host/x86_64/safe-syscall.inc.S
> b/common-user/host/x86_64/safe-syscall.inc.S
> similarity index 100%
> rename from linux-user/host/x86_64/safe-syscall.inc.S
> rename to common-user/host/x86_64/safe-syscall.inc.S
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 8031 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 04/17] common-user: Move syscall error detection into safe_syscall_base
2021-11-17 16:03 ` [PATCH v5 04/17] common-user: Move syscall error detection into safe_syscall_base Richard Henderson
@ 2021-11-17 16:28 ` Warner Losh
2021-11-22 11:55 ` Peter Maydell
1 sibling, 0 replies; 46+ messages in thread
From: Warner Losh @ 2021-11-17 16:28 UTC (permalink / raw)
To: Richard Henderson; +Cc: QEMU Developers, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 32048 bytes --]
On Wed, Nov 17, 2021 at 9:04 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> 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 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.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> linux-user/safe-syscall.h | 20 +++---
> common-user/host/aarch64/safe-syscall.inc.S | 55 +++++++++-------
> common-user/host/arm/safe-syscall.inc.S | 58 ++++++++++-------
> common-user/host/i386/safe-syscall.inc.S | 51 +++++++++------
> common-user/host/ppc64/safe-syscall.inc.S | 63 +++++++++++--------
> common-user/host/riscv/safe-syscall.inc.S | 50 +++++++++------
> common-user/host/s390x/safe-syscall.inc.S | 50 +++++++++------
> common-user/host/x86_64/safe-syscall.inc.S | 70 ++++++++++++---------
> 8 files changed, 243 insertions(+), 174 deletions(-)
>
Reviewed by: Warner Losh <imp@bsdimp.com>
And I think it may fix a bug, when integrated with bsd-user fork,
in PowerPC hosts (though there's other bugs lingering there).
> diff --git a/linux-user/safe-syscall.h b/linux-user/safe-syscall.h
> index aaa9ffc0e2..ea0e8a8d24 100644
> --- a/linux-user/safe-syscall.h
> +++ b/linux-user/safe-syscall.h
> @@ -125,23 +125,17 @@
> * 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, ...);
> +
> +/* The core part of this function is implemented in assembly. */
> +extern long safe_syscall_base(int *pending, int *errnop, long number,
> ...);
> +
> /* 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,
> \
> + &errno, __VA_ARGS__)
>
> #else
>
> diff --git a/common-user/host/aarch64/safe-syscall.inc.S
> b/common-user/host/aarch64/safe-syscall.inc.S
> index bc1f5a9792..95c60d8609 100644
> --- a/common-user/host/aarch64/safe-syscall.inc.S
> +++ b/common-user/host/aarch64/safe-syscall.inc.S
> @@ -17,22 +17,21 @@
> .type safe_syscall_start, #function
> .type safe_syscall_end, #function
>
> - /* This is the entry point for making a system call. The calling
> + /*
> + * 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:
> + /*
> + * 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
> + * x1 == errno
> + * x2 == syscall number
> + * x3 ... x7, (stack) == syscall arguments
> * and return the result in x0
> * and the syscall instruction needs
> * x8 == syscall number
> @@ -40,17 +39,18 @@ safe_syscall_base:
> * 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]
> + mov x10, x0 /* signal_pending pointer */
> + mov x11, x1 /* errno pointer */
> + mov x8, x2 /* syscall number */
> + mov x0, x3 /* syscall arguments */
> + mov x1, x4
> + mov x2, x5
> + mov x3, x6
> + mov x4, x7
> + ldp x5, x6, [sp]
>
> - /* This next sequence of code works in conjunction with the
> + /*
> + * 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'.
> @@ -59,17 +59,26 @@ safe_syscall_base:
> */
> safe_syscall_start:
> /* if signal_pending is non-zero, don't do the call */
> - ldr w10, [x9]
> - cbnz w10, 0f
> + ldr w9, [x10]
> + cbnz w9, 2f
> svc 0x0
> safe_syscall_end:
> +
> /* code path for having successfully executed the syscall */
> + cmn x0, #4095
> + b.cs 1f
> ret
>
> -0:
> - /* code path when we didn't execute the syscall */
> - mov x0, #-TARGET_ERESTARTSYS
> + /* code path setting errno */
> +0: neg w0, w0 /* create positive errno */
> +1: str w0, [x11] /* store errno */
> + mov x0, #-1
> ret
> +
> + /* code path when we didn't execute the syscall */
> +2: mov w0, #TARGET_ERESTARTSYS
> + b 1b
> +
> .cfi_endproc
>
> .size safe_syscall_base, .-safe_syscall_base
> diff --git a/common-user/host/arm/safe-syscall.inc.S
> b/common-user/host/arm/safe-syscall.inc.S
> index 88c4958504..17839c6486 100644
> --- a/common-user/host/arm/safe-syscall.inc.S
> +++ b/common-user/host/arm/safe-syscall.inc.S
> @@ -22,33 +22,35 @@
> .arm
> .align 2
>
> - /* This is the entry point for making a system call. The calling
> + /*
> + * 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:
> .fnstart
> .cfi_startproc
> mov r12, sp /* save entry stack */
> - push { r4, r5, r6, r7, r8, lr }
> - .save { r4, r5, r6, r7, r8, lr }
> - .cfi_adjust_cfa_offset 24
> + push { r4, r5, r6, r7, r8, r9, r10, lr }
> + .save { r4, r5, r6, r7, r8, r9, r10, lr }
> + .cfi_adjust_cfa_offset 32
> .cfi_rel_offset r4, 0
> .cfi_rel_offset r5, 4
> .cfi_rel_offset r6, 8
> .cfi_rel_offset r7, 12
> .cfi_rel_offset r8, 16
> - .cfi_rel_offset lr, 20
> + .cfi_rel_offset r9, 20
> + .cfi_rel_offset r10, 24
> + .cfi_rel_offset lr, 28
>
> - /* The syscall calling convention isn't the same as the C one:
> - * we enter with r0 == *signal_pending
> - * r1 == syscall number
> - * r2, r3, [sp+0] ... [sp+12] == syscall arguments
> + /*
> + * The syscall calling convention isn't the same as the C one:
> + * we enter with r0 == &signal_pending
> + * r1 == &errno
> + * r2 == syscall number
> + * r3, [sp+0] ... [sp+16] == syscall arguments
> * and return the result in r0
> * and the syscall instruction needs
> * r7 == syscall number
> @@ -58,12 +60,13 @@ safe_syscall_base:
> * Note the 16 bytes that we pushed to save registers.
> */
> mov r8, r0 /* copy signal_pending */
> - mov r7, r1 /* syscall number */
> - mov r0, r2 /* syscall args */
> - mov r1, r3
> - ldm r12, { r2, r3, r4, r5, r6 }
> + mov r9, r1 /* copy errnop */
> + mov r7, r2 /* syscall number */
> + mov r0, r3 /* syscall args */
> + ldm r12, { r1, r2, r3, r4, r5, r6 }
>
> - /* This next sequence of code works in conjunction with the
> + /*
> + * 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'.
> @@ -74,16 +77,25 @@ 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 */
> - pop { r4, r5, r6, r7, r8, pc }
>
> -1:
> + /* code path for having successfully executed the syscall */
> + cmp r0, #-4096
> + bhi 0f
> +9: pop { r4, r5, r6, r7, r8, r9, r10, pc }
> +
> + /* code path setting errno */
> +0: neg r0, r0 /* create positive errno */
> +1: str r0, [r9] /* store errno */
> + mov r0, #-1
> + b 9b
> +
> /* code path when we didn't execute the syscall */
> - ldr r0, =-TARGET_ERESTARTSYS
> - pop { r4, r5, r6, r7, r8, pc }
> +2: ldr r0, =TARGET_ERESTARTSYS
> + b 1b
> +
> .fnend
> .cfi_endproc
>
> diff --git a/common-user/host/i386/safe-syscall.inc.S
> b/common-user/host/i386/safe-syscall.inc.S
> index 9e58fc6504..ad89521783 100644
> --- a/common-user/host/i386/safe-syscall.inc.S
> +++ b/common-user/host/i386/safe-syscall.inc.S
> @@ -15,14 +15,12 @@
> .global safe_syscall_end
> .type safe_syscall_base, @function
>
> - /* This is the entry point for making a system call. The calling
> + /*
> + * 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
> @@ -41,9 +39,10 @@ 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
> - * 8(%esp) == syscall number
> - * 12(%esp) ... 32(%esp) == syscall arguments
> + * 4(%esp) == &signal_pending
> + * 8(%esp) == &errno
> + * 12(%esp) == syscall number
> + * 16(%esp) ... 36(%esp) == syscall arguments
> * and return the result in eax
> * and the syscall instruction needs
> * eax == syscall number
> @@ -52,14 +51,15 @@ safe_syscall_base:
> * Shuffle everything around appropriately.
> * Note the 16 bytes that we pushed to save registers.
> */
> - mov 12+16(%esp), %ebx /* the syscall arguments */
> - mov 16+16(%esp), %ecx
> - mov 20+16(%esp), %edx
> - mov 24+16(%esp), %esi
> - mov 28+16(%esp), %edi
> - mov 32+16(%esp), %ebp
> + mov 16+16(%esp), %ebx /* the syscall arguments */
> + mov 20+16(%esp), %ecx
> + mov 24+16(%esp), %edx
> + mov 28+16(%esp), %esi
> + mov 32+16(%esp), %edi
> + mov 36+16(%esp), %ebp
>
> - /* This next sequence of code works in conjunction with the
> + /*
> + * 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'.
> @@ -70,12 +70,16 @@ 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 */
> - pop %ebx
> + cmp $-4095, %eax
> + jae 0f
> +
> +9: pop %ebx
> .cfi_remember_state
> .cfi_adjust_cfa_offset -4
> .cfi_restore ebx
> @@ -90,11 +94,18 @@ safe_syscall_end:
> .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
> +
> + /* code path setting errno */
> +0: neg %eax /* create positive errno */
> +1: mov 8+16(%esp), %ebx /* load errno pointer */
> + mov %eax, (%ebx) /* store errno */
> + mov $-1, %eax
> + jmp 9b
> +
> + /* code path when we didn't execute the syscall */
> +2: mov $TARGET_ERESTARTSYS, %eax
> + jmp 1b
> .cfi_endproc
>
> .size safe_syscall_base, .-safe_syscall_base
> diff --git a/common-user/host/ppc64/safe-syscall.inc.S
> b/common-user/host/ppc64/safe-syscall.inc.S
> index 875133173b..e35408c5fb 100644
> --- a/common-user/host/ppc64/safe-syscall.inc.S
> +++ b/common-user/host/ppc64/safe-syscall.inc.S
> @@ -17,14 +17,19 @@
>
> .text
>
> - /* This is the entry point for making a system call. The calling
> +#if _CALL_ELF == 2
> +#define PARAM_OFS 32
> +#else
> +#define PARAM_OFS 48
> +#endif
> +#define PARAM(X) PARAM_OFS + X*8
> +
> + /*
> + * 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.
> */
> #if _CALL_ELF == 2
> safe_syscall_base:
> @@ -39,9 +44,11 @@ safe_syscall_base:
> .L.safe_syscall_base:
> .cfi_startproc
> #endif
> - /* We enter with r3 == *signal_pending
> - * r4 == syscall number
> - * r5 ... r10 == syscall arguments
> + /*
> + * We enter with r3 == &signal_pending
> + * r4 == &errno
> + * r5 == syscall number
> + * r6 ... r10, (stack) == syscall arguments
> * and return the result in r3
> * and the syscall instruction needs
> * r0 == syscall number
> @@ -49,18 +56,18 @@ safe_syscall_base:
> * and returns the result in r3
> * Shuffle everything around appropriately.
> */
> - std 14, 16(1) /* Preserve r14 in SP+16 */
> - .cfi_offset 14, 16
> - mr 14, 3 /* signal_pending */
> - mr 0, 4 /* syscall number */
> - mr 3, 5 /* syscall arguments */
> - mr 4, 6
> - mr 5, 7
> - mr 6, 8
> - mr 7, 9
> - mr 8, 10
> + mr 11, 3 /* signal_pending pointer */
> + std 4, PARAM(1)(1) /* save errno pointer in param slot */
> + mr 0, 5 /* syscall number */
> + mr 3, 6 /* syscall arguments */
> + mr 4, 7
> + mr 5, 8
> + mr 6, 9
> + mr 7, 10
> + ld 8, PARAM(8)(1)
>
> - /* This next sequence of code works in conjunction with the
> + /*
> + * 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'.
> @@ -69,23 +76,25 @@ safe_syscall_base:
> */
> safe_syscall_start:
> /* if signal_pending is non-zero, don't do the call */
> - lwz 12, 0(14)
> + lwz 12, 0(11)
> cmpwi 0, 12, 0
> bne- 0f
> 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
> + /* code path for having successfully executed the syscall */
> + bnslr+ /* SO set for syscall error */
> +
> + /* code path setting errno */
> +1: ld 11, PARAM(1)(1) /* restore errno pointer */
> + stw 3, 0(11) /* store errno */
> + li 3, -1
> 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
> +0: li 3, TARGET_ERESTARTSYS
> + b 1b
> +
> .cfi_endproc
>
> #if _CALL_ELF == 2
> diff --git a/common-user/host/riscv/safe-syscall.inc.S
> b/common-user/host/riscv/safe-syscall.inc.S
> index 9ca3fbfd1e..eddede702b 100644
> --- a/common-user/host/riscv/safe-syscall.inc.S
> +++ b/common-user/host/riscv/safe-syscall.inc.S
> @@ -23,17 +23,15 @@
> * 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
> - * a1 == syscall number
> - * a2 ... a7 == syscall arguments
> + * we enter with a0 == &signal_pending
> + * a1 == &errno
> + * a2 == syscall number
> + * a3 ... a7, [sp] == syscall arguments
> * and return the result in a0
> * and the syscall instruction needs
> * a7 == syscall number
> @@ -42,14 +40,19 @@ safe_syscall_base:
> * Shuffle everything around appropriately.
> */
> mv t0, a0 /* signal_pending pointer */
> - mv t1, a1 /* syscall number */
> - mv a0, a2 /* syscall arguments */
> - mv a1, a3
> - mv a2, a4
> - mv a3, a5
> - mv a4, a6
> - mv a5, a7
> - mv a7, t1
> + mv t1, a1 /* errno pointer */
> + mv t2, a2 /* syscall number */
> + mv a0, a3 /* syscall arguments */
> + mv a1, a4
> + mv a2, a5
> + mv a3, a6
> + mv a4, a7
> +#if __riscv_xlen == 32
> + lw a5, 0(sp)
> +#else
> + ld a5, 0(sp)
> +#endif
> + mv a7, t2
>
> /*
> * This next sequence of code works in conjunction with the
> @@ -61,17 +64,26 @@ safe_syscall_base:
> */
> safe_syscall_start:
> /* If signal_pending is non-zero, don't do the call */
> - lw t1, 0(t0)
> - bnez t1, 0f
> + lw t2, 0(t0)
> + bnez t2, 2f
> scall
> safe_syscall_end:
> +
> /* code path for having successfully executed the syscall */
> + li t2, -4096
> + bgtu a0, t2, 0f
> ret
>
> -0:
> - /* code path when we didn't execute the syscall */
> - li a0, -TARGET_ERESTARTSYS
> + /* code path setting errno */
> +0: neg a0, a0 /* create positive errno */
> +1: sw a0, 0(t1) /* store errno */
> + li a0, -1
> ret
> +
> + /* code path when we didn't execute the syscall */
> +2: li a0, TARGET_ERESTARTSYS
> + j 1b
> +
> .cfi_endproc
>
> .size safe_syscall_base, .-safe_syscall_base
> diff --git a/common-user/host/s390x/safe-syscall.inc.S
> b/common-user/host/s390x/safe-syscall.inc.S
> index 414b44ad38..f2a3bccc13 100644
> --- a/common-user/host/s390x/safe-syscall.inc.S
> +++ b/common-user/host/s390x/safe-syscall.inc.S
> @@ -15,14 +15,12 @@
> .global safe_syscall_end
> .type safe_syscall_base, @function
>
> - /* This is the entry point for making a system call. The calling
> + /*
> + * 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
> @@ -44,11 +42,13 @@ 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
> + /*
> + * 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
> + * we enter with r2 == &signal_pending
> + * r3 == &errno
> + * r4 == syscall number
> + * r5, r6, (stack) == syscall arguments
> * and return the result in r2
> * and the syscall instruction needs
> * r1 == syscall number
> @@ -57,13 +57,14 @@ safe_syscall_base:
> * Shuffle everything around appropriately.
> */
> lgr %r8,%r2 /* signal_pending pointer */
> - lgr %r1,%r3 /* syscall number */
> - lgr %r2,%r4 /* syscall args */
> - lgr %r3,%r5
> - lgr %r4,%r6
> - lmg %r5,%r7,320(%r15)
> + lgr %r9,%r3 /* errno pointer */
> + lgr %r1,%r4 /* syscall number */
> + lgr %r2,%r5 /* syscall args */
> + lgr %r3,%r6
> + lmg %r4,%r7,320(%r15)
>
> - /* This next sequence of code works in conjunction with the
> + /*
> + * 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'.
> @@ -73,18 +74,31 @@ safe_syscall_base:
> safe_syscall_start:
> /* if signal_pending is non-zero, don't do the call */
> icm %r0,15,0(%r8)
> - jne 2f
> + jne 1f
> svc 0
> safe_syscall_end:
>
> -1: lg %r15,0(%r15) /* load back chain */
> + /* code path for having successfully executed the syscall */
> + lghi %r0, -4095 /* check for syscall error */
> + clgr %r2, %r0
> + jgnl 0f
> +
> +9: 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
> +
> + /* code path when we didn't execute the syscall */
> +1: lghi %r2, -TARGET_ERESTARTSYS
> +
> + /* code path setting errno */
> +0: lcr %r2, %r2 /* create positive errno */
> + st %r2, 0(%r9) /* store errno */
> + lghi %r2, -1
> + j 9b
> +
> .cfi_endproc
>
> .size safe_syscall_base, .-safe_syscall_base
> diff --git a/common-user/host/x86_64/safe-syscall.inc.S
> b/common-user/host/x86_64/safe-syscall.inc.S
> index f36992daa3..9a0c4c93b4 100644
> --- a/common-user/host/x86_64/safe-syscall.inc.S
> +++ b/common-user/host/x86_64/safe-syscall.inc.S
> @@ -14,18 +14,17 @@
> .global safe_syscall_end
> .type safe_syscall_base, @function
>
> - /* This is the entry point for making a system call. The calling
> + /*
> + * 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
> - /* This saves a frame pointer and aligns the stack for the
> syscall.
> + /*
> + * This saves a frame pointer and aligns the stack for the
> syscall.
> * (It's unclear if the syscall ABI has the same stack alignment
> * requirements as the userspace function call ABI, but better
> safe than
> * sorry. Appendix A2 of
> http://www.x86-64.org/documentation/abi.pdf
> @@ -35,11 +34,12 @@ 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
> - * rsi == syscall number
> - * rdx, rcx, r8, r9, (stack), (stack) == syscall
> arguments
> + /*
> + * The syscall calling convention isn't the same as the C one:
> + * we enter with rdi == &signal_pending
> + * rsi == &errno
> + * rdx == syscall number
> + * rcx, r8, r9, (stack...) == syscall arguments
> * and return the result in rax
> * and the syscall instruction needs
> * rax == syscall number
> @@ -48,17 +48,19 @@ safe_syscall_base:
> * Shuffle everything around appropriately.
> * Note that syscall will trash rcx and r11.
> */
> - mov %rsi, %rax /* syscall number */
> - mov %rdi, %rbp /* signal_pending pointer */
> + mov %rdi, %r11 /* signal_pending pointer */
> + mov %rsi, %rbp /* errno pointer */
> + mov %rdx, %rax /* syscall number */
> /* and the syscall arguments */
> - mov %rdx, %rdi
> - mov %rcx, %rsi
> - mov %r8, %rdx
> - mov %r9, %r10
> - mov 16(%rsp), %r8
> - mov 24(%rsp), %r9
> + mov %rcx, %rdi
> + mov %r8, %rsi
> + mov %r9, %rdx
> + mov 16(%rsp), %r10
> + mov 24(%rsp), %r8
> + mov 32(%rsp), %r9
>
> - /* This next sequence of code works in conjunction with the
> + /*
> + * 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'.
> @@ -67,25 +69,31 @@ safe_syscall_base:
> */
> safe_syscall_start:
> /* if signal_pending is non-zero, don't do the call */
> - cmpl $0, (%rbp)
> - jnz 1f
> + cmpl $0, (%r11)
> + jnz 2f
> syscall
> safe_syscall_end:
> +
> /* code path for having successfully executed the syscall */
> - pop %rbp
> + cmp $-4095, %rax
> + jae 0f
> +
> +9: 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
> - .cfi_def_cfa_offset 8
> - .cfi_restore rbp
> - ret
> - .cfi_endproc
>
> + /* code path setting errno */
> +0: neg %eax /* create positive errno */
> +1: mov %eax, (%rbp) /* store errno */
> + mov $-1, %rax
> + jmp 9b
> +
> + /* code path when we didn't execute the syscall */
> +2: mov $TARGET_ERESTARTSYS, %eax
> + jmp 1b
> +
> + .cfi_endproc
> .size safe_syscall_base, .-safe_syscall_base
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 39802 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 05/17] common-user/host/mips: Add safe-syscall.inc.S
2021-11-17 16:04 ` [PATCH v5 05/17] common-user/host/mips: Add safe-syscall.inc.S Richard Henderson
@ 2021-11-17 16:31 ` Warner Losh
0 siblings, 0 replies; 46+ messages in thread
From: Warner Losh @ 2021-11-17 16:31 UTC (permalink / raw)
To: Richard Henderson; +Cc: QEMU Developers, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 6007 bytes --]
On Wed, Nov 17, 2021 at 9:04 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> common-user/host/mips/hostdep.h | 2 +
> common-user/host/mips/safe-syscall.inc.S | 135 +++++++++++++++++++++++
> 2 files changed, 137 insertions(+)
> create mode 100644 common-user/host/mips/hostdep.h
> create mode 100644 common-user/host/mips/safe-syscall.inc.S
>
Reviewed-by: Warner Losh <imp@bsdimp.com>
> diff --git a/common-user/host/mips/hostdep.h
> b/common-user/host/mips/hostdep.h
> new file mode 100644
> index 0000000000..b18aca1deb
> --- /dev/null
> +++ b/common-user/host/mips/hostdep.h
> @@ -0,0 +1,2 @@
> +/* We have a safe-syscall.inc.S */
> +#define HAVE_SAFE_SYSCALL
> diff --git a/common-user/host/mips/safe-syscall.inc.S
> b/common-user/host/mips/safe-syscall.inc.S
> new file mode 100644
> index 0000000000..1e2f5a079c
> --- /dev/null
> +++ b/common-user/host/mips/safe-syscall.inc.S
> @@ -0,0 +1,135 @@
> +/*
> + * 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
> + *
> + * Written by Richard Henderson <rth@twiddle.net>
> + * Copyright (C) 2021 Linaro, 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 "sys/regdef.h"
> +#include "sys/asm.h"
> +
> + .text
> + .set nomips16
> + .set noreorder
> +
> + .global safe_syscall_start
> + .global safe_syscall_end
> + .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').
> + */
> +
> +#if _MIPS_SIM == _ABIO32
> +/* Do not allocate a stack frame and store into the parameter space. */
> +#define FRAME 0
> +#define ERRNOP 4
> +#else
> +/* Allocate a stack frame and store into the first allocated slot. */
> +#define FRAME 16
> +#define ERRNOP 0
> +#endif
> +
> +NESTED(safe_syscall_base, FRAME, ra)
> + .cfi_startproc
> +#if _MIPS_SIM == _ABIO32
> + /*
> + * The syscall calling convention is nearly the same as C:
> + * we enter with a0 == &signal_pending
> + * a1 == &errno
> + * a2 == syscall number
> + * a3, stack == syscall arguments
> + * and return the result in a0
> + * and the syscall instruction needs
> + * v0 == syscall number
> + * a0 ... a3, stack == syscall arguments
> + * and returns the result in v0
> + * Shuffle everything around appropriately.
> + */
> + move t0, a0 /* signal_pending pointer */
> + sw a1, ERRNOP(sp) /* errno pointer */
> + move v0, a2 /* syscall number */
> + move a0, a3 /* syscall arguments */
> + lw a1, 16(sp)
> + lw a2, 20(sp)
> + lw a3, 24(sp)
> + lw t4, 28(sp)
> + lw t5, 32(sp)
> + lw t6, 40(sp)
> + lw t7, 44(sp)
> + sw t4, 16(sp)
> + sw t5, 20(sp)
> + sw t6, 24(sp)
> + sw t7, 28(sp)
> +#else
> + PTR_ADDIU sp, sp, -FRAME
> + .cfi_adjust_cfa_offset FRAME
> +
> + /*
> + * The syscall calling convention is nearly the same as C:
> + * we enter with a0 == &signal_pending
> + * a1 == &errno
> + * a2 == syscall number
> + * a3 ... a7, stack == syscall arguments
> + * and return the result in a0
> + * and the syscall instruction needs
> + * v0 == syscall number
> + * a0 ... a5 == syscall arguments
> + * and returns the result in v0
> + * Shuffle everything around appropriately.
> + */
> + move t0, a0 /* signal_pending pointer */
> + PTR_S a1, ERRNOP(sp) /* save errno pointer */
> + move v0, a2 /* syscall number */
> + move a0, a3 /* syscall arguments */
> + move a1, a4
> + move a2, a5
> + move a3, a6
> + move a4, a7
> + ld a5, 16(sp)
> +#endif
> +
> + /*
> + * 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 */
> + lw t1, 0(t0)
> + bnez t1, 0f
> + nop
> + syscall
> +safe_syscall_end:
> +
> + /* code path for having successfully executed the syscall */
> + bnez a3, 1f
> + nop
> + jr ra
> + PTR_ADDIU sp, sp, FRAME
> +
> + /* code path when we didn't execute the syscall */
> +0: li v0, TARGET_ERESTARTSYS
> +
> + /* code path setting errno */
> +1: PTR_L t0, ERRNOP(sp)
> + sw v0, 0(t0) /* store errno */
> + li v0, -1
> + jr ra
> + PTR_ADDIU sp, sp, FRAME
> +
> + .cfi_endproc
> +END(safe_syscall_base)
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 7859 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 01/17] linux-user: Add host_signal_set_pc to set pc in mcontext
2021-11-17 16:03 ` [PATCH v5 01/17] linux-user: Add host_signal_set_pc to set pc in mcontext Richard Henderson
2021-11-17 16:23 ` Warner Losh
@ 2021-11-17 16:37 ` Alex Bennée
1 sibling, 0 replies; 46+ messages in thread
From: Alex Bennée @ 2021-11-17 16:37 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel, laurent, imp, Philippe Mathieu-Daudé
Richard Henderson <richard.henderson@linaro.org> writes:
> From: Warner Losh <imp@bsdimp.com>
>
> Add a new function host_signal_set_pc to set the next pc in an
> mcontext. The caller should ensure this is a valid PC for execution.
>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Message-Id: <20211113045603.60391-2-imp@bsdimp.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 02/17] linux-user/signal.c: Create a common rewind_if_in_safe_syscall
2021-11-17 16:03 ` [PATCH v5 02/17] linux-user/signal.c: Create a common rewind_if_in_safe_syscall Richard Henderson
2021-11-17 16:24 ` Warner Losh
@ 2021-11-17 16:37 ` Alex Bennée
1 sibling, 0 replies; 46+ messages in thread
From: Alex Bennée @ 2021-11-17 16:37 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel, laurent, imp, Philippe Mathieu-Daudé
Richard Henderson <richard.henderson@linaro.org> writes:
> From: Warner Losh <imp@bsdimp.com>
>
> All instances of rewind_if_in_safe_syscall are the same, differing only
> in how the instruction point is fetched from the ucontext and the size
> of the registers. Use host_signal_pc and new host_signal_set_pc
> interfaces to fetch the pointer to the PC and adjust if needed. Delete
> all the old copies of rewind_if_in_safe_syscall.
>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Message-Id: <20211113045603.60391-3-imp@bsdimp.com>
> [rth: include safe-syscall.h, simplify ifdefs]
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 03/17] linux-user/safe-syscall.inc.S: Move to common-user
2021-11-17 16:03 ` [PATCH v5 03/17] linux-user/safe-syscall.inc.S: Move to common-user Richard Henderson
2021-11-17 16:25 ` Warner Losh
@ 2021-11-17 16:38 ` Alex Bennée
1 sibling, 0 replies; 46+ messages in thread
From: Alex Bennée @ 2021-11-17 16:38 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel, laurent, imp, Philippe Mathieu-Daudé
Richard Henderson <richard.henderson@linaro.org> writes:
> From: Warner Losh <imp@bsdimp.com>
>
> Move all the safe_syscall.inc.S files to common-user. They are almost
> identical between linux-user and bsd-user to re-use.
>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Message-Id: <20211113045603.60391-4-imp@bsdimp.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 08/17] common-user: Adjust system call return on FreeBSD
2021-11-17 16:04 ` [PATCH v5 08/17] common-user: Adjust system call return on FreeBSD Richard Henderson
@ 2021-11-17 16:44 ` Warner Losh
0 siblings, 0 replies; 46+ messages in thread
From: Warner Losh @ 2021-11-17 16:44 UTC (permalink / raw)
To: Richard Henderson; +Cc: QEMU Developers, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 5512 bytes --]
On Wed, Nov 17, 2021 at 9:04 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> From: Warner Losh <imp@bsdimp.com>
>
> FreeBSD system calls return positive errno. On the 4 hosts for
> which we have support, error is indicated by the C bit set or clear.
>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> [rth: Rebase on new safe_syscall_base api; add #error check.]
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> common-user/host/aarch64/safe-syscall.inc.S | 12 +++++++++++-
> common-user/host/arm/safe-syscall.inc.S | 11 +++++++++++
> common-user/host/i386/safe-syscall.inc.S | 10 ++++++++++
> common-user/host/x86_64/safe-syscall.inc.S | 10 ++++++++++
> 4 files changed, 42 insertions(+), 1 deletion(-)
>
Reviewed by: Warner Losh <imp@bsdimp.com>
> diff --git a/common-user/host/aarch64/safe-syscall.inc.S
> b/common-user/host/aarch64/safe-syscall.inc.S
> index 95c60d8609..d3f065cdef 100644
> --- a/common-user/host/aarch64/safe-syscall.inc.S
> +++ b/common-user/host/aarch64/safe-syscall.inc.S
> @@ -65,12 +65,22 @@ safe_syscall_start:
> safe_syscall_end:
>
> /* code path for having successfully executed the syscall */
> - cmn x0, #4095
> +#if defined(__linux__)
> + /* Linux kernel returns (small) negative errno. */
> + cmn 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
>
> /* code path setting errno */
> +#ifdef __linux__
> 0: neg w0, w0 /* create positive errno */
> +#endif
> 1: str w0, [x11] /* store errno */
> mov x0, #-1
> ret
> diff --git a/common-user/host/arm/safe-syscall.inc.S
> b/common-user/host/arm/safe-syscall.inc.S
> index 17839c6486..328299021d 100644
> --- a/common-user/host/arm/safe-syscall.inc.S
> +++ b/common-user/host/arm/safe-syscall.inc.S
> @@ -82,12 +82,23 @@ safe_syscall_start:
> safe_syscall_end:
>
> /* code path for having successfully executed the syscall */
> +#if defined(__linux__)
> + /* Linux kernel returns (small) negative errno. */
> cmp r0, #-4096
> bhi 0f
> +#elif defined(__FreeBSD__)
> + /* FreeBSD kernel returns positive errno and C bit set. */
> + bcs 1f
>
I believe this is OK. On FreeBSD, this will get the proper location for
errno and store
it there based on the current thread's local storage. Since the rest of the
code
extracts the errno directly, and we use that correctly w/o relying on errno
to
evaluate to the error associated with the last system call in this thread
in bsd-user,
I believe this adjustment is fine (also, a prior version seems to work,
this version
isn't yet in the github mirror, so I've not tried it).
This comment applies to all FreeBSD archs, except aarch64 which does a
similar thing,
but in a different way.
Warner
+#else
> +#error "unsupported os"
> +#endif
> +
> 9: pop { r4, r5, r6, r7, r8, r9, r10, pc }
>
> /* code path setting errno */
> +#ifdef __linux__
> 0: neg r0, r0 /* create positive errno */
> +#endif
> 1: str r0, [r9] /* store errno */
> mov r0, #-1
> b 9b
> diff --git a/common-user/host/i386/safe-syscall.inc.S
> b/common-user/host/i386/safe-syscall.inc.S
> index ad89521783..c27207492a 100644
> --- a/common-user/host/i386/safe-syscall.inc.S
> +++ b/common-user/host/i386/safe-syscall.inc.S
> @@ -76,8 +76,16 @@ safe_syscall_start:
> 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
>
> 9: pop %ebx
> .cfi_remember_state
> @@ -97,7 +105,9 @@ safe_syscall_end:
> .cfi_restore_state
>
> /* code path setting errno */
> +#ifdef __linux__
> 0: neg %eax /* create positive errno */
> +#endif
> 1: mov 8+16(%esp), %ebx /* load errno pointer */
> mov %eax, (%ebx) /* store errno */
> mov $-1, %eax
> diff --git a/common-user/host/x86_64/safe-syscall.inc.S
> b/common-user/host/x86_64/safe-syscall.inc.S
> index 9a0c4c93b4..e3f920fa5c 100644
> --- a/common-user/host/x86_64/safe-syscall.inc.S
> +++ b/common-user/host/x86_64/safe-syscall.inc.S
> @@ -75,8 +75,16 @@ safe_syscall_start:
> 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
>
> 9: pop %rbp
> .cfi_remember_state
> @@ -86,7 +94,9 @@ safe_syscall_end:
> .cfi_restore_state
>
> /* code path setting errno */
> +#ifdef __linux__
> 0: neg %eax /* create positive errno */
> +#endif
> 1: mov %eax, (%rbp) /* store errno */
> mov $-1, %rax
> jmp 9b
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 7348 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 09/17] *-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS
2021-11-17 16:04 ` [PATCH v5 09/17] *-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS Richard Henderson
@ 2021-11-17 16:46 ` Warner Losh
2021-11-17 16:51 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 46+ messages in thread
From: Warner Losh @ 2021-11-17 16:46 UTC (permalink / raw)
To: Richard Henderson; +Cc: QEMU Developers, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 25861 bytes --]
On Wed, Nov 17, 2021 at 9:04 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> 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.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> bsd-user/errno_defs.h | 2 +-
> 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 +-
> common-user/host/aarch64/safe-syscall.inc.S | 2 +-
> common-user/host/arm/safe-syscall.inc.S | 2 +-
> common-user/host/i386/safe-syscall.inc.S | 2 +-
> common-user/host/mips/safe-syscall.inc.S | 2 +-
> common-user/host/ppc64/safe-syscall.inc.S | 2 +-
> common-user/host/riscv/safe-syscall.inc.S | 2 +-
> common-user/host/s390x/safe-syscall.inc.S | 2 +-
> common-user/host/sparc64/safe-syscall.inc.S | 2 +-
> common-user/host/x86_64/safe-syscall.inc.S | 2 +-
> 32 files changed, 46 insertions(+), 46 deletions(-)
>
Reviewed-by: Warner Losh <imp@bsdimp.com>
> diff --git a/bsd-user/errno_defs.h b/bsd-user/errno_defs.h
> index 832671354f..583ebe8cee 100644
> --- a/bsd-user/errno_defs.h
> +++ b/bsd-user/errno_defs.h
> @@ -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 /* compat */
>
> #endif /* ! _ERRNO_DEFS_H_ */
> diff --git a/linux-user/generic/target_errno_defs.h
> b/linux-user/generic/target_errno_defs.h
> index 17d85e0b61..58a06a10d6 100644
> --- a/linux-user/generic/target_errno_defs.h
> +++ b/linux-user/generic/target_errno_defs.h
> @@ -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
> diff --git a/linux-user/safe-syscall.h b/linux-user/safe-syscall.h
> index 0deb87e51a..70c2dec408 100644
> --- a/linux-user/safe-syscall.h
> +++ b/linux-user/safe-syscall.h
> @@ -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
> diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h
> index 7457f8025c..b9f33bb44f 100644
> --- a/linux-user/signal-common.h
> +++ b/linux-user/signal-common.h
> @@ -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
> diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c
> index 97e0728b67..775ba43913 100644
> --- a/linux-user/aarch64/cpu_loop.c
> +++ b/linux-user/aarch64/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/alpha/cpu_loop.c b/linux-user/alpha/cpu_loop.c
> index 4029849d5c..ce9b251ce3 100644
> --- a/linux-user/alpha/cpu_loop.c
> +++ b/linux-user/alpha/cpu_loop.c
> @@ -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;
> }
> diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c
> index 01cb6eb534..1fcf19750e 100644
> --- a/linux-user/arm/cpu_loop.c
> +++ b/linux-user/arm/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/cris/cpu_loop.c b/linux-user/cris/cpu_loop.c
> index 0d5d268609..f3e5b13f89 100644
> --- a/linux-user/cris/cpu_loop.c
> +++ b/linux-user/cris/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/hexagon/cpu_loop.c b/linux-user/hexagon/cpu_loop.c
> index 6b24cbaba9..1cacbf42f1 100644
> --- a/linux-user/hexagon/cpu_loop.c
> +++ b/linux-user/hexagon/cpu_loop.c
> @@ -54,7 +54,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;
> diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c
> index 375576c8f0..5315224d12 100644
> --- a/linux-user/hppa/cpu_loop.c
> +++ b/linux-user/hppa/cpu_loop.c
> @@ -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;
> }
> diff --git a/linux-user/i386/cpu_loop.c b/linux-user/i386/cpu_loop.c
> index f6a1cc632b..fbd9a353e5 100644
> --- a/linux-user/i386/cpu_loop.c
> +++ b/linux-user/i386/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/m68k/cpu_loop.c b/linux-user/m68k/cpu_loop.c
> index 790bd558c3..b03c21a3dc 100644
> --- a/linux-user/m68k/cpu_loop.c
> +++ b/linux-user/m68k/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/microblaze/cpu_loop.c
> b/linux-user/microblaze/cpu_loop.c
> index a94467dd2d..6e368f986e 100644
> --- a/linux-user/microblaze/cpu_loop.c
> +++ b/linux-user/microblaze/cpu_loop.c
> @@ -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) {
> diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c
> index b735c99a24..64f308c6ad 100644
> --- a/linux-user/mips/cpu_loop.c
> +++ b/linux-user/mips/cpu_loop.c
> @@ -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;
> }
> diff --git a/linux-user/openrisc/cpu_loop.c
> b/linux-user/openrisc/cpu_loop.c
> index 3cfdbbf037..3147ab2b62 100644
> --- a/linux-user/openrisc/cpu_loop.c
> +++ b/linux-user/openrisc/cpu_loop.c
> @@ -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);
> diff --git a/linux-user/ppc/cpu_loop.c b/linux-user/ppc/cpu_loop.c
> index 483e669300..5348641e9e 100644
> --- a/linux-user/ppc/cpu_loop.c
> +++ b/linux-user/ppc/cpu_loop.c
> @@ -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;
> }
> diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c
> index b301dac802..20f8c48b1d 100644
> --- a/linux-user/riscv/cpu_loop.c
> +++ b/linux-user/riscv/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/s390x/cpu_loop.c b/linux-user/s390x/cpu_loop.c
> index d089c8417e..043582ca7c 100644
> --- a/linux-user/s390x/cpu_loop.c
> +++ b/linux-user/s390x/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/sh4/cpu_loop.c b/linux-user/sh4/cpu_loop.c
> index ac9b01840c..6c4ebfa969 100644
> --- a/linux-user/sh4/cpu_loop.c
> +++ b/linux-user/sh4/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/signal.c b/linux-user/signal.c
> index ca8f24b9ec..12b1705287 100644
> --- a/linux-user/signal.c
> +++ b/linux-user/signal.c
> @@ -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];
> diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c
> index 0ba65e431c..529337c5e0 100644
> --- a/linux-user/sparc/cpu_loop.c
> +++ b/linux-user/sparc/cpu_loop.c
> @@ -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)) {
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 544f5b662f..3c0e341e45 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -545,7 +545,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) {
> @@ -6456,7 +6456,7 @@ static int do_fork(CPUArchState *env, unsigned int
> flags, abi_ulong newsp,
> }
>
> if (block_signals()) {
> - return -TARGET_ERESTARTSYS;
> + return -QEMU_ERESTARTSYS;
> }
>
> fork_start();
> @@ -8173,7 +8173,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);
> @@ -9162,7 +9162,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;
> }
> }
> @@ -9181,7 +9181,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;
> }
> }
> @@ -9297,13 +9297,13 @@ static abi_long do_syscall1(void *cpu_env, int
> num, abi_long arg1,
> #ifdef TARGET_NR_sigreturn
> case 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:
> @@ -13141,7 +13141,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
> diff --git a/linux-user/xtensa/cpu_loop.c b/linux-user/xtensa/cpu_loop.c
> index a83490ab35..29cc6f3830 100644
> --- a/linux-user/xtensa/cpu_loop.c
> +++ b/linux-user/xtensa/cpu_loop.c
> @@ -184,7 +184,7 @@ void cpu_loop(CPUXtensaState *env)
> env->regs[2] = ret;
> break;
>
> - case -TARGET_ERESTARTSYS:
> + case -QEMU_ERESTARTSYS:
> env->pc -= 3;
> break;
>
> diff --git a/common-user/host/aarch64/safe-syscall.inc.S
> b/common-user/host/aarch64/safe-syscall.inc.S
> index d3f065cdef..6b405be448 100644
> --- a/common-user/host/aarch64/safe-syscall.inc.S
> +++ b/common-user/host/aarch64/safe-syscall.inc.S
> @@ -86,7 +86,7 @@ safe_syscall_end:
> ret
>
> /* code path when we didn't execute the syscall */
> -2: mov w0, #TARGET_ERESTARTSYS
> +2: mov w0, #QEMU_ERESTARTSYS
> b 1b
>
> .cfi_endproc
> diff --git a/common-user/host/arm/safe-syscall.inc.S
> b/common-user/host/arm/safe-syscall.inc.S
> index 328299021d..e9b8d49d7c 100644
> --- a/common-user/host/arm/safe-syscall.inc.S
> +++ b/common-user/host/arm/safe-syscall.inc.S
> @@ -104,7 +104,7 @@ safe_syscall_end:
> b 9b
>
> /* code path when we didn't execute the syscall */
> -2: ldr r0, =TARGET_ERESTARTSYS
> +2: ldr r0, =QEMU_ERESTARTSYS
> b 1b
>
> .fnend
> diff --git a/common-user/host/i386/safe-syscall.inc.S
> b/common-user/host/i386/safe-syscall.inc.S
> index c27207492a..3f928764db 100644
> --- a/common-user/host/i386/safe-syscall.inc.S
> +++ b/common-user/host/i386/safe-syscall.inc.S
> @@ -114,7 +114,7 @@ safe_syscall_end:
> jmp 9b
>
> /* code path when we didn't execute the syscall */
> -2: mov $TARGET_ERESTARTSYS, %eax
> +2: mov $QEMU_ERESTARTSYS, %eax
> jmp 1b
> .cfi_endproc
>
> diff --git a/common-user/host/mips/safe-syscall.inc.S
> b/common-user/host/mips/safe-syscall.inc.S
> index 1e2f5a079c..90bf3cc03e 100644
> --- a/common-user/host/mips/safe-syscall.inc.S
> +++ b/common-user/host/mips/safe-syscall.inc.S
> @@ -122,7 +122,7 @@ safe_syscall_end:
> PTR_ADDIU sp, sp, FRAME
>
> /* code path when we didn't execute the syscall */
> -0: li v0, TARGET_ERESTARTSYS
> +0: li v0, QEMU_ERESTARTSYS
>
> /* code path setting errno */
> 1: PTR_L t0, ERRNOP(sp)
> diff --git a/common-user/host/ppc64/safe-syscall.inc.S
> b/common-user/host/ppc64/safe-syscall.inc.S
> index e35408c5fb..11c4672f71 100644
> --- a/common-user/host/ppc64/safe-syscall.inc.S
> +++ b/common-user/host/ppc64/safe-syscall.inc.S
> @@ -92,7 +92,7 @@ safe_syscall_end:
> blr
>
> /* code path when we didn't execute the syscall */
> -0: li 3, TARGET_ERESTARTSYS
> +0: li 3, QEMU_ERESTARTSYS
> b 1b
>
> .cfi_endproc
> diff --git a/common-user/host/riscv/safe-syscall.inc.S
> b/common-user/host/riscv/safe-syscall.inc.S
> index eddede702b..2f07c729c4 100644
> --- a/common-user/host/riscv/safe-syscall.inc.S
> +++ b/common-user/host/riscv/safe-syscall.inc.S
> @@ -81,7 +81,7 @@ safe_syscall_end:
> ret
>
> /* code path when we didn't execute the syscall */
> -2: li a0, TARGET_ERESTARTSYS
> +2: li a0, QEMU_ERESTARTSYS
> j 1b
>
> .cfi_endproc
> diff --git a/common-user/host/s390x/safe-syscall.inc.S
> b/common-user/host/s390x/safe-syscall.inc.S
> index f2a3bccc13..c1cc127e85 100644
> --- a/common-user/host/s390x/safe-syscall.inc.S
> +++ b/common-user/host/s390x/safe-syscall.inc.S
> @@ -91,7 +91,7 @@ safe_syscall_end:
> .cfi_restore_state
>
> /* code path when we didn't execute the syscall */
> -1: lghi %r2, -TARGET_ERESTARTSYS
> +1: lghi %r2, -QEMU_ERESTARTSYS
>
> /* code path setting errno */
> 0: lcr %r2, %r2 /* create positive errno */
> diff --git a/common-user/host/sparc64/safe-syscall.inc.S
> b/common-user/host/sparc64/safe-syscall.inc.S
> index 2492fcbd9e..55e32b30eb 100644
> --- a/common-user/host/sparc64/safe-syscall.inc.S
> +++ b/common-user/host/sparc64/safe-syscall.inc.S
> @@ -85,7 +85,7 @@ safe_syscall_end:
>
> /* code path when we didn't execute the syscall */
> 2: ba,pt %xcc, 1b
> - set TARGET_ERESTARTSYS, %o0
> + set QEMU_ERESTARTSYS, %o0
>
> .cfi_endproc
> .size safe_syscall_base, .-safe_syscall_base
> diff --git a/common-user/host/x86_64/safe-syscall.inc.S
> b/common-user/host/x86_64/safe-syscall.inc.S
> index e3f920fa5c..b93d684e66 100644
> --- a/common-user/host/x86_64/safe-syscall.inc.S
> +++ b/common-user/host/x86_64/safe-syscall.inc.S
> @@ -102,7 +102,7 @@ safe_syscall_end:
> jmp 9b
>
> /* code path when we didn't execute the syscall */
> -2: mov $TARGET_ERESTARTSYS, %eax
> +2: mov $QEMU_ERESTARTSYS, %eax
> jmp 1b
>
> .cfi_endproc
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 31057 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 09/17] *-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS
2021-11-17 16:04 ` [PATCH v5 09/17] *-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS Richard Henderson
2021-11-17 16:46 ` Warner Losh
@ 2021-11-17 16:51 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 46+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-17 16:51 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: laurent, imp
On 11/17/21 17:04, Richard Henderson wrote:
> 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.
Thanks for this cleanup, I often wondered what was it really.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> bsd-user/errno_defs.h | 2 +-
> 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 +-
> common-user/host/aarch64/safe-syscall.inc.S | 2 +-
> common-user/host/arm/safe-syscall.inc.S | 2 +-
> common-user/host/i386/safe-syscall.inc.S | 2 +-
> common-user/host/mips/safe-syscall.inc.S | 2 +-
> common-user/host/ppc64/safe-syscall.inc.S | 2 +-
> common-user/host/riscv/safe-syscall.inc.S | 2 +-
> common-user/host/s390x/safe-syscall.inc.S | 2 +-
> common-user/host/sparc64/safe-syscall.inc.S | 2 +-
> common-user/host/x86_64/safe-syscall.inc.S | 2 +-
> 32 files changed, 46 insertions(+), 46 deletions(-)
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 15/17] linux-user: Move thunk.c from top-level
2021-11-17 16:04 ` [PATCH v5 15/17] linux-user: Move thunk.c from top-level Richard Henderson
@ 2021-11-17 16:52 ` Philippe Mathieu-Daudé
2021-11-17 17:27 ` Warner Losh
1 sibling, 0 replies; 46+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-17 16:52 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: laurent, imp
On 11/17/21 17:04, Richard Henderson wrote:
> So far, linux-user is the only user of these functions.
> Clean up the build machinery by restricting it to linux-user.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> meson.build | 1 -
> thunk.c => linux-user/thunk.c | 0
> linux-user/meson.build | 1 +
> 3 files changed, 1 insertion(+), 1 deletion(-)
> rename thunk.c => linux-user/thunk.c (100%)
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 16/17] meson: Move linux_user_ss to linux-user/
2021-11-17 16:04 ` [PATCH v5 16/17] meson: Move linux_user_ss to linux-user/ Richard Henderson
@ 2021-11-17 16:56 ` Philippe Mathieu-Daudé
2021-11-17 17:04 ` Richard Henderson
2021-11-17 17:31 ` Warner Losh
1 sibling, 1 reply; 46+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-17 16:56 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: Paolo Bonzini, Thomas Huth, laurent, imp
+Thomas/Paolo
On 11/17/21 17:04, Richard Henderson wrote:
> We have no need to reference linux_user_ss outside of linux-user.
> Go ahead and merge it directly into specific_ss.
The patch is correct, so:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
But ...
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> meson.build | 3 ---
> linux-user/meson.build | 4 ++++
> 2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index 9f59c57909..ecc181ea13 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2363,7 +2363,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()
> @@ -2614,8 +2613,6 @@
... shouldn't it be cheaper for the build system to
avoid parsing linux-user machinery when we linux-user
is disabled, ...
+ if have_linux_user
subdir('linux-user')
+ endif
>
> 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(),
> diff --git a/linux-user/meson.build b/linux-user/meson.build
> index fcf7d40f23..b89534c49c 100644
> --- a/linux-user/meson.build
> +++ b/linux-user/meson.build
> @@ -2,6 +2,8 @@ if not have_linux_user
> subdir_done()
> endif
>
> +linux_user_ss = ss.source_set()
> +
> common_user_inc += include_directories('host/' / config_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)
... and add here unconditionally?
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 17/17] meson: Move bsd_user_ss to bsd-user/
2021-11-17 16:04 ` [PATCH v5 17/17] meson: Move bsd_user_ss to bsd-user/ Richard Henderson
@ 2021-11-17 16:56 ` Philippe Mathieu-Daudé
2021-11-17 17:29 ` Warner Losh
1 sibling, 0 replies; 46+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-17 16:56 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: laurent, imp
On 11/17/21 17:04, Richard Henderson wrote:
> We have no need to reference bsd_user_ss outside of bsd-user.
> Go ahead and merge it directly into specific_ss.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> meson.build | 3 ---
> bsd-user/meson.build | 4 ++++
> 2 files changed, 4 insertions(+), 3 deletions(-)
Similar comment than linux-user previous patch (avoid wasting
buildsys resources), otherwise:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 10/17] linux-user: Rename TARGET_QEMU_ESIGRETURN to QEMU_ESIGRETURN
2021-11-17 16:04 ` [PATCH v5 10/17] linux-user: Rename TARGET_QEMU_ESIGRETURN to QEMU_ESIGRETURN Richard Henderson
@ 2021-11-17 17:01 ` Warner Losh
0 siblings, 0 replies; 46+ messages in thread
From: Warner Losh @ 2021-11-17 17:01 UTC (permalink / raw)
To: Richard Henderson; +Cc: QEMU Developers, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 27799 bytes --]
On Wed, Nov 17, 2021 at 9:04 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> This value is fully internal to qemu, and so is not a TARGET define.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> 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(-)
>
Reviewed-by: Warner Losh <imp@bsdimp.com>
> diff --git a/linux-user/generic/target_errno_defs.h
> b/linux-user/generic/target_errno_defs.h
> index 58a06a10d6..bb37d88be9 100644
> --- a/linux-user/generic/target_errno_defs.h
> +++ b/linux-user/generic/target_errno_defs.h
> @@ -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
> diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c
> index 775ba43913..98b53962cd 100644
> --- a/linux-user/aarch64/cpu_loop.c
> +++ b/linux-user/aarch64/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
> index 29c52db3f1..df9e39a4ba 100644
> --- a/linux-user/aarch64/signal.c
> +++ b/linux-user/aarch64/signal.c
> @@ -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)
> diff --git a/linux-user/alpha/cpu_loop.c b/linux-user/alpha/cpu_loop.c
> index ce9b251ce3..37c33f0ccd 100644
> --- a/linux-user/alpha/cpu_loop.c
> +++ b/linux-user/alpha/cpu_loop.c
> @@ -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
> diff --git a/linux-user/alpha/signal.c b/linux-user/alpha/signal.c
> index bbe3dd175a..4ec42994d4 100644
> --- a/linux-user/alpha/signal.c
> +++ b/linux-user/alpha/signal.c
> @@ -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)
> diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c
> index 1fcf19750e..f153ab503a 100644
> --- a/linux-user/arm/cpu_loop.c
> +++ b/linux-user/arm/cpu_loop.c
> @@ -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;
> }
> }
> diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c
> index df9f8e8eb2..cf99fd7b8a 100644
> --- a/linux-user/arm/signal.c
> +++ b/linux-user/arm/signal.c
> @@ -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;
> }
>
> /*
> diff --git a/linux-user/cris/cpu_loop.c b/linux-user/cris/cpu_loop.c
> index f3e5b13f89..5213aebf55 100644
> --- a/linux-user/cris/cpu_loop.c
> +++ b/linux-user/cris/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/cris/signal.c b/linux-user/cris/signal.c
> index 7f6aca934e..4f532b2903 100644
> --- a/linux-user/cris/signal.c
> +++ b/linux-user/cris/signal.c
> @@ -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)
> diff --git a/linux-user/hexagon/cpu_loop.c b/linux-user/hexagon/cpu_loop.c
> index 1cacbf42f1..b84e25bf71 100644
> --- a/linux-user/hexagon/cpu_loop.c
> +++ b/linux-user/hexagon/cpu_loop.c
> @@ -56,7 +56,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;
> diff --git a/linux-user/hexagon/signal.c b/linux-user/hexagon/signal.c
> index 74e61739a0..ad4e3822d5 100644
> --- a/linux-user/hexagon/signal.c
> +++ b/linux-user/hexagon/signal.c
> @@ -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);
> diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c
> index 5315224d12..a47a63176b 100644
> --- a/linux-user/hppa/cpu_loop.c
> +++ b/linux-user/hppa/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/hppa/signal.c b/linux-user/hppa/signal.c
> index c2fbc26ebb..962f551c04 100644
> --- a/linux-user/hppa/signal.c
> +++ b/linux-user/hppa/signal.c
> @@ -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;
> }
> diff --git a/linux-user/i386/cpu_loop.c b/linux-user/i386/cpu_loop.c
> index fbd9a353e5..9aaae93e2f 100644
> --- a/linux-user/i386/cpu_loop.c
> +++ b/linux-user/i386/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c
> index 433efa3d69..4372621a4d 100644
> --- a/linux-user/i386/signal.c
> +++ b/linux-user/i386/signal.c
> @@ -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
> diff --git a/linux-user/m68k/cpu_loop.c b/linux-user/m68k/cpu_loop.c
> index b03c21a3dc..3181594414 100644
> --- a/linux-user/m68k/cpu_loop.c
> +++ b/linux-user/m68k/cpu_loop.c
> @@ -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;
> }
> }
> diff --git a/linux-user/m68k/signal.c b/linux-user/m68k/signal.c
> index ec33482e14..5f35354487 100644
> --- a/linux-user/m68k/signal.c
> +++ b/linux-user/m68k/signal.c
> @@ -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)
> diff --git a/linux-user/microblaze/cpu_loop.c
> b/linux-user/microblaze/cpu_loop.c
> index 6e368f986e..ff1fb26c8b 100644
> --- a/linux-user/microblaze/cpu_loop.c
> +++ b/linux-user/microblaze/cpu_loop.c
> @@ -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
> diff --git a/linux-user/microblaze/signal.c
> b/linux-user/microblaze/signal.c
> index 8ebb6a1b7d..5188d74025 100644
> --- a/linux-user/microblaze/signal.c
> +++ b/linux-user/microblaze/signal.c
> @@ -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)
> diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c
> index 64f308c6ad..32f9fc1c1c 100644
> --- a/linux-user/mips/cpu_loop.c
> +++ b/linux-user/mips/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/mips/signal.c b/linux-user/mips/signal.c
> index 8f79e405ec..58a9d7a8a3 100644
> --- a/linux-user/mips/signal.c
> +++ b/linux-user/mips/signal.c
> @@ -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)
> diff --git a/linux-user/openrisc/cpu_loop.c
> b/linux-user/openrisc/cpu_loop.c
> index 3147ab2b62..592901a68b 100644
> --- a/linux-user/openrisc/cpu_loop.c
> +++ b/linux-user/openrisc/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/ppc/cpu_loop.c b/linux-user/ppc/cpu_loop.c
> index 5348641e9e..30c82f2354 100644
> --- a/linux-user/ppc/cpu_loop.c
> +++ b/linux-user/ppc/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c
> index 90a0369632..176c9d8503 100644
> --- a/linux-user/ppc/signal.c
> +++ b/linux-user/ppc/signal.c
> @@ -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;
> diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c
> index 20f8c48b1d..0cd8985cb8 100644
> --- a/linux-user/riscv/cpu_loop.c
> +++ b/linux-user/riscv/cpu_loop.c
> @@ -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) {
> diff --git a/linux-user/riscv/signal.c b/linux-user/riscv/signal.c
> index a0f9542ce3..296e39fbf0 100644
> --- a/linux-user/riscv/signal.c
> +++ b/linux-user/riscv/signal.c
> @@ -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);
> diff --git a/linux-user/s390x/cpu_loop.c b/linux-user/s390x/cpu_loop.c
> index 043582ca7c..ad0c3cd263 100644
> --- a/linux-user/s390x/cpu_loop.c
> +++ b/linux-user/s390x/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c
> index 676b948147..f47713e04a 100644
> --- a/linux-user/s390x/signal.c
> +++ b/linux-user/s390x/signal.c
> @@ -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)
> diff --git a/linux-user/sh4/cpu_loop.c b/linux-user/sh4/cpu_loop.c
> index 6c4ebfa969..3290f6445c 100644
> --- a/linux-user/sh4/cpu_loop.c
> +++ b/linux-user/sh4/cpu_loop.c
> @@ -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;
> diff --git a/linux-user/sh4/signal.c b/linux-user/sh4/signal.c
> index faa869fb19..f6a18bc6b5 100644
> --- a/linux-user/sh4/signal.c
> +++ b/linux-user/sh4/signal.c
> @@ -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)
> diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c
> index 529337c5e0..8765ab6020 100644
> --- a/linux-user/sparc/cpu_loop.c
> +++ b/linux-user/sparc/cpu_loop.c
> @@ -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)) {
> diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c
> index 23e1e761de..b501750fe0 100644
> --- a/linux-user/sparc/signal.c
> +++ b/linux-user/sparc/signal.c
> @@ -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)
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 3c0e341e45..1ef6abb776 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -548,7 +548,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";
> }
>
> diff --git a/linux-user/xtensa/cpu_loop.c b/linux-user/xtensa/cpu_loop.c
> index 29cc6f3830..6bc6d6dee6 100644
> --- a/linux-user/xtensa/cpu_loop.c
> +++ b/linux-user/xtensa/cpu_loop.c
> @@ -188,7 +188,7 @@ void cpu_loop(CPUXtensaState *env)
> env->pc -= 3;
> break;
>
> - case -TARGET_QEMU_ESIGRETURN:
> + case -QEMU_ESIGRETURN:
> break;
> }
> break;
> diff --git a/linux-user/xtensa/signal.c b/linux-user/xtensa/signal.c
> index 81572a5fc7..06d91a37ec 100644
> --- a/linux-user/xtensa/signal.c
> +++ b/linux-user/xtensa/signal.c
> @@ -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)
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 33221 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 16/17] meson: Move linux_user_ss to linux-user/
2021-11-17 16:56 ` Philippe Mathieu-Daudé
@ 2021-11-17 17:04 ` Richard Henderson
2021-11-17 17:11 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 46+ messages in thread
From: Richard Henderson @ 2021-11-17 17:04 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Paolo Bonzini, Thomas Huth, laurent, imp
On 11/17/21 5:56 PM, Philippe Mathieu-Daudé wrote:
> +Thomas/Paolo
>
> On 11/17/21 17:04, Richard Henderson wrote:
>> We have no need to reference linux_user_ss outside of linux-user.
>> Go ahead and merge it directly into specific_ss.
>
> The patch is correct, so:
>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> But ...
>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>> meson.build | 3 ---
>> linux-user/meson.build | 4 ++++
>> 2 files changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/meson.build b/meson.build
>> index 9f59c57909..ecc181ea13 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -2363,7 +2363,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()
>> @@ -2614,8 +2613,6 @@
>
> ... shouldn't it be cheaper for the build system to
> avoid parsing linux-user machinery when we linux-user
> is disabled, ...
>
> + if have_linux_user
>
> subdir('linux-user')
>
> + endif
We had this discussion before, and settled on
if not have_linux_user
subdir_done()
endif
within linux-user/meson.build.
>> +specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss)
>
> ... and add here unconditionally?
Can't do it unconditionally. We still need to distinguish specific_ss files that are
CONFIG_USER_ONLY, when building both user-only and sysemu binaries.
I thought about changing this to CONFIG_USER_ONLY, but thought that would just be a step
too far for this patch.
r~
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 16/17] meson: Move linux_user_ss to linux-user/
2021-11-17 17:04 ` Richard Henderson
@ 2021-11-17 17:11 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 46+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-17 17:11 UTC (permalink / raw)
To: Richard Henderson
Cc: Paolo Bonzini, Thomas Huth, qemu-devel@nongnu.org Developers,
Warner Losh, Laurent Vivier
On Wed, Nov 17, 2021 at 6:04 PM Richard Henderson
<richard.henderson@linaro.org> wrote:
> On 11/17/21 5:56 PM, Philippe Mathieu-Daudé wrote:
> > +Thomas/Paolo
> >
> > On 11/17/21 17:04, Richard Henderson wrote:
> >> We have no need to reference linux_user_ss outside of linux-user.
> >> Go ahead and merge it directly into specific_ss.
> >
> > The patch is correct, so:
> >
> > Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> >
> > But ...
> >
> >> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> >> ---
> >> meson.build | 3 ---
> >> linux-user/meson.build | 4 ++++
> >> 2 files changed, 4 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/meson.build b/meson.build
> >> index 9f59c57909..ecc181ea13 100644
> >> --- a/meson.build
> >> +++ b/meson.build
> >> @@ -2363,7 +2363,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()
> >> @@ -2614,8 +2613,6 @@
> >
> > ... shouldn't it be cheaper for the build system to
> > avoid parsing linux-user machinery when we linux-user
> > is disabled, ...
> >
> > + if have_linux_user
> >
> > subdir('linux-user')
> >
> > + endif
>
> We had this discussion before, and settled on
>
> if not have_linux_user
> subdir_done()
> endif
>
> within linux-user/meson.build.
Indeed sorry. Too much context switching.
> >> +specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss)
> >
> > ... and add here unconditionally?
>
> Can't do it unconditionally. We still need to distinguish specific_ss files that are
> CONFIG_USER_ONLY, when building both user-only and sysemu binaries.
Indeed.
> I thought about changing this to CONFIG_USER_ONLY, but thought that would just be a step
> too far for this patch.
>
>
> r~
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 11/17] bsd-user: Create special-errno.h
2021-11-17 16:04 ` [PATCH v5 11/17] bsd-user: Create special-errno.h Richard Henderson
@ 2021-11-17 17:21 ` Warner Losh
0 siblings, 0 replies; 46+ messages in thread
From: Warner Losh @ 2021-11-17 17:21 UTC (permalink / raw)
To: Richard Henderson; +Cc: QEMU Developers, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 2052 bytes --]
On Wed, Nov 17, 2021 at 9:04 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> Pull the internal errno used by qemu internally its own
> header file, for use by safe-syscall.S.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> 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
>
Reviewed by: Warner Losh <imp@bsdimp.com>
> diff --git a/bsd-user/errno_defs.h b/bsd-user/errno_defs.h
> index 583ebe8cee..73cfa24b7f 100644
> --- a/bsd-user/errno_defs.h
> +++ b/bsd-user/errno_defs.h
> @@ -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 /* compat */
> +
> +#include "special-errno.h"
> +
> +_Static_assert(TARGET_ERESTART == QEMU_ERESTARTSYS,
> + "TARGET_ERESTART and QEMU_ERESTARTSYS expected to match");
>
> #endif /* ! _ERRNO_DEFS_H_ */
> diff --git a/bsd-user/special-errno.h b/bsd-user/special-errno.h
> new file mode 100644
> index 0000000000..03599d9b5a
> --- /dev/null
> +++ b/bsd-user/special-errno.h
> @@ -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 */
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 2903 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 12/17] linux-user: Create special-errno.h
2021-11-17 16:04 ` [PATCH v5 12/17] linux-user: " Richard Henderson
@ 2021-11-17 17:21 ` Warner Losh
0 siblings, 0 replies; 46+ messages in thread
From: Warner Losh @ 2021-11-17 17:21 UTC (permalink / raw)
To: Richard Henderson; +Cc: QEMU Developers, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 5029 bytes --]
On Wed, Nov 17, 2021 at 9:04 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> Pull the two internal errno used by qemu internally into their own
> header file. This includes the one define required by safe-syscall.S.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> 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
>
Reviewed-by: Warner Losh <imp@bsdimp.com>
> diff --git a/linux-user/cpu_loop-common.h b/linux-user/cpu_loop-common.h
> index 8828af28a4..dc0042e4de 100644
> --- a/linux-user/cpu_loop-common.h
> +++ b/linux-user/cpu_loop-common.h
> @@ -21,6 +21,7 @@
> #define CPU_LOOP_COMMON_H
>
> #include "exec/log.h"
> +#include "special-errno.h"
>
> #define EXCP_DUMP(env, fmt, ...) \
> do { \
> diff --git a/linux-user/generic/target_errno_defs.h
> b/linux-user/generic/target_errno_defs.h
> index bb37d88be9..c2f9d403e7 100644
> --- a/linux-user/generic/target_errno_defs.h
> +++ b/linux-user/generic/target_errno_defs.h
> @@ -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
> diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h
> index b9f33bb44f..42aa479080 100644
> --- a/linux-user/signal-common.h
> +++ b/linux-user/signal-common.h
> @@ -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;
> diff --git a/linux-user/special-errno.h b/linux-user/special-errno.h
> new file mode 100644
> index 0000000000..4120455baa
> --- /dev/null
> +++ b/linux-user/special-errno.h
> @@ -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 */
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 1ef6abb776..33d342157d 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -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"
> diff --git a/linux-user/safe-syscall.S b/linux-user/safe-syscall.S
> index 7ddc997801..74f7e35694 100644
> --- a/linux-user/safe-syscall.S
> +++ b/linux-user/safe-syscall.S
> @@ -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.
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 6296 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 13/17] meson: Add build infrastructure for common-user
2021-11-17 16:04 ` [PATCH v5 13/17] meson: Add build infrastructure for common-user Richard Henderson
@ 2021-11-17 17:22 ` Warner Losh
0 siblings, 0 replies; 46+ messages in thread
From: Warner Losh @ 2021-11-17 17:22 UTC (permalink / raw)
To: Richard Henderson; +Cc: QEMU Developers, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 2925 bytes --]
On Wed, Nov 17, 2021 at 9:04 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> The first objects to be added will be target-independent,
> and so built once for the host.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> meson.build | 16 +++++++++++++++-
> bsd-user/meson.build | 2 ++
> common-user/meson.build | 1 +
> linux-user/meson.build | 3 +++
> 4 files changed, 21 insertions(+), 1 deletion(-)
> create mode 100644 common-user/meson.build
>
Reviewed-by: Warner Losh <imp@bsdimp.com>
> diff --git a/meson.build b/meson.build
> index c58abf0d0d..387f7fe1c9 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2359,6 +2359,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()
> @@ -2603,15 +2604,28 @@ 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)
> +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')
> diff --git a/bsd-user/meson.build b/bsd-user/meson.build
> index 87885d91ed..25c3976ead 100644
> --- a/bsd-user/meson.build
> +++ b/bsd-user/meson.build
> @@ -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',
> diff --git a/common-user/meson.build b/common-user/meson.build
> new file mode 100644
> index 0000000000..4f5c0f2f88
> --- /dev/null
> +++ b/common-user/meson.build
> @@ -0,0 +1 @@
> +common_user_inc += include_directories('host/' / config_host['ARCH'])
> diff --git a/linux-user/meson.build b/linux-user/meson.build
> index bf62c13e37..d6fa4f4d74 100644
> --- a/linux-user/meson.build
> +++ b/linux-user/meson.build
> @@ -2,6 +2,9 @@ if not have_linux_user
> subdir_done()
> endif
>
> +common_user_inc += include_directories('host/' / config_host['ARCH'])
> +common_user_inc += include_directories('.')
> +
> linux_user_ss.add(files(
> 'elfload.c',
> 'exit.c',
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 4093 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 14/17] common-user: Move safe-syscall.* from linux-user
2021-11-17 16:04 ` [PATCH v5 14/17] common-user: Move safe-syscall.* from linux-user Richard Henderson
@ 2021-11-17 17:23 ` Warner Losh
0 siblings, 0 replies; 46+ messages in thread
From: Warner Losh @ 2021-11-17 17:23 UTC (permalink / raw)
To: Richard Henderson; +Cc: QEMU Developers, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 2732 bytes --]
On Wed, Nov 17, 2021 at 9:04 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> Move linux-user/safe-syscall.S 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.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> {linux-user => include/user}/safe-syscall.h | 0
> linux-user/signal.c | 2 +-
> linux-user/syscall.c | 2 +-
> common-user/meson.build | 2 ++
> {linux-user => common-user}/safe-syscall.S | 0
> linux-user/meson.build | 1 -
> 6 files changed, 4 insertions(+), 3 deletions(-)
> rename {linux-user => include/user}/safe-syscall.h (100%)
> rename {linux-user => common-user}/safe-syscall.S (100%)
>
Reviewed-by: Warner Losh <imp@bsdimp.com>
> diff --git a/linux-user/safe-syscall.h b/include/user/safe-syscall.h
> similarity index 100%
> rename from linux-user/safe-syscall.h
> rename to include/user/safe-syscall.h
> diff --git a/linux-user/signal.c b/linux-user/signal.c
> index 12b1705287..510db73c34 100644
> --- a/linux-user/signal.c
> +++ b/linux-user/signal.c
> @@ -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];
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 33d342157d..53deb887ca 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -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"
> diff --git a/common-user/meson.build b/common-user/meson.build
> index 4f5c0f2f88..c02b5d9cc2 100644
> --- a/common-user/meson.build
> +++ b/common-user/meson.build
> @@ -1 +1,3 @@
> common_user_inc += include_directories('host/' / config_host['ARCH'])
> +
> +common_user_ss.add(files('safe-syscall.S'))
> diff --git a/linux-user/safe-syscall.S b/common-user/safe-syscall.S
> similarity index 100%
> rename from linux-user/safe-syscall.S
> rename to common-user/safe-syscall.S
> diff --git a/linux-user/meson.build b/linux-user/meson.build
> index d6fa4f4d74..bf9d945504 100644
> --- a/linux-user/meson.build
> +++ b/linux-user/meson.build
> @@ -12,7 +12,6 @@ linux_user_ss.add(files(
> 'linuxload.c',
> 'main.c',
> 'mmap.c',
> - 'safe-syscall.S',
> 'signal.c',
> 'strace.c',
> 'syscall.c',
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 3853 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 15/17] linux-user: Move thunk.c from top-level
2021-11-17 16:04 ` [PATCH v5 15/17] linux-user: Move thunk.c from top-level Richard Henderson
2021-11-17 16:52 ` Philippe Mathieu-Daudé
@ 2021-11-17 17:27 ` Warner Losh
1 sibling, 0 replies; 46+ messages in thread
From: Warner Losh @ 2021-11-17 17:27 UTC (permalink / raw)
To: Richard Henderson; +Cc: QEMU Developers, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 1421 bytes --]
On Wed, Nov 17, 2021 at 9:04 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> So far, linux-user is the only user of these functions.
> Clean up the build machinery by restricting it to linux-user.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> meson.build | 1 -
> thunk.c => linux-user/thunk.c | 0
> linux-user/meson.build | 1 +
> 3 files changed, 1 insertion(+), 1 deletion(-)
> rename thunk.c => linux-user/thunk.c (100%)
>
Reviewed-by: Warner Losh <imp@bsdimp.com>
> diff --git a/meson.build b/meson.build
> index 387f7fe1c9..9f59c57909 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2614,7 +2614,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)
> diff --git a/thunk.c b/linux-user/thunk.c
> similarity index 100%
> rename from thunk.c
> rename to linux-user/thunk.c
> diff --git a/linux-user/meson.build b/linux-user/meson.build
> index bf9d945504..fcf7d40f23 100644
> --- a/linux-user/meson.build
> +++ b/linux-user/meson.build
> @@ -15,6 +15,7 @@ linux_user_ss.add(files(
> 'signal.c',
> 'strace.c',
> 'syscall.c',
> + 'thunk.c',
> 'uaccess.c',
> 'uname.c',
> ))
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 2263 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 17/17] meson: Move bsd_user_ss to bsd-user/
2021-11-17 16:04 ` [PATCH v5 17/17] meson: Move bsd_user_ss to bsd-user/ Richard Henderson
2021-11-17 16:56 ` Philippe Mathieu-Daudé
@ 2021-11-17 17:29 ` Warner Losh
1 sibling, 0 replies; 46+ messages in thread
From: Warner Losh @ 2021-11-17 17:29 UTC (permalink / raw)
To: Richard Henderson; +Cc: QEMU Developers, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 1717 bytes --]
On Wed, Nov 17, 2021 at 9:04 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> We have no need to reference bsd_user_ss outside of bsd-user.
> Go ahead and merge it directly into specific_ss.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> meson.build | 3 ---
> bsd-user/meson.build | 4 ++++
> 2 files changed, 4 insertions(+), 3 deletions(-)
>
Reviewed-by: Warner Losh <imp@bsdimp.com>
> diff --git a/meson.build b/meson.build
> index ecc181ea13..9f7756a805 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2356,7 +2356,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()
> @@ -2611,8 +2610,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(),
> diff --git a/bsd-user/meson.build b/bsd-user/meson.build
> index 25c3976ead..9fcb80c3fa 100644
> --- a/bsd-user/meson.build
> +++ b/bsd-user/meson.build
> @@ -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)
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 2566 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 16/17] meson: Move linux_user_ss to linux-user/
2021-11-17 16:04 ` [PATCH v5 16/17] meson: Move linux_user_ss to linux-user/ Richard Henderson
2021-11-17 16:56 ` Philippe Mathieu-Daudé
@ 2021-11-17 17:31 ` Warner Losh
1 sibling, 0 replies; 46+ messages in thread
From: Warner Losh @ 2021-11-17 17:31 UTC (permalink / raw)
To: Richard Henderson; +Cc: QEMU Developers, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 1942 bytes --]
On Wed, Nov 17, 2021 at 9:04 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> We have no need to reference linux_user_ss outside of linux-user.
> Go ahead and merge it directly into specific_ss.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> meson.build | 3 ---
> linux-user/meson.build | 4 ++++
> 2 files changed, 4 insertions(+), 3 deletions(-)
>
Reviewed-by: Warner Losh <imp@bsdimp.com>
BTW, I don't think I have anything meaningful to add to the discussions to
date on this bug, and I'm
agnostic as to the final decision...
> diff --git a/meson.build b/meson.build
> index 9f59c57909..ecc181ea13 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2363,7 +2363,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()
> @@ -2614,8 +2613,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(),
> diff --git a/linux-user/meson.build b/linux-user/meson.build
> index fcf7d40f23..b89534c49c 100644
> --- a/linux-user/meson.build
> +++ b/linux-user/meson.build
> @@ -2,6 +2,8 @@ if not have_linux_user
> subdir_done()
> endif
>
> +linux_user_ss = ss.source_set()
> +
> common_user_inc += include_directories('host/' / config_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)
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 2874 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 00/17] linux-user: simplify safe signal handling
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
` (16 preceding siblings ...)
2021-11-17 16:04 ` [PATCH v5 17/17] meson: Move bsd_user_ss to bsd-user/ Richard Henderson
@ 2021-11-17 17:42 ` Warner Losh
17 siblings, 0 replies; 46+ messages in thread
From: Warner Losh @ 2021-11-17 17:42 UTC (permalink / raw)
To: Richard Henderson; +Cc: QEMU Developers, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 9244 bytes --]
On Wed, Nov 17, 2021 at 9:04 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> Warner's v3:
> https://patchew.org/QEMU/20211113045603.60391-1-imp@bsdimp.com/
>
> Changes for v5:
> * Fix safe-syscall.S FreeBSD typos.
> * Rename special TARGET_EFOO to QEMU_EFOO.
> * Create *-user/special-errno.h.
> * Build safe-syscall.o only once.
> * meson.build cleanups.
> * bsd-user builds without modification on master.
>
> Changes for v4:
> * Move errno handling into the assembly. While returning the
> raw -errno is handy for x86 linux (and a few others), it is
> in fact more complex for other hosts that return a separate
> error indicator. At which point we wind up jumping through
> hoops to return -errno, only to have the caller put it right
> back into +errno with -1 result, just like syscall(3).
>
> Pass in &errno, because the method of calculating this
> varies wildly between glibc, musl, etc. This means that
> the assembly need only store to a provided pointer.
>
> * Add mips and sparc safe-syscall implementations.
> Both of which, btw, have separate error indicators. ;-)
>
> * All hosts now have it, so remove HAVE_SAFE_SYSCALL.
>
> * Add meson.build rules for common-user/safe-syscall.S, so
> that we don't have to have weird includes from *-user.
>
>
> r~
>
>
> Richard Henderson (13):
> common-user: Move syscall error detection into safe_syscall_base
> common-user/host/mips: Add safe-syscall.inc.S
> common-user/host/sparc64: Add safe-syscall.inc.S
> linux-user: Remove HAVE_SAFE_SYSCALL and hostdep.h
> *-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS
> linux-user: Rename TARGET_QEMU_ESIGRETURN to QEMU_ESIGRETURN
> bsd-user: Create special-errno.h
> linux-user: Create special-errno.h
> meson: Add build infrastructure for common-user
> common-user: Move safe-syscall.* from linux-user
> linux-user: Move thunk.c from top-level
> meson: Move linux_user_ss to linux-user/
> meson: Move bsd_user_ss to bsd-user/
>
In addition to the reviews, I've pulled these changes, and
as a whole they build and work on FreeBSD with my small
test binaries for x86.
It also works with my in-flight arm addition.
I've not tried to integrate it into the bsd-user fork's 'blitz'
branch though I don't think there will be issues.
Thanks!
Warner
> Warner Losh (4):
> linux-user: Add host_signal_set_pc to set pc in mcontext
> linux-user/signal.c: Create a common rewind_if_in_safe_syscall
> linux-user/safe-syscall.inc.S: Move to common-user
> common-user: Adjust system call return on FreeBSD
>
> meson.build | 23 ++-
> bsd-user/errno_defs.h | 6 +-
> bsd-user/special-errno.h | 24 ++++
> {linux-user => include/user}/safe-syscall.h | 39 ++---
> linux-user/cpu_loop-common.h | 1 +
> linux-user/generic/target_errno_defs.h | 17 ---
> linux-user/host/aarch64/host-signal.h | 5 +
> linux-user/host/aarch64/hostdep.h | 38 -----
> linux-user/host/alpha/host-signal.h | 5 +
> linux-user/host/arm/host-signal.h | 5 +
> linux-user/host/arm/hostdep.h | 38 -----
> linux-user/host/i386/host-signal.h | 5 +
> linux-user/host/i386/hostdep.h | 38 -----
> linux-user/host/ia64/hostdep.h | 15 --
> linux-user/host/mips/host-signal.h | 5 +
> linux-user/host/mips/hostdep.h | 15 --
> linux-user/host/ppc/host-signal.h | 5 +
> linux-user/host/ppc/hostdep.h | 15 --
> linux-user/host/ppc64/hostdep.h | 38 -----
> linux-user/host/riscv/host-signal.h | 5 +
> linux-user/host/riscv/hostdep.h | 34 -----
> linux-user/host/s390/host-signal.h | 5 +
> linux-user/host/s390/hostdep.h | 15 --
> linux-user/host/s390x/hostdep.h | 38 -----
> linux-user/host/sparc/host-signal.h | 9 ++
> 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/host-signal.h | 5 +
> linux-user/host/x86_64/hostdep.h | 38 -----
> linux-user/signal-common.h | 4 +-
> linux-user/special-errno.h | 32 +++++
> linux-user/user-internals.h | 1 -
> 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 | 19 ++-
> 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 +-
> bsd-user/meson.build | 6 +
> .../host/aarch64/safe-syscall.inc.S | 65 ++++++---
> .../host/arm/safe-syscall.inc.S | 69 ++++++---
> .../host/i386/safe-syscall.inc.S | 61 +++++---
> common-user/host/mips/safe-syscall.inc.S | 135 ++++++++++++++++++
> .../host/ppc64/safe-syscall.inc.S | 63 ++++----
> .../host/riscv/safe-syscall.inc.S | 50 ++++---
> .../host/s390x/safe-syscall.inc.S | 50 ++++---
> common-user/host/sparc64/safe-syscall.inc.S | 91 ++++++++++++
> .../host/x86_64/safe-syscall.inc.S | 80 +++++++----
> common-user/meson.build | 3 +
> {linux-user => common-user}/safe-syscall.S | 5 +-
> linux-user/meson.build | 9 +-
> 82 files changed, 778 insertions(+), 689 deletions(-)
> create mode 100644 bsd-user/special-errno.h
> rename {linux-user => include/user}/safe-syscall.h (81%)
> 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
> rename thunk.c => linux-user/thunk.c (100%)
> rename {linux-user => common-user}/host/aarch64/safe-syscall.inc.S (64%)
> rename {linux-user => common-user}/host/arm/safe-syscall.inc.S (64%)
> rename {linux-user => common-user}/host/i386/safe-syscall.inc.S (71%)
> create mode 100644 common-user/host/mips/safe-syscall.inc.S
> rename {linux-user => common-user}/host/ppc64/safe-syscall.inc.S (68%)
> rename {linux-user => common-user}/host/riscv/safe-syscall.inc.S (77%)
> rename {linux-user => common-user}/host/s390x/safe-syscall.inc.S (71%)
> create mode 100644 common-user/host/sparc64/safe-syscall.inc.S
> rename {linux-user => common-user}/host/x86_64/safe-syscall.inc.S (64%)
> create mode 100644 common-user/meson.build
> rename {linux-user => common-user}/safe-syscall.S (91%)
>
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 11581 bytes --]
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 04/17] common-user: Move syscall error detection into safe_syscall_base
2021-11-17 16:03 ` [PATCH v5 04/17] common-user: Move syscall error detection into safe_syscall_base Richard Henderson
2021-11-17 16:28 ` Warner Losh
@ 2021-11-22 11:55 ` Peter Maydell
2021-11-22 12:21 ` Richard Henderson
1 sibling, 1 reply; 46+ messages in thread
From: Peter Maydell @ 2021-11-22 11:55 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel, imp, Laurent
On Wed, 17 Nov 2021 at 16:12, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> 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 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.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> linux-user/safe-syscall.h | 20 +++---
> common-user/host/aarch64/safe-syscall.inc.S | 55 +++++++++-------
> common-user/host/arm/safe-syscall.inc.S | 58 ++++++++++-------
> common-user/host/i386/safe-syscall.inc.S | 51 +++++++++------
> common-user/host/ppc64/safe-syscall.inc.S | 63 +++++++++++--------
> common-user/host/riscv/safe-syscall.inc.S | 50 +++++++++------
> common-user/host/s390x/safe-syscall.inc.S | 50 +++++++++------
> common-user/host/x86_64/safe-syscall.inc.S | 70 ++++++++++++---------
> 8 files changed, 243 insertions(+), 174 deletions(-)
>
> diff --git a/linux-user/safe-syscall.h b/linux-user/safe-syscall.h
> index aaa9ffc0e2..ea0e8a8d24 100644
> --- a/linux-user/safe-syscall.h
> +++ b/linux-user/safe-syscall.h
> @@ -125,23 +125,17 @@
> * 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, ...);
> +
> +/* The core part of this function is implemented in assembly. */
> +extern long safe_syscall_base(int *pending, int *errnop, long number, ...);
> +
> /* 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, \
> + &errno, __VA_ARGS__)
>
> #else
>
> diff --git a/common-user/host/aarch64/safe-syscall.inc.S b/common-user/host/aarch64/safe-syscall.inc.S
> index bc1f5a9792..95c60d8609 100644
> --- a/common-user/host/aarch64/safe-syscall.inc.S
> +++ b/common-user/host/aarch64/safe-syscall.inc.S
> @@ -17,22 +17,21 @@
> .type safe_syscall_start, #function
> .type safe_syscall_end, #function
>
> - /* This is the entry point for making a system call. The calling
> + /*
> + * 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').
This comment text needs updating to mention the new errnop argument.
(Applies to all the similar comments in the files for the other archs.)
> - * 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:
> + /*
> + * The syscall calling convention isn't the same as the C one:
Looks like the indent here is wrong ?
> * we enter with x0 == *signal_pending
> - * x1 == syscall number
> - * x2 ... x7, (stack) == syscall arguments
> + * x1 == errno
"int* address of errno"
> + * x2 == syscall number
> + * x3 ... x7, (stack) == syscall arguments
> * and return the result in x0
> * and the syscall instruction needs
> * x8 == syscall number
> @@ -40,17 +39,18 @@ safe_syscall_base:
> * 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]
> + mov x10, x0 /* signal_pending pointer */
> + mov x11, x1 /* errno pointer */
> + mov x8, x2 /* syscall number */
> + mov x0, x3 /* syscall arguments */
> + mov x1, x4
> + mov x2, x5
> + mov x3, x6
> + mov x4, x7
> + ldp x5, x6, [sp]
>
> - /* This next sequence of code works in conjunction with the
> + /*
> + * 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'.
> @@ -59,17 +59,26 @@ safe_syscall_base:
> */
> safe_syscall_start:
> /* if signal_pending is non-zero, don't do the call */
> - ldr w10, [x9]
> - cbnz w10, 0f
> + ldr w9, [x10]
> + cbnz w9, 2f
> svc 0x0
> safe_syscall_end:
> +
> /* code path for having successfully executed the syscall */
> + cmn x0, #4095
> + b.cs 1f
Shouldn't this be going to label 0f ? We need to do the 'neg',
and unless I'm misreading the diff there's currently no path
of execution that gets to that.
Alternatively, branch on the opposite-sense condition to the
'ret' after the set-errno stuff.
> ret
>
> -0:
> - /* code path when we didn't execute the syscall */
> - mov x0, #-TARGET_ERESTARTSYS
> + /* code path setting errno */
> +0: neg w0, w0 /* create positive errno */
> +1: str w0, [x11] /* store errno */
> + mov x0, #-1
> ret
> +
> + /* code path when we didn't execute the syscall */
> +2: mov w0, #TARGET_ERESTARTSYS
> + b 1b
> +
> .cfi_endproc
>
> .size safe_syscall_base, .-safe_syscall_base
> diff --git a/common-user/host/arm/safe-syscall.inc.S b/common-user/host/arm/safe-syscall.inc.S
> index 88c4958504..17839c6486 100644
> --- a/common-user/host/arm/safe-syscall.inc.S
> +++ b/common-user/host/arm/safe-syscall.inc.S
> @@ -22,33 +22,35 @@
> .arm
> .align 2
>
> - /* This is the entry point for making a system call. The calling
> + /*
> + * 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:
> .fnstart
> .cfi_startproc
> mov r12, sp /* save entry stack */
> - push { r4, r5, r6, r7, r8, lr }
> - .save { r4, r5, r6, r7, r8, lr }
> - .cfi_adjust_cfa_offset 24
> + push { r4, r5, r6, r7, r8, r9, r10, lr }
> + .save { r4, r5, r6, r7, r8, r9, r10, lr }
> + .cfi_adjust_cfa_offset 32
> .cfi_rel_offset r4, 0
> .cfi_rel_offset r5, 4
> .cfi_rel_offset r6, 8
> .cfi_rel_offset r7, 12
> .cfi_rel_offset r8, 16
> - .cfi_rel_offset lr, 20
> + .cfi_rel_offset r9, 20
> + .cfi_rel_offset r10, 24
> + .cfi_rel_offset lr, 28
>
> - /* The syscall calling convention isn't the same as the C one:
> - * we enter with r0 == *signal_pending
> - * r1 == syscall number
> - * r2, r3, [sp+0] ... [sp+12] == syscall arguments
> + /*
> + * The syscall calling convention isn't the same as the C one:
> + * we enter with r0 == &signal_pending
> + * r1 == &errno
Odd indent ?
> + * r2 == syscall number
> + * r3, [sp+0] ... [sp+16] == syscall arguments
> * and return the result in r0
Don't we wind up with a potential issue here with 64-bit arguments
due to the calling convention wanting to put those in aligned
memory/register locations? Previously because we had just two
extra arguments the arguments started at r2 and had the same
alignment behaviour as the syscall wants for them starting at
r0; but now we start at r3 so if for instance the first argument
is 64-bit it will be in [sp+0][sp+4] but should go in r0:r1
I think...
(Stopped reviewing here because if we need to change the
way we call these functions there's no point my reviewing
the fine detail of the asm.)
-- PMM
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 04/17] common-user: Move syscall error detection into safe_syscall_base
2021-11-22 11:55 ` Peter Maydell
@ 2021-11-22 12:21 ` Richard Henderson
2021-11-22 15:07 ` Peter Maydell
0 siblings, 1 reply; 46+ messages in thread
From: Richard Henderson @ 2021-11-22 12:21 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, imp, Laurent
On 11/22/21 12:55 PM, Peter Maydell wrote:
>> - /* This is the entry point for making a system call. The calling
>> + /*
>> + * 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').
>
> This comment text needs updating to mention the new errnop argument.
> (Applies to all the similar comments in the files for the other archs.)
Yep.
>> + /*
>> + * The syscall calling convention isn't the same as the C one:
>
> Looks like the indent here is wrong ?
Irritatingly, these files are a mix of tabs/spaces.
>> * we enter with x0 == *signal_pending
>> - * x1 == syscall number
>> - * x2 ... x7, (stack) == syscall arguments
>> + * x1 == errno
>
> "int* address of errno"
Arg, fixed some of these, but clearly. not all.
>> /* code path for having successfully executed the syscall */
>> + cmn x0, #4095
>> + b.cs 1f
>
> Shouldn't this be going to label 0f ? We need to do the 'neg',
> and unless I'm misreading the diff there's currently no path
> of execution that gets to that.
Oops, rebase error, where the fix landed in the next patch.
>> + * r2 == syscall number
>> + * r3, [sp+0] ... [sp+16] == syscall arguments
>> * and return the result in r0
>
> Don't we wind up with a potential issue here with 64-bit arguments
> due to the calling convention wanting to put those in aligned
> memory/register locations? Previously because we had just two
> extra arguments the arguments started at r2 and had the same
> alignment behaviour as the syscall wants for them starting at
> r0; but now we start at r3 so if for instance the first argument
> is 64-bit it will be in [sp+0][sp+4] but should go in r0:r1
> I think...
>
> (Stopped reviewing here because if we need to change the
> way we call these functions there's no point my reviewing
> the fine detail of the asm.)
Oof. I missed that detail. Yes, that is a problem (I think arm is the only such
supported host). I think the best solution would be to *not* pass in &errno, but to have
the assembly tail-call to
long safe_syscall_errno_tail(int value)
{
errno = value;
return -1;
}
Which is probably more efficient in any case. I'll re-work this.
r~
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5 04/17] common-user: Move syscall error detection into safe_syscall_base
2021-11-22 12:21 ` Richard Henderson
@ 2021-11-22 15:07 ` Peter Maydell
0 siblings, 0 replies; 46+ messages in thread
From: Peter Maydell @ 2021-11-22 15:07 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel, imp, Laurent
On Mon, 22 Nov 2021 at 12:21, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> On 11/22/21 12:55 PM, Peter Maydell wrote:
> >> + /*
> >> + * The syscall calling convention isn't the same as the C one:
> >
> > Looks like the indent here is wrong ?
>
> Irritatingly, these files are a mix of tabs/spaces.
Hmm, so they are; I wonder how we let that slip in. Maybe do
a set of preparatory patches doing a mechanical tab-to-space
conversion?
-- PMM
^ permalink raw reply [flat|nested] 46+ messages in thread
end of thread, other threads:[~2021-11-22 15:09 UTC | newest]
Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-17 16:03 [PATCH v5 00/17] linux-user: simplify safe signal handling Richard Henderson
2021-11-17 16:03 ` [PATCH v5 01/17] linux-user: Add host_signal_set_pc to set pc in mcontext Richard Henderson
2021-11-17 16:23 ` Warner Losh
2021-11-17 16:37 ` Alex Bennée
2021-11-17 16:03 ` [PATCH v5 02/17] linux-user/signal.c: Create a common rewind_if_in_safe_syscall Richard Henderson
2021-11-17 16:24 ` Warner Losh
2021-11-17 16:37 ` Alex Bennée
2021-11-17 16:03 ` [PATCH v5 03/17] linux-user/safe-syscall.inc.S: Move to common-user Richard Henderson
2021-11-17 16:25 ` Warner Losh
2021-11-17 16:38 ` Alex Bennée
2021-11-17 16:03 ` [PATCH v5 04/17] common-user: Move syscall error detection into safe_syscall_base Richard Henderson
2021-11-17 16:28 ` Warner Losh
2021-11-22 11:55 ` Peter Maydell
2021-11-22 12:21 ` Richard Henderson
2021-11-22 15:07 ` Peter Maydell
2021-11-17 16:04 ` [PATCH v5 05/17] common-user/host/mips: Add safe-syscall.inc.S Richard Henderson
2021-11-17 16:31 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 06/17] common-user/host/sparc64: " Richard Henderson
2021-11-17 16:04 ` [PATCH v5 07/17] linux-user: Remove HAVE_SAFE_SYSCALL and hostdep.h Richard Henderson
2021-11-17 16:04 ` [PATCH v5 08/17] common-user: Adjust system call return on FreeBSD Richard Henderson
2021-11-17 16:44 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 09/17] *-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS Richard Henderson
2021-11-17 16:46 ` Warner Losh
2021-11-17 16:51 ` Philippe Mathieu-Daudé
2021-11-17 16:04 ` [PATCH v5 10/17] linux-user: Rename TARGET_QEMU_ESIGRETURN to QEMU_ESIGRETURN Richard Henderson
2021-11-17 17:01 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 11/17] bsd-user: Create special-errno.h Richard Henderson
2021-11-17 17:21 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 12/17] linux-user: " Richard Henderson
2021-11-17 17:21 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 13/17] meson: Add build infrastructure for common-user Richard Henderson
2021-11-17 17:22 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 14/17] common-user: Move safe-syscall.* from linux-user Richard Henderson
2021-11-17 17:23 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 15/17] linux-user: Move thunk.c from top-level Richard Henderson
2021-11-17 16:52 ` Philippe Mathieu-Daudé
2021-11-17 17:27 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 16/17] meson: Move linux_user_ss to linux-user/ Richard Henderson
2021-11-17 16:56 ` Philippe Mathieu-Daudé
2021-11-17 17:04 ` Richard Henderson
2021-11-17 17:11 ` Philippe Mathieu-Daudé
2021-11-17 17:31 ` Warner Losh
2021-11-17 16:04 ` [PATCH v5 17/17] meson: Move bsd_user_ss to bsd-user/ Richard Henderson
2021-11-17 16:56 ` Philippe Mathieu-Daudé
2021-11-17 17:29 ` Warner Losh
2021-11-17 17:42 ` [PATCH v5 00/17] linux-user: simplify safe signal handling Warner Losh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).