[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 17/30] bsd-user/signal.c: Implement rewind_if_in_safe_syscall
|
From: |
Warner Losh |
|
Subject: |
[PATCH 17/30] bsd-user/signal.c: Implement rewind_if_in_safe_syscall |
|
Date: |
Sun, 9 Jan 2022 09:19:10 -0700 |
Signed-off-by: Kyle Evans <kevans@freebsd.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/qemu.h | 2 ++
bsd-user/signal.c | 12 ++++++++++++
2 files changed, 14 insertions(+)
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 0e0b8db708b..e5e97632c82 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -454,4 +454,6 @@ static inline void *lock_user_string(abi_ulong guest_addr)
#include <pthread.h>
+#include "user/safe-syscall.h"
+
#endif /* QEMU_H */
diff --git a/bsd-user/signal.c b/bsd-user/signal.c
index 3fe8b2d9898..b1331f63d61 100644
--- a/bsd-user/signal.c
+++ b/bsd-user/signal.c
@@ -43,6 +43,18 @@ int target_to_host_signal(int sig)
return sig;
}
+/* 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 = (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);
+ }
+}
+
/* Siginfo conversion. */
static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo,
const siginfo_t *info)
--
2.33.1
- Re: [PATCH 11/30] bsd-user/host/arm/host-signal.h: Implement host_signal_*, (continued)
[PATCH 17/30] bsd-user/signal.c: Implement rewind_if_in_safe_syscall,
Warner Losh <=
[PATCH 23/30] bsd-user/signal.c: sigset manipulation routines., Warner Losh, 2022/01/09
[PATCH 15/30] bsd-user: Add trace events for bsd-usr, Warner Losh, 2022/01/09
[PATCH 25/30] bsd-user/signal.c: handle_pending_signal, Warner Losh, 2022/01/09