aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/linux/linux_sysvec.c
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2021-06-21 16:13:53 +0000
committerDmitry Chagin <dchagin@FreeBSD.org>2022-06-17 19:30:20 +0000
commite056a2379340417682c53f6e644001e459014db3 (patch)
tree17f6b1ad50ff5e545141a2469997e49f954d3b89 /sys/amd64/linux/linux_sysvec.c
parentb5bfa2af4bbdf3d72eee4e4769572a17edeb8fc8 (diff)
downloadsrc-e056a2379340417682c53f6e644001e459014db3.tar.gz
src-e056a2379340417682c53f6e644001e459014db3.zip
linux: reduce differences between rt_sendsig() and sendsig()
This makes it easier to compare the two. This involves moving the mutex slightly lower down, but there should be no functional changes. Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D30541 (cherry picked from commit 135dd0cab51e89739416d8f924ea984e364a110e)
Diffstat (limited to 'sys/amd64/linux/linux_sysvec.c')
-rw-r--r--sys/amd64/linux/linux_sysvec.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c
index 6ed694dc8af9..4a85f0469804 100644
--- a/sys/amd64/linux/linux_sysvec.c
+++ b/sys/amd64/linux/linux_sysvec.c
@@ -604,17 +604,6 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
LINUX_CTR4(rt_sendsig, "%p, %d, %p, %u",
catcher, sig, mask, code);
- /* Allocate space for the signal handler context. */
- if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack &&
- SIGISMEMBER(psp->ps_sigonstack, sig)) {
- sp = (caddr_t)td->td_sigstk.ss_sp + td->td_sigstk.ss_size -
- sizeof(struct l_rt_sigframe);
- } else
- sp = (caddr_t)regs->tf_rsp - sizeof(struct l_rt_sigframe) - 128;
- /* Align to 16 bytes. */
- sfp = (struct l_rt_sigframe *)((unsigned long)sp & ~0xFul);
- mtx_unlock(&psp->ps_mtx);
-
/* Translate the signal. */
sig = bsd_to_linux_signal(sig);
@@ -627,7 +616,6 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
sf.sf_sc.uc_stack.ss_size = td->td_sigstk.ss_size;
sf.sf_sc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK)
? ((oonstack) ? LINUX_SS_ONSTACK : 0) : LINUX_SS_DISABLE;
- PROC_UNLOCK(p);
sf.sf_sc.uc_mcontext.sc_rdi = regs->tf_rdi;
sf.sf_sc.uc_mcontext.sc_rsi = regs->tf_rsi;
@@ -652,15 +640,28 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
sf.sf_sc.uc_mcontext.sc_trapno = bsd_to_linux_trapcode(code);
sf.sf_sc.uc_mcontext.sc_cr2 = (register_t)ksi->ksi_addr;
+ /* Allocate space for the signal handler context. */
+ if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack &&
+ SIGISMEMBER(psp->ps_sigonstack, sig)) {
+ sp = (caddr_t)td->td_sigstk.ss_sp + td->td_sigstk.ss_size -
+ sizeof(struct l_rt_sigframe);
+ } else
+ sp = (caddr_t)regs->tf_rsp - sizeof(struct l_rt_sigframe) - 128;
+ /* Align to 16 bytes. */
+ sfp = (struct l_rt_sigframe *)((unsigned long)sp & ~0xFul);
+
/* Build the argument list for the signal handler. */
regs->tf_rdi = sig; /* arg 1 in %rdi */
regs->tf_rax = 0;
regs->tf_rsi = (register_t)&sfp->sf_si; /* arg 2 in %rsi */
regs->tf_rdx = (register_t)&sfp->sf_sc; /* arg 3 in %rdx */
- sf.sf_handler = catcher;
/* Fill in POSIX parts. */
siginfo_to_lsiginfo(&ksi->ksi_info, &sf.sf_si, sig);
+ sf.sf_handler = catcher;
+
+ mtx_unlock(&psp->ps_mtx);
+ PROC_UNLOCK(p);
/* Copy the sigframe out to the user's stack. */
if (copyout(&sf, sfp, sizeof(*sfp)) != 0) {