From nobody Mon Jul 18 17:06:21 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 4LmpJw4mn9z4WfSd; Mon, 18 Jul 2022 17:06:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LmpJw4G9yz3R1h; Mon, 18 Jul 2022 17:06:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658163984; 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: in-reply-to:in-reply-to:references:references; bh=0WHJZP3sWp2NEHiUnBaVgx/M2mO9wDJ4HHgSZurCbB8=; b=G6R/o8u5N5MTW1Z+DtPlcZ4/ojVWlQ1wF75mEH/ky/ZnoNgFO2KIrJBhUgYmEjHuZTEm6V 0O7CYD2Lx8a1wyOeh41v9zA2ue1zwUM9ROSvPFZDdMH5L1tA2rJCvcRim7uOprliKXQEnA mWBXhkaR2L3wA4tKkdlWd7rXDrwFBD8c8KC7XbdMu/vWvsUQCyl1Sr94bnFnxKkLMfdL+h 1Cij6dVrPvLnjVRjKJqbygi2HOIqRvfnwOv4zSBpm6qZDOjCiIVWozlPKVJOhjJzvEbodN bxeBzceOMVgKs9C95Ih4lKu6/MWFedI26466OwZKJlzurU8wlW/M6D8Pt5Mxgw== Received: from [10.0.1.4] (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4LmpJw02D2z1KJm; Mon, 18 Jul 2022 17:06:23 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <02b113ba-f61d-6498-4787-5c6f0223897c@FreeBSD.org> Date: Mon, 18 Jul 2022 10:06:21 -0700 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 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US To: =?UTF-8?Q?Kornel_Dul=c4=99ba?= , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202207181429.26IETi64019036@gitrepo.freebsd.org> From: John Baldwin Subject: Re: git: f6ac79fb12f3 - main - Introduce the PROC_SIGCODE() macro In-Reply-To: <202207181429.26IETi64019036@gitrepo.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658163984; 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: in-reply-to:in-reply-to:references:references; bh=0WHJZP3sWp2NEHiUnBaVgx/M2mO9wDJ4HHgSZurCbB8=; b=A9Po0scwnx503vyMVzP3bvyVjuUy6zjwNS0cd5/wK9Q/qv+kvkw8IDgMOPePz25CAHPgPj Zvd14RhoSWVdS6HKt8GU6H9Ux1x3v/J0lJr4Zh9aSi8fgCEjCfbq1ep7KLkOdYM8TKtEbL atIb7IU1bRhdNshgjKCbKrzBMSd6rCiKycRfwGSJcUjEPYEacHgf122plUQuC6QhxB6LXg AwYkaJ9iXZUZDrAmjF6NjNEKxfVcvujUjLWOivg28m2Bf7aYyXOtq/FPgcM3QdB+F7H1te jjAv22twg7h8degBE7BVg1sKx++p67WjVzeohUbkiR7FQVb3rk4FtGHpqTZ/Nw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658163984; a=rsa-sha256; cv=none; b=Aqey9kJYqqc3RVLur2haKF+KfdSXpyCmjH79bI8rzH/OtfHzAPnP1ESwYP2UEdnsYarpCo fFlfqUg+Mr/t68AvDZfxqL58aiQgnAIizE5sd7Pxxx/8a58IZS+tu0EJeq2+BpTIjv7Nd1 jUf49xN+abdMkfUTqswsCXfCG88odWANjvb4IwN8KvPKL2O+rGDf5SUbC/nmpP2rYatbAz lAVU6rdkDC++ShAJRGIV2ewGsPkeAmIjWCnpzwRAwgCSXrn/0vuqUteV7xhxQO0FhYG7vf 1Tatn15rYBTe49/ECYnQLDVxBVV7eED+RcU147l1+K+So4IXp+6b+goJaDI0XQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N On 7/18/22 7:29 AM, Kornel Dulęba wrote: > The branch main has been updated by kd: > > URL: https://cgit.FreeBSD.org/src/commit/?id=f6ac79fb12f3c7ad891849d6721a20a100f6a9a9 > > commit f6ac79fb12f3c7ad891849d6721a20a100f6a9a9 > Author: Kornel Dulęba > AuthorDate: 2022-06-02 08:45:54 +0000 > Commit: Kornel Dulęba > CommitDate: 2022-07-18 14:27:26 +0000 > > Introduce the PROC_SIGCODE() macro > > Use a getter macro instead of fetching the sigcode address directly > from a sysent of a given process. It assumes that the sigcode is stored > in the shared page, which is true in all cases, except for a.out > binaries. This will be later useful when the shared page address > randomization is introduced. > No functional change intended. In CheriBSD we have a local 'p_md.md_sigcode' (which could really just be a 'p_sigcode') that is a user pointer directly to the sigcode. This means, e.g. that exec_copyout_strings could set it to the address it copies a trampoline out to directly rather than duplicating the same expression in all the various sendsig functions. That is likely still a cleaner approach even for FreeBSD as it means the various places you just changed to all be duplicates in followup commits could instead just set p_sigcode directly in a single place for all arches (probably I would have exec_copyout_strings set it to the right per-process location for the shared page in an 'else' branch opposite the copyout of the sigcode). > diff --git a/sys/riscv/riscv/exec_machdep.c b/sys/riscv/riscv/exec_machdep.c > index 2d30ba9cb01c..d45e8b808f74 100644 > --- a/sys/riscv/riscv/exec_machdep.c > +++ b/sys/riscv/riscv/exec_machdep.c > @@ -416,7 +416,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) > > sysent = p->p_sysent; > if (sysent->sv_sigcode_base != 0) > - tf->tf_ra = (register_t)sysent->sv_sigcode_base; > + tf->tf_ra = (register_t)PROC_SIGCODE(p); > else > tf->tf_ra = (register_t)(PROC_PS_STRINGS(p) - > *(sysent->sv_szsigcode)); In particular, (to pick an example) this would mean that all these sendsig functions would instead just become: tf->tf_ra = (register_t)p->p_sigcode; And the logic for choosing between these two options would instead be in a single place in exec_copyout_strings() to control setting p_sigcode. -- John Baldwin