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 0C5CEC3DA5D for ; Thu, 25 Jul 2024 16:00:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F0266B0089; Thu, 25 Jul 2024 12:00:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A0A26B0092; Thu, 25 Jul 2024 12:00:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 767FF6B0093; Thu, 25 Jul 2024 12:00:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 5966F6B0089 for ; Thu, 25 Jul 2024 12:00:27 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 14C4B14117F for ; Thu, 25 Jul 2024 16:00:27 +0000 (UTC) X-FDA: 82378737294.23.A1C04D0 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf10.hostedemail.com (Postfix) with ESMTP id E8305C003B for ; Thu, 25 Jul 2024 16:00:24 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of Dave.Martin@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=Dave.Martin@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=1721923186; 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=bBCZbxfj/RAg6kPc6sgf9eGtuyv5QbReIjCPZC4cN3o=; b=AhHoYF1v4uZpoqvkuxij7T9QEuEF+/2wJx9uqCHVs/YVNURwoaJbixQ0xFdncux3CcSCUY zgRV7pC2hifAhLKALRA8VT+KYA3lKU99S1pKV2FN3WduzAzPlwhT3mqALmxMBKCNUHukEo 1URfd7dtDie01qNY6VP1maoSwt/A0AA= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of Dave.Martin@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=Dave.Martin@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721923186; a=rsa-sha256; cv=none; b=ny3DeMe8wV9xIUTVe52eFSZIzavE8H/o9J2zsZHaGoKMnzCUHzP2Ry5XwfY2NhiTSGgDc7 bHOo9dl/LINEC4naqn4YdC77dl+mxhlwzN0TljvmgpdsdCNk3EHMsMLmoi9r2ZKW1Fu53D s3SbSJPuDaT2kVecBqSLo4l5Kip2zEM= 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 B2F0F1007; Thu, 25 Jul 2024 09:00:49 -0700 (PDT) Received: from e133380.arm.com (e133380.arm.com [10.1.197.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3FE1C3F5A1; Thu, 25 Jul 2024 09:00:21 -0700 (PDT) Date: Thu, 25 Jul 2024 17:00:18 +0100 From: Dave Martin To: Joey Gouly 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: 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: <20240503130147.1154804-19-joey.gouly@arm.com> X-Stat-Signature: gnjb7o4yz746n3axktyyxnq4p7mg75f5 X-Rspam-User: X-Rspamd-Queue-Id: E8305C003B X-Rspamd-Server: rspam02 X-HE-Tag: 1721923224-704180 X-HE-Meta: U2FsdGVkX1+A86WgqLSybdB7y3mKELT3MJqLlPrjMkPW/mVivBF6aY9C65OEdTRURW2Np4h1kvQEuFaAkq4tX/MCnfmiEux3oF6Wj3aoW5KQtINn8vGi+cuTC1eCNvQ1MJb/rHOm16shVhekAh/aNveudngkIhDQdRN6mGfCIlM7j6BagNjvczqVOkTUilfBt82jnhAW3pe6Yb1bcmC2PCzgddDCfUi5zgpMd3mO+oag7Risr7IdIsKTIVUkXAuPTCOpquzEEJo/E0tmHpoVrz4kiwg4v3r1oOBFV3z221BCk1GkRl15Gf6JKVWLlohGZsaFZtjDxVHGnEnyY968F239JPV81jq2Zno6ww/Nk3U+Nom/hb95J/Gh65a0+qEou0Yyrm1T4ikiSCY8C3yXXN/fvwVh3gboCMDOh//23arAMiZmczkyQebVfjTNPKqI9b/rjHLDCF4X4w6zWFY9sJyjm8BvxGTMJ9ZPy1DqFR2KrFDFPX1ctudUCTQF6oatQQzyqB/vek3UhA9juE+VpNxmGby5XZFkHX4qvuMjtznTXJAC8NqagNPtm02PJOF+TjfTvm75jLD2uubiFJ1uMx1f2KMyiLXznDyio+DRuDkMq5Doq+Nj/LyGIXkbU8r5iiEH/NzMQ8M3hs0XVdZKWonPzcIRgWVWDoiEr/uwVGT5T4fBn0GZvJimGeeGUkwWgWQyQDv1BFY68zxDwSLCiGttQRmRaM8e3K2Wh7K0Dclfq5XAL8VRhV4/LJVV3qLNzKf90UX6w7Qwc7hw2j4aAwHjkz81gI5WfwjWBBjHGZeI8078w5J5BpqW/CkfoU+VVpwpOa0owacB3yJzo/H4MpVK7bizxqc/xcFA+yiY+dsWu8MQcfGQB1Sciy40tdQHZsCMtajg5WqmJB7NbOWpaVlddUXEq7fPgRkPfK8rDeskeUSyrJfA75Pi+CwytVq28PnnkThb1/CByzXFfJ0 b3sBEyPT Jxj7TPnJEhq23GKkYauuRFzcj6adeRXpo73tEXbpGmQlZb2e6ifAj30xMQh/JWxmAEAv6YYoJDNOP71fv8vMb7dZbXK18Vy4bZHWngZl0XRDRLN2QZe4JIncSWLcWSNZyWUBpzlixqpl/G5FQWjwcf+cy3cOkh7CSlyghzCBbJr8vY0+b1m23DYuEtGD5gRkc0cMUW7WZp8mirk9iHWm2LtWw3gzSDYK3Pbiz1jKC5Gg+G71Hx1l/dggXFOMTjyrXc2FkGM+DESMAXzg= 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, 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? 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. [...] Cheers ---Dave