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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 518F5C52D7B for ; Wed, 14 Aug 2024 15:04:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C6C406B0082; Wed, 14 Aug 2024 11:04:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF3D66B0083; Wed, 14 Aug 2024 11:04:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A94A06B0085; Wed, 14 Aug 2024 11:04:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8B1DA6B0082 for ; Wed, 14 Aug 2024 11:04:02 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0633C1A0FF4 for ; Wed, 14 Aug 2024 15:04:02 +0000 (UTC) X-FDA: 82451171124.29.0DB73B2 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf04.hostedemail.com (Postfix) with ESMTP id 985BB40017 for ; Wed, 14 Aug 2024 15:03:59 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of cmarinas@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723647744; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eyfCx3fw00t3hytVvFnb/phTt7zi8oUpxoYCyDVw8Kc=; b=UlDFFcCGHTHReUOgtc9k10ZIl7MdasycWwMUArbUUN+WtznlWxnxUuCNKhkXz4fajGHd+h lDACLreeJJvhQ2YMkXfIb/F967eldXThuHxWHeJQnDAFfDBQY4lMw8acb+ybDPRbyuimqW VpwvG7y9w+9joZtgAbNd7FAjHNYTj1A= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of cmarinas@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723647744; a=rsa-sha256; cv=none; b=3qtDTrIIuS5fJQcCvw/wE7l/I65LCv84Wzy9XZF2yakFr6GAcG5Zr9WaqDhL8yHZxMaMec Pc4G/+W1lUQ5w7WjGwciU18vxN/861sO4geieRLGVM4ix/6dsUz8D7BjXNqOvrHcJ4Pjyq EZR0fDli+8Plh+++RXsNaEKJuDTHfag= 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-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 985BB40017 X-Stat-Signature: mu17n4yxk5torsoramx31uua49q3at1q X-Rspam-User: X-HE-Tag: 1723647839-194051 X-HE-Meta: U2FsdGVkX1/WssMjfMwJAMDYAhEESEvq/WPk67eqy4EnUmHmDJ05C42zMoFGKCcgfRhgfjv5SThODQDM2O95ZckqfC9YvA9THI1awOB+bnaEbjRSfnoG+2tO9wp9dD3YgPZ8fLiLOF3qhxc3B3AsCiVgtkarQHsljXylHxw5h7UHHtwHBHhMNr3zIm0bzzFdne8W8NsublbTE0ysyrzBXkIySVHGpwvHkiSWOOiyevClooghY5s92V4G9HW9mAi8swyC84tEZb/VoDqgopoT4Nxzv6Fvz2BlsOeeULVKuwP7Lc5CJQQ/xo/ek5nyNDTyGZNwJxPIdJH6wdpmywwQQT0jSGXguz/uKLn78UOXBC/VDS01EnUp/SKON/+DQkV/XyiCGv6xrIkfX7/UYXvsOBLJ2EgKWqsFcIjhjQ2tdm2HecaLOqKht/RaNQICXKYTBzmSRGjGYmGB9CuYbHbaJ/PPeGTEDRbiMmedsZfccby+bMB13YC/eBsQbpjJ/cxJJDDFVPcGHKor3b+/f4pAA05FWq2JnD/8Ejl4fyfmNqqU+aViDNeblD07zVmWbLidWbFCLLbjKmWw4mJrWVqoP5DcCKOwtx+xE536OT41c8k+/TfdjgQjvCJDZCIA1DEIECruSgi1mexzyQay1VHBxBZlNjSDYANDMMZsR3RCpUdT2ZMTrcNhehl4uvg7lFiTxKfQVJmU1jXm5FIOHaT96Z5A62tz2MGV3xjPr+zwUsh04XUmqRfPuhaHcKaYEVj1YFlAWSAj1tXyO03biIfliKtLpi4j9a6UCJ4jjufDTZ6qnKRiI2VEXPob4319UcDTjSPHCCtezClwhM3ZsjkBO2epziksAb4s5YGoxXFwVNGUCrt5Qu9soa9KA5A0IUoPpsmdzGlt7wBsBlocWKwoTPpZQ3dp1Ha+yNTRKsrHcef84c7is/95wJX19DVvtyKZ1kKmr83TCqqelOa1Bug nhyiXEbt 1JbYVP508JEpApNeyi6BBb5Wnt4ktoeKq21JFkFQTydQpA5l7bjQMpdRsDvIWoUn0XIMhRJJHW07e/NPbFS7J9DTOCVNGTymhiC0C3ii7/pMrxNxdepKTDxlSxBjlo+PLDUzqems9XbXzY6dGCD8olOqORbTF1aWhpFaG6YBdQmYEumIw0lzXDP/5SuGKgar7C3FidufrayGJEwA1LBZ97G6dfSNRO3vrAX0CL9kvy4aJV4T3kkTxyPpZDlvvO+NMNWCuyyARlFQGBUHKA1wYvfs0d1XyxdvtRKmx1vyOV28HorMq1egyySPRwy+Axfs9HT9ynNVrrp9bZo9pKNUibGFQXIbscBeBqI7D X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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