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 40507C3DA64 for ; Thu, 1 Aug 2024 15:54:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C14C46B0089; Thu, 1 Aug 2024 11:54:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BC4306B008C; Thu, 1 Aug 2024 11:54:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ADA116B0092; Thu, 1 Aug 2024 11:54:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8E9B46B0089 for ; Thu, 1 Aug 2024 11:54:50 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2F219C0F23 for ; Thu, 1 Aug 2024 15:54:50 +0000 (UTC) X-FDA: 82404124740.06.FE0CFC1 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf02.hostedemail.com (Postfix) with ESMTP id 75D3380022 for ; Thu, 1 Aug 2024 15:54:47 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722527631; 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=h2SDq/cICAt+FRnPLZBGA/FC4H3alooBkj7GfHPMhGE=; b=IdpDLOm5R5PkcyfEVnmBWW+LPEXScbhH4zdlO6k8FTHQzo9884Cs/n14S+b7q2H83ruLzt CTgB7+kk7zQYlaqT0lfejDsiOtz9dhbcm7ppOsbnbpb8fAdpDTF/dQyN6ux60qPRdQeuX5 UTfZGWoZk9w/0zWm/ueEizMsAP8zLXE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722527631; a=rsa-sha256; cv=none; b=KD+Xp2gb5K7zXwjZskJ3P7p81JNvjAOUC3tDOsM+vhVKY1/qNv+Q4JyHQVg4J6x8FFPEqV JiE8WpGNVwMbQdHRT/QTHodpbP+pBiP+H1fU54/j6bDozv4JdEdLGFd3Q+RP3h0ctzcM3G 80EMydFlpD67EcoIJTks2LwofdpH+kQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EB88115A1; Thu, 1 Aug 2024 08:55:11 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 33D933F5A1; Thu, 1 Aug 2024 08:54:43 -0700 (PDT) Date: Thu, 1 Aug 2024 16:54:41 +0100 From: Joey Gouly To: Dave Martin Cc: 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, catalin.marinas@arm.com, 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: <20240801155441.GB841837@e124191.cambridge.arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> <20240503130147.1154804-19-joey.gouly@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 75D3380022 X-Stat-Signature: 65p1bfwgjj69rr5htjoepood4rhc44y4 X-HE-Tag: 1722527687-37527 X-HE-Meta: U2FsdGVkX1+qSA3QrOal/shKIOZk8U4T6WIJL8/HHF1DpiOV03WYpu8VHitywBP7CGI0+WzWLHHiNtSpdIiVISDQO4UiV45MRhSgx9S12jqxB3bkhOljfukF62KOvK7FewtpnMnVOWFPqr4rbFxniILLy9J2i7pFD/7ZW1hxV1jvtkjgG0gIiZf3DCZV6PMxlgckAr0MFx11B0eiaT2jwt+m74jYFVNbt1sjnxiX1UDbvh/qjiG7kQSxdJJ8tzE/clZD0mPFDOJyCYj00V3EalG8pn2DwAj44kpteG30YZthKmdQSUjaKJK+wZZKqV5yjZHeE0T99ciInQPSHXdn69QLdSsts6Z7Tw3K2cG3VGscPxsu3BmHsYw9AT9oWEcUqQqElVoH0yPEFmc5r4zPTSIve9yDh3uC0itRNOkrwiehzHlPJiaRzWPig3pzYuid8EtZvCmwS2JObqx94NEvVsvoVYwoZVFvtQ8eKxd2mjKjtVr+Otrt7eJNNesUoLxSSP7tU2MtfL8Tq8vO29qJMVTb6a/4vXWaX8KMh10cfwgIF8pry3kDN0cGjkrrWqcxS2W+BjVZVfGF979gMcmXUUSC92LnRTBWKJy8XnpVYxhcnRKkeWKYOya2xJDhI49egRKlxgCpXi3rdm4TVMlLcylxfQcj3WLa1TejM4hX677w8DzDFTaTKQBgZyx9oahDf4jjzgIAMWIIDg8spcUSPFR3/Jjfc+bFg/7eoJxW0IUwelPPe4KSdhp6+EHQpSyHVvXh/k0nEhQ3Mw3a9KztdrbLq3x3AGACwE6LyL8SHRM8PAbVymOJHWXMCYHFaqrIClzpSzNA+ZYTRAEBFLyR9pieBkppVKVl43/KzKv9SGLg1mBnTuLjcgegFOwMvpTVODhwAyCr9Z29sTw2LGcJDa9AtvtRs6xopvlWh+7Xz8N9pQMt0Di5IAip/6biRGs1GAs9jaeKYoLdEp/uDSn DklDtJiZ G/hc467uV9iWWqShv/YwcQKTK4D1EvjiVrWo5OjQ7dQ3aSWRAXidFA+ARHj5igh91qHW058pzKiecHyUCl4Yv3+GZ6R+zYUcSfGH6p5ulRsAQcPHnmbHcXbe0TMj7bXWBmbQ6cdJlwi5xZRcqK1h1iD3KojBCbJEBRTIyBTio+tIoGFsamD1poHhJECMkZFf8bIsvS8InInj+zKyk1WZAJbNWdXM9qoJrlOsD780jBjTlk1hIQY6pNWPzDYi0TOcwpFsmCiqlMvUUKTY= 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: On Thu, Jul 25, 2024 at 05:00:18PM +0100, Dave Martin wrote: > Hi, > > On Fri, May 03, 2024 at 02:01:36PM +0100, Joey Gouly wrote: > > Add PKEY support to signals, by saving and restoring POR_EL0 from the stackframe. > > > > Signed-off-by: Joey Gouly > > Cc: Catalin Marinas > > Cc: Will Deacon > > Reviewed-by: Mark Brown > > Acked-by: Szabolcs Nagy > > --- > > arch/arm64/include/uapi/asm/sigcontext.h | 7 ++++ > > arch/arm64/kernel/signal.c | 52 ++++++++++++++++++++++++ > > 2 files changed, 59 insertions(+) > > > > diff --git a/arch/arm64/include/uapi/asm/sigcontext.h b/arch/arm64/include/uapi/asm/sigcontext.h > > index 8a45b7a411e0..e4cba8a6c9a2 100644 > > --- a/arch/arm64/include/uapi/asm/sigcontext.h > > +++ b/arch/arm64/include/uapi/asm/sigcontext.h > > [...] > > > @@ -980,6 +1013,13 @@ static int setup_sigframe_layout(struct rt_sigframe_user_layout *user, > > return err; > > } > > > > + if (system_supports_poe()) { > > + err = sigframe_alloc(user, &user->poe_offset, > > + sizeof(struct poe_context)); > > + if (err) > > + return err; > > + } > > + > > return sigframe_alloc_end(user); > > } > > > > @@ -1020,6 +1060,15 @@ static int setup_sigframe(struct rt_sigframe_user_layout *user, > > __put_user_error(current->thread.fault_code, &esr_ctx->esr, err); > > } > > > > + if (system_supports_poe() && err == 0 && user->poe_offset) { > > + struct poe_context __user *poe_ctx = > > + apply_user_offset(user, user->poe_offset); > > + > > + __put_user_error(POE_MAGIC, &poe_ctx->head.magic, err); > > + __put_user_error(sizeof(*poe_ctx), &poe_ctx->head.size, err); > > + __put_user_error(read_sysreg_s(SYS_POR_EL0), &poe_ctx->por_el0, err); > > + } > > + > > Does the AArch64 procedure call standard say anything about whether > POR_EL0 is caller-saved? I asked about this, and it doesn't say anything and they don't plan on it, since it's very application specific. > > > > In theory we could skip saving this register if it is already > POR_EL0_INIT (which it often will be), and if the signal handler is not > supposed to modify and leave the modified value in the register when > returning. > > The complexity of the additional check my be a bit pointless though, > and the the handler might theoretically want to change the interrupted > code's POR_EL0 explicitly, which would be complicated if POE_MAGIC is > sometimes there and sometimes not. > > > I think trying to skip/optimise something here would be more effort than any possible benefits! Thanks, Joey