Skip to content

Commit 31330e6

Browse files
rth7680vivier
authored andcommitted
linux-user/s390x: Implement setup_sigtramp
Create and record the two signal trampolines. Use them when the guest does not use SA_RESTORER. Cc: [email protected] Tested-by: Alex Bennée <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: Richard Henderson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Laurent Vivier <[email protected]>
1 parent 3c62b5d commit 31330e6

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

linux-user/s390x/signal.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ typedef struct {
6868
target_sigregs sregs;
6969
int signo;
7070
target_sigregs_ext sregs_ext;
71-
uint16_t retcode;
7271
} sigframe;
7372

7473
#define TARGET_UC_VXRS 2
@@ -85,7 +84,6 @@ struct target_ucontext {
8584

8685
typedef struct {
8786
uint8_t callee_used_stack[__SIGNAL_FRAMESIZE];
88-
uint16_t retcode;
8987
struct target_siginfo info;
9088
struct target_ucontext uc;
9189
} rt_sigframe;
@@ -209,9 +207,7 @@ void setup_frame(int sig, struct target_sigaction *ka,
209207
if (ka->sa_flags & TARGET_SA_RESTORER) {
210208
restorer = ka->sa_restorer;
211209
} else {
212-
restorer = frame_addr + offsetof(sigframe, retcode);
213-
__put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn,
214-
&frame->retcode);
210+
restorer = default_sigreturn;
215211
}
216212

217213
/* Set up registers for signal handler */
@@ -262,9 +258,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
262258
if (ka->sa_flags & TARGET_SA_RESTORER) {
263259
restorer = ka->sa_restorer;
264260
} else {
265-
restorer = frame_addr + offsetof(typeof(*frame), retcode);
266-
__put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn,
267-
&frame->retcode);
261+
restorer = default_rt_sigreturn;
268262
}
269263

270264
/* Create siginfo on the signal stack. */
@@ -405,3 +399,17 @@ long do_rt_sigreturn(CPUS390XState *env)
405399
unlock_user_struct(frame, frame_addr, 0);
406400
return -TARGET_QEMU_ESIGRETURN;
407401
}
402+
403+
void setup_sigtramp(abi_ulong sigtramp_page)
404+
{
405+
uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 + 2, 0);
406+
assert(tramp != NULL);
407+
408+
default_sigreturn = sigtramp_page;
409+
__put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn, &tramp[0]);
410+
411+
default_rt_sigreturn = sigtramp_page + 2;
412+
__put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, &tramp[1]);
413+
414+
unlock_user(tramp, sigtramp_page, 2 + 2);
415+
}

linux-user/s390x/target_signal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ typedef struct target_sigaltstack {
1919
#include "../generic/signal.h"
2020

2121
#define TARGET_ARCH_HAS_SETUP_FRAME
22+
#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
23+
2224
#endif /* S390X_TARGET_SIGNAL_H */

0 commit comments

Comments
 (0)