From nobody Fri Jun 17 19:37:02 2022 X-Original-To: dev-commits-src-all@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 613EA85A59D; Fri, 17 Jun 2022 19:37:03 +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 4LPq7273QQz3PPl; Fri, 17 Jun 2022 19:37:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494623; 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=L3O6iNTdMg3UV7goCZzELeUVX2hzyxqyBfUsYWFO2mw=; b=Ove7y7v7K0sTkL1VzQLlujkl9Oe0+mkGWOtGikZnr4m7mUGiJM48XP75/uLDaXe+0gCMuN Fsd9fJddhqza4TxEZU4R59c7A7DaB1gMsSKA8i/J5rA1GDcRgrfunpD6NE/vATgfmJl28J qwT1f3seMalyenmZsMLFnzOkcUaDkDcYmeAuF7kJt5obEvl5wibn3HhhEKOIKC9AUNnCGl khIPDgs252NxTALGUm0dmtcWNcBRmk1tyzciCiFjx3MuvzPfb5rM3T+Sok7yjBGSFOFbmn /m0Z38nLMr9EcElx2LNg7BI7bmi4wYCeSxe5N4Ql87lSEGf4exp6aZ7RiDbOvw== 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 D0FBE259B8; Fri, 17 Jun 2022 19:37:02 +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 25HJb2Va012829; Fri, 17 Jun 2022 19:37:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJb2EO012828; Fri, 17 Jun 2022 19:37:02 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:37:02 GMT Message-Id: <202206171937.25HJb2EO012828@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: 97382953f2c7 - stable/13 - linux: implement sigaltstack(2) on arm64 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: 97382953f2c75b9cbee85daf1b7ad5e6bf0381bf Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494623; 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=L3O6iNTdMg3UV7goCZzELeUVX2hzyxqyBfUsYWFO2mw=; b=DPu7w2xO8qGm2XDWcK1VGS495yjLJcsKaWJjqaLR84RSl7NPcGJ+lTiZH7/UeY2tYKXh0e TRhWcEJ/HhofHDMAJMaXd3ZyvS7Cm9COQTU7NV7lZ3gBlA5VV0TTwtcqGxAkpGmiXkifU9 FMdR9govz2J7w6E7o+rtB4HRFAMRqdYgK6QP3/O3+VyJat4Q0tDTMTJG9gGzPZEerh5qxN MOfVzN2lUbU+8un24kaTFO0JLVHoot+8EotLwjXjdYD4vIl7p/k9NL2Z2M/C4Qv7i29ncR XEUNSDdvFgksqD7UwEhAZ5f9A0KJLyHB8Ca/tlHRubi0/No02qUjopDbVZFlDw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494623; a=rsa-sha256; cv=none; b=n2lcAklVR2oE30uPaENvWu9sQgphb4sjIQI+SgVizuZpnqOk3qDEP8Z7yUPtaXxKAoXA8/ NshAORa9GMiakjcAdMpx+tZuy44sx/C2y5IkwTwBKd8/EIaoNJ6m05OPyg2A/S2sxU//3A rMXjQGAfJdvRyHVHPGqC6dqbF1G66CsPHpNumZezIwx+gylwRBn8a56Hz8AUrQdhJevV5X 3wZOUThXKH5LJdG8tM02kqIA1oX1bC8jcTUxM88RZZjYhXcJNmTWkhLbUCwj3KSUtyZCSG X/6XzjeeMsICRyt5IWbRX08W9ARhQP/CGcWxmM+mLOB8yVSd2K59dLPQuR2Sjw== 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=97382953f2c75b9cbee85daf1b7ad5e6bf0381bf commit 97382953f2c75b9cbee85daf1b7ad5e6bf0381bf Author: Edward Tomasz Napierala AuthorDate: 2021-07-26 23:43:09 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:33:10 +0000 linux: implement sigaltstack(2) on arm64 ... by making it machine-independent. Reviewed By: dchagin Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D31286 (cherry picked from commit 30c6d982190482857883fc96eefafcc6fd769fa0) --- sys/amd64/linux/linux_machdep.c | 31 ------------------------------- sys/amd64/linux32/linux32_machdep.c | 28 ---------------------------- sys/arm64/linux/linux_machdep.c | 10 ---------- sys/compat/linux/linux_signal.c | 32 ++++++++++++++++++++++++++++++++ sys/i386/linux/linux.h | 2 +- sys/i386/linux/linux_machdep.c | 28 ---------------------------- sys/i386/linux/linux_sysvec.c | 4 ++-- 7 files changed, 35 insertions(+), 100 deletions(-) diff --git a/sys/amd64/linux/linux_machdep.c b/sys/amd64/linux/linux_machdep.c index b67bed524c79..5de27a7ee7d3 100644 --- a/sys/amd64/linux/linux_machdep.c +++ b/sys/amd64/linux/linux_machdep.c @@ -188,37 +188,6 @@ linux_pause(struct thread *td, struct linux_pause_args *args) return (kern_sigsuspend(td, sigmask)); } -int -linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap) -{ - stack_t ss, oss; - l_stack_t lss; - int error; - - memset(&lss, 0, sizeof(lss)); - LINUX_CTR2(sigaltstack, "%p, %p", uap->uss, uap->uoss); - - if (uap->uss != NULL) { - error = copyin(uap->uss, &lss, sizeof(l_stack_t)); - if (error) - return (error); - - ss.ss_sp = PTRIN(lss.ss_sp); - ss.ss_size = lss.ss_size; - ss.ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags); - } - error = kern_sigaltstack(td, (uap->uss != NULL) ? &ss : NULL, - (uap->uoss != NULL) ? &oss : NULL); - if (!error && uap->uoss != NULL) { - lss.ss_sp = PTROUT(oss.ss_sp); - lss.ss_size = oss.ss_size; - lss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags); - error = copyout(&lss, uap->uoss, sizeof(l_stack_t)); - } - - return (error); -} - int linux_arch_prctl(struct thread *td, struct linux_arch_prctl_args *args) { diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c index 7fa061f750c6..926c69c9ebac 100644 --- a/sys/amd64/linux32/linux32_machdep.c +++ b/sys/amd64/linux32/linux32_machdep.c @@ -549,34 +549,6 @@ linux_pause(struct thread *td, struct linux_pause_args *args) return (kern_sigsuspend(td, sigmask)); } -int -linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap) -{ - stack_t ss, oss; - l_stack_t lss; - int error; - - if (uap->uss != NULL) { - error = copyin(uap->uss, &lss, sizeof(l_stack_t)); - if (error) - return (error); - - ss.ss_sp = PTRIN(lss.ss_sp); - ss.ss_size = lss.ss_size; - ss.ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags); - } - error = kern_sigaltstack(td, (uap->uss != NULL) ? &ss : NULL, - (uap->uoss != NULL) ? &oss : NULL); - if (!error && uap->uoss != NULL) { - lss.ss_sp = PTROUT(oss.ss_sp); - lss.ss_size = oss.ss_size; - lss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags); - error = copyout(&lss, uap->uoss, sizeof(l_stack_t)); - } - - return (error); -} - int linux_gettimeofday(struct thread *td, struct linux_gettimeofday_args *uap) { diff --git a/sys/arm64/linux/linux_machdep.c b/sys/arm64/linux/linux_machdep.c index cfb2fd60e44c..eff084eb9f96 100644 --- a/sys/arm64/linux/linux_machdep.c +++ b/sys/arm64/linux/linux_machdep.c @@ -56,7 +56,6 @@ LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE); /* DTrace probes */ LIN_SDT_PROBE_DEFINE0(machdep, linux_mmap2, todo); -LIN_SDT_PROBE_DEFINE0(machdep, linux_sigaltstack, todo); /* * LINUXTODO: deduplicate; linux_execve is common across archs, except that on @@ -124,15 +123,6 @@ linux_madvise(struct thread *td, struct linux_madvise_args *uap) return (linux_madvise_common(td, PTROUT(uap->addr), uap->len, uap->behav)); } -/* LINUXTODO: implement arm64 linux_sigaltstack */ -int -linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap) -{ - - LIN_SDT_PROBE0(machdep, linux_sigaltstack, todo); - return (EDOOFUS); -} - int linux_set_cloned_tls(struct thread *td, void *desc) { diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c index 610bd7916689..786bcab2bf5e 100644 --- a/sys/compat/linux/linux_signal.c +++ b/sys/compat/linux/linux_signal.c @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -184,6 +185,37 @@ linux_do_sigaction(struct thread *td, int linux_sig, l_sigaction_t *linux_nsa, return (0); } +int +linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap) +{ + stack_t ss, oss; + l_stack_t lss; + int error; + + memset(&lss, 0, sizeof(lss)); + LINUX_CTR2(sigaltstack, "%p, %p", uap->uss, uap->uoss); + + if (uap->uss != NULL) { + error = copyin(uap->uss, &lss, sizeof(l_stack_t)); + if (error != 0) + return (error); + + ss.ss_sp = PTRIN(lss.ss_sp); + ss.ss_size = lss.ss_size; + ss.ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags); + } + error = kern_sigaltstack(td, (uap->uss != NULL) ? &ss : NULL, + (uap->uoss != NULL) ? &oss : NULL); + if (error == 0 && uap->uoss != NULL) { + lss.ss_sp = PTROUT(oss.ss_sp); + lss.ss_size = oss.ss_size; + lss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags); + error = copyout(&lss, uap->uoss, sizeof(l_stack_t)); + } + + return (error); +} + #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) int linux_signal(struct thread *td, struct linux_signal_args *args) diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h index af7bb554b340..7fed468239a8 100644 --- a/sys/i386/linux/linux.h +++ b/sys/i386/linux/linux.h @@ -257,7 +257,7 @@ typedef struct { } l_sigaction_t; typedef struct { - void *ss_sp; + l_uintptr_t ss_sp; l_int ss_flags; l_size_t ss_size; } l_stack_t; diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c index b2628738728f..1a51b7954063 100644 --- a/sys/i386/linux/linux_machdep.c +++ b/sys/i386/linux/linux_machdep.c @@ -517,34 +517,6 @@ linux_pause(struct thread *td, struct linux_pause_args *args) return (kern_sigsuspend(td, sigmask)); } -int -linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap) -{ - stack_t ss, oss; - l_stack_t lss; - int error; - - if (uap->uss != NULL) { - error = copyin(uap->uss, &lss, sizeof(l_stack_t)); - if (error) - return (error); - - ss.ss_sp = lss.ss_sp; - ss.ss_size = lss.ss_size; - ss.ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags); - } - error = kern_sigaltstack(td, (uap->uss != NULL) ? &ss : NULL, - (uap->uoss != NULL) ? &oss : NULL); - if (!error && uap->uoss != NULL) { - lss.ss_sp = oss.ss_sp; - lss.ss_size = oss.ss_size; - lss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags); - error = copyout(&lss, uap->uoss, sizeof(l_stack_t)); - } - - return (error); -} - int linux_set_thread_area(struct thread *td, struct linux_set_thread_area_args *args) { diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index d312e7e9003e..15fec674f8c5 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -437,7 +437,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) frame.sf_sc.uc_flags = 0; /* XXX ??? */ frame.sf_sc.uc_link = NULL; /* XXX ??? */ - frame.sf_sc.uc_stack.ss_sp = td->td_sigstk.ss_sp; + frame.sf_sc.uc_stack.ss_sp = PTROUT(td->td_sigstk.ss_sp); frame.sf_sc.uc_stack.ss_size = td->td_sigstk.ss_size; frame.sf_sc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) ? ((oonstack) ? LINUX_SS_ONSTACK : 0) : LINUX_SS_DISABLE; @@ -747,7 +747,7 @@ linux_rt_sigreturn(struct thread *td, struct linux_rt_sigreturn_args *args) /* Call sigaltstack & ignore results. */ lss = &uc.uc_stack; - ss.ss_sp = lss->ss_sp; + ss.ss_sp = PTRIN(lss->ss_sp); ss.ss_size = lss->ss_size; ss.ss_flags = linux_to_bsd_sigaltstack(lss->ss_flags);