From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7A03C52D7B for ; Wed, 14 Aug 2024 15:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=eyfCx3fw00t3hytVvFnb/phTt7zi8oUpxoYCyDVw8Kc=; b=BOzw29q2iJzfFPviwoaqqZuYXL gpaxQmCflUG1z1uV/RVUMJ7o7diIez3dj3LJsV360dX6GlHeh3jigv4e81tNddUNOcw7sWHLMW+T8 c0vs1sD48r+EPDKbUi0N/9oKJURiXCT3OEQsOoZf9rB1jPml8kzclapv6k4xMbZ0nP6GcwxSotn1F ZrzefIbp1G3aTLSXCdsltX0P0+xl+ixMDemV/c7ZWQtziI1DYA//QMD8TaNA2yQrfR6ldxgxkiU2y as8WZ+1/QMYhSjGzRdL+TkNt36SeZHNseDrYbe4URaOuiFYt4uliTGg8X4MEiozMf1f77prp3Xhma QnuqM2/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFYJ-00000007PlN-2Tio; Wed, 14 Aug 2024 15:04:43 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFXh-00000007Pfl-0CBn for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Aug 2024 15:04:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=eyfCx3fw00t3hytVvFnb/phTt7zi8oUpxoYCyDVw8Kc=; b=T31tTXC56JQgzZegOou60/24dI NA7D52J/cbjwP+mFSgICU9CULCTcrWsL6AOEccNfqHuqfITKKFUve+OI8Ym9cYDD+f03nIR+6ZbjG /7OY6XDMRUDr2dsd7/BvXsgIqBnXs3/lPZ06rV3hpyIZVLyO5p2JuQK4Srlzt5vwjB2AKErk2ButK hqenguhHzzOrHIChS8Zkbit4ckb+NgjGUql/WCMMgYr89odTC60ewMWlbAWvUYcJT2gUGqWrI7oRk saeq3mwtzBH5Fe4ZlJYU/uru1Fff+r4afLsTvv82PDofEHfrgijg8aAbFb8H40cjA4qBPBqR+WPw6 EJrRCjSA==; Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFXc-000000085FB-1b1m for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 15:04:03 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 08353CE1A16; Wed, 14 Aug 2024 15:03:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 727D4C4AF0A; Wed, 14 Aug 2024 15:03:49 +0000 (UTC) Date: Wed, 14 Aug 2024 16:03:47 +0100 From: Catalin Marinas To: Joey Gouly Cc: Dave Martin , linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: Re: [PATCH v4 18/29] arm64: add POE signal support Message-ID: References: <20240503130147.1154804-1-joey.gouly@arm.com> <20240503130147.1154804-19-joey.gouly@arm.com> <20240801155441.GB841837@e124191.cambridge.arm.com> <20240806103532.GA1986436@e124191.cambridge.arm.com> <20240806143103.GB2017741@e124191.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240806143103.GB2017741@e124191.cambridge.arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_160400_765661_2F66DF20 X-CRM114-Status: GOOD ( 17.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Joey, On Tue, Aug 06, 2024 at 03:31:03PM +0100, Joey Gouly wrote: > diff --git arch/arm64/kernel/signal.c arch/arm64/kernel/signal.c > index 561986947530..ca7d4e0be275 100644 > --- arch/arm64/kernel/signal.c > +++ arch/arm64/kernel/signal.c > @@ -1024,7 +1025,10 @@ static int setup_sigframe_layout(struct rt_sigframe_user_layout *user, > return err; > } > > - if (system_supports_poe()) { > + if (system_supports_poe() && > + (add_all || > + mm_pkey_allocation_map(current->mm) != 0x1 || > + read_sysreg_s(SYS_POR_EL0) != POR_EL0_INIT)) { > err = sigframe_alloc(user, &user->poe_offset, > sizeof(struct poe_context)); > if (err) > > > That is, we only save the POR_EL0 value if any pkeys have been allocated (other > than pkey 0) *or* if POR_EL0 is a non-default value. I had a chat with Dave as well on this and, in principle, we don't want to add stuff to the signal frame unnecessarily, especially for old binaries that have no clue of pkeys. OTOH, it looks like too complicated for just 16 bytes. Also POR_EL0 all RWX is a valid combination, I don't think we should exclude it. If no pkey has been allocated, I guess we could skip this and it also matches the x86 description of the PKRU being guaranteed to be preserved only for the allocated keys. Do we reserve pkey 0 for arm64? I thought that's only an x86 thing to emulate execute-only mappings. Another corner case would be the signal handler doing a pkey_alloc() and willing to populate POR_EL0 on sigreturn. It will have to find room in the signal handler, though I don't think that's a problem. -- Catalin