From nobody Fri Jun 17 19:32:04 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A3F86853BB3; Fri, 17 Jun 2022 19:32:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LPq1K0yrxz3KM4; Fri, 17 Jun 2022 19:32:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494325; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=duYDk7OreXlwaGSU7FPfHbyOj8GLot+IiYKlRRLNHaQ=; b=kFHJ40tFgMVYZp6a0oUqA+Xm9jlSN+nFy4H4PrOSGipHOvL6GesZ8GXgx9LuGhVvtYdbhb fE+EcqdTcVJ+odmEPW1k7Ab8rpzLuofVFsvszRvnjWhgyCQf3JWv0SUaeoxFsJUPEL8KO8 Ftwpg8JlQFpO8TgSavX2kWmYw3bazqXUUBVHMXY6hvYnaJrXJqJ8MaNR7OltvJRwbhDpvX A6VGAi4GlWujXdXGamt8DUxd1NE6BXTR2QPEbAcIPkXfEda2hdBgk5EXg5zkL69n6yJzjw yfdeku/5F4AC8JmUoiK8PQTILST4BTwbAIZTMTjklabPAqWcc6ri9wENpbmA6g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ED3E22556C; Fri, 17 Jun 2022 19:32:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25HJW4HN007985; Fri, 17 Jun 2022 19:32:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJW4u3007984; Fri, 17 Jun 2022 19:32:04 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:32:04 GMT Message-Id: <202206171932.25HJW4u3007984@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: e056a2379340 - stable/13 - linux: reduce differences between rt_sendsig() and sendsig() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e056a2379340417682c53f6e644001e459014db3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494325; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=duYDk7OreXlwaGSU7FPfHbyOj8GLot+IiYKlRRLNHaQ=; b=GqG7eMEhiZkkR2il8E+Iw7NWigW0fLs4G/XjDA2mZmyDj2IInWQl1FUWS9VdkYlScMoQ0C g1GzxHUahCohIR0V5RBoOrSnUtH7JxXOnu0baQnT5t/Uj/HC1jogGIQojYWVilFze9ayLP /Jejx1sNwx+PU/7INFYDXCf+iZXJK8U09/QZOzuymaK6i3dO2uDqXOBKEaVCjlHTOUQVHk 7BJ3XulNweE5Vjnd8iRnKa/IS055FO1KwfFXsj3NEj73fb+AZc/liJI+K5rbccpHopUYhz uar0RVuy86rU74z8oKOgWpzuLKjA5Abz1krWY+rpAmx16/h8vZ8hOjVyq37e/Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494325; a=rsa-sha256; cv=none; b=AJWvT52E1WvFh/1dZrEPv4WTvm26dzl8pa0zmuXtuYh+6i1XOlaYAAcXTyffdkh2ceCzVu /PZbYpvaMRmYgotpn+Xki27hk7xOR+xl2Henkp2yut2YWnaS3GSAT94tUqvOk+2Qli/PU+ XUoCcnGOCQ41JubzexcGzYKYe3s9KYzKVCZIqVhEhpiXtQkFs8ekAtnQgdmFRUsMGL9xc9 rAQWQTnePh5QarDT3kMoGuiLdWlfuNkiaWjqiG/3VWx2SU1Q/61Szlun+zbF2jyubCUIFW lXn1H9XEn+Uq5CwOkrcsAGJlAa4US46+S1PLV2noufEalHLGyPwCNXDca1o4JA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=e056a2379340417682c53f6e644001e459014db3 commit e056a2379340417682c53f6e644001e459014db3 Author: Edward Tomasz Napierala AuthorDate: 2021-06-21 16:13:53 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:30:20 +0000 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) --- sys/amd64/linux/linux_sysvec.c | 27 ++++++++++++++------------- 1 file 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) {