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 EFF26CFC280 for ; Tue, 15 Oct 2024 09:59:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FF666B0082; Tue, 15 Oct 2024 05:59:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6AF696B0083; Tue, 15 Oct 2024 05:59:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59DD86B0085; Tue, 15 Oct 2024 05:59:24 -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 3C5986B0082 for ; Tue, 15 Oct 2024 05:59:24 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 04E2B1614B2 for ; Tue, 15 Oct 2024 09:59:13 +0000 (UTC) X-FDA: 82675388922.14.64372C0 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf01.hostedemail.com (Postfix) with ESMTP id AE50240009 for ; Tue, 15 Oct 2024 09:59:15 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf01.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728986204; 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=r+qS+vHPu3vvmtluIrNi5LqVMqt7qQEpT1xPhSXea6E=; b=H4kv+hCdMXdIzL6+CN3sdhqH9RL3u5+b31XyPie9oiyyiEadgp34tZYYSYqNBf4v/mI8fM Hxw/7tHOQ74V2nPUzr44v/y3dXp5qqSgRKrCdaV2k0W9BxdO76/qRWQuX5x6JY4Yz85MYi Q4bmVHnDciB5LCyn1sr2e46RMKWAyCc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728986204; a=rsa-sha256; cv=none; b=CCVT6fnHC/cTSxHSBXAed4GpwrEEPulPvyWdzAno6DKIs5QPEbprBNKHFF9XS5LWdosqBd eWdE2pSECkYu5CRa+sK3FZUYgxnNQBL1JVxTafNGok55fO7fDyY2DeGzCB3NHuwmkU/68j LPFjLTM9h6+qUV4f8nDkd0PMA/+vie0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf01.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@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 577591007; Tue, 15 Oct 2024 02:59:50 -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 A909B3F71E; Tue, 15 Oct 2024 02:59:16 -0700 (PDT) Date: Tue, 15 Oct 2024 10:59:11 +0100 From: Joey Gouly To: Will Deacon Cc: Kevin Brodsky , linux-arm-kernel@lists.infradead.org, nd@arm.com, akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, anshuman.khandual@arm.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, skhan@linuxfoundation.org, szabolcs.nagy@arm.com, tglx@linutronix.de, x86@kernel.org, kvmarm@lists.linux.dev, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v5 19/30] arm64: add POE signal support Message-ID: <20241015095911.GA3777204@e124191.cambridge.arm.com> References: <20240822151113.1479789-1-joey.gouly@arm.com> <20240822151113.1479789-20-joey.gouly@arm.com> <47e1537f-5b60-4541-aed1-a20e804c137d@arm.com> <20241009144301.GA12453@willie-the-truck> <20241014171023.GA18295@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241014171023.GA18295@willie-the-truck> X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: AE50240009 X-Stat-Signature: cjwismy4snza3wauoraj81p8r85shqxd X-Rspam-User: X-HE-Tag: 1728986355-512247 X-HE-Meta: U2FsdGVkX1/O51VPgrrZkBE/Etkv1GvasmkCbS8ufIGA5Av31XDnfEoG37sVkIhuQE7IQuXT4xbllgx+2kPfzNmLWgQOMifKtDYE/3w3ZhrflCoNQigLXUbiO4CoEJWSg4bpmZAqVu8Ezfbzi5tlSqGV+JKboF+Pi+17mAmPejnEl5JCw64Tb5LsNrlduZ0fJdap1m9zLYuPxo/2yAhrLZ32wqYUvCDMQFYoOH74+4NNipvrfHAXKEnS9M3VYGkvp1jAkioesAOvpUFThhj/dr0rrQemzeY0PFTcVFoOdffQisTuaK6TyVFsEmCLiJqblojBj6rIoAj4/+hQqnNb8qnUelWOHGNeBJrekhtVXqJ032heo7LulGd20UGQgOVQIYTkOa8Q291Srqfd39ToXT/Fv6lQygqhtkNVC+Y1izkSQrBTnByEmiTiUsXS5BCK0pjeLh/dcVJ24yqzDbV4QeqFTls0WBiX5wQTPpMw5dSzGpdjUbKNW1dTj/P4qFoWRsATtW5G6G+RcLRnmYrw9vdbxPGFNhSJ7RgPpduUFyixFiGoK4jE1Z2WboPuYGBL2aGvDnrc6ocDeXNYvW+26kPv/15www6464mormoakRrl8vieAGGpWUO2a86cxQGnb/LKT9lYtQMHjVTAZjXi4KaJJbI8rn1inRPY0OVKGd9k/p/XVnK3xRH5/T5qsVRO0qTr7xq8YRliXV/OU0Pgp45j8Psj2bEpzgl2qGlUVFh4dr/WZTJAICSag4WNPiAZMAj4UTzT2zlFRseAiZN9X2sUTB5KNBtXWcQa41MkfGlU1lbxvXziOIxrVni5NNwdqsDlwuxx0oecnF4XYV70Ljnmhhz2LT0DS91aHKf0rpqqHNlBP1KaG7ymgYNWSeAZMDd4HwDPcAnJHVrBMORWZ/iqHBfZuPeHLnlvh0kwN0lkXLHRQc6zthAjc8kms7cOVYogWczRq+wiB1yTqn7 K4ou2aYJ Cbu4rSu1OFOVSzIZU8RG4g+ce7+bjDP5zsQ16LtCSf7ITDgsICKazZdiWk3zu+yHYR1kTZ26te1ZDHm5eEB37dY3kk8fZevObaW9C5c/xNo1XTJ9YgwdF0Cmtc7QmZR/HliR3WPPYzYiITQinqGrBBZ4t6w== 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 Mon, Oct 14, 2024 at 06:10:23PM +0100, Will Deacon wrote: > Kevin, Joey, > > On Wed, Oct 09, 2024 at 03:43:01PM +0100, Will Deacon wrote: > > On Tue, Sep 24, 2024 at 01:27:58PM +0200, Kevin Brodsky wrote: > > > On 22/08/2024 17:11, Joey Gouly wrote: > > > > @@ -1178,6 +1237,9 @@ static void setup_return(struct pt_regs *regs, struct k_sigaction *ka, > > > > sme_smstop(); > > > > } > > > > > > > > + if (system_supports_poe()) > > > > + write_sysreg_s(POR_EL0_INIT, SYS_POR_EL0); > > > > > > At the point where setup_return() is called, the signal frame has > > > already been written to the user stack. In other words, we write to the > > > user stack first, and then reset POR_EL0. This may be problematic, > > > especially if we are using the alternate signal stack, which the > > > interrupted POR_EL0 may not grant access to. In that situation uaccess > > > will fail and we'll end up with a SIGSEGV. > > > > > > This issue has already been discussed on the x86 side, and as it happens > > > patches to reset PKRU early [1] have just landed. I don't think this is > > > a blocker for getting this series landed, but we should try and align > > > with x86. If there's no objection, I'm planning to work on a counterpart > > > to the x86 series (resetting POR_EL0 early during signal delivery). > > > > Did you get a chance to work on that? It would be great to land the > > fixes for 6.12, if possible, so that the first kernel release with POE > > support doesn't land with known issues. > > Looking a little more at this, I think we have quite a weird behaviour > on arm64 as it stands. It looks like we rely on the signal frame to hold > the original POR_EL0 so, if for some reason we fail to allocate space > for the POR context, I think we'll return back from the signal with > POR_EL0_INIT. That seems bad? If we don't allocate space for POR_EL0, I think the program recieves SIGSGEV? setup_sigframe_layout() if (system_supports_poe()) { err = sigframe_alloc(user, &user->poe_offset, sizeof(struct poe_context)); if (err) return err; } Through get_sigframe() and setup_rt_frame(), that eventually hets here: handle_signal() ret = setup_rt_frame(usig, ksig, oldset, regs); [..] signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP)); void signal_setup_done(int failed, struct ksignal *ksig, int stepping) { if (failed) force_sigsegv(ksig->sig); else signal_delivered(ksig, stepping); } So I think it's "fine"? Thanks, Joey