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 0984ED37496 for ; Thu, 17 Oct 2024 14:00:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94C686B0083; Thu, 17 Oct 2024 10:00:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FB716B0085; Thu, 17 Oct 2024 10:00:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C3286B008C; Thu, 17 Oct 2024 10:00:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5DAD56B0083 for ; Thu, 17 Oct 2024 10:00:46 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6A8E61C5236 for ; Thu, 17 Oct 2024 14:00:33 +0000 (UTC) X-FDA: 82683254556.23.81F2481 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf05.hostedemail.com (Postfix) with ESMTP id 86037100029 for ; Thu, 17 Oct 2024 14:00:24 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf05.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729173536; a=rsa-sha256; cv=none; b=MEj+q4Uo4h9Sd2VLAJa+Kntlf8iMC4ArZ6ZjKpRTdYwp13Q22CKgpzZthKwyO/G5OAWGmm OpUvN6a4U/MG01gCuz0NaTvfo/rAOmaqbZAprZb39qC0NZRo3WXxP6pFvRfG9nVfOWblNY UG78fbIaU914q9/R3SKfUEc0g7cNPFk= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf05.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729173536; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nZuVhJis95dVNimUHudHNvGiNmLlOJXRRB+4qzPMuVc=; b=fDh8iKe0ixUR0YyiTAo5tpvBpYwCLt3VmmU1jAneCLp/Jq1sPzg4m2vyB3HFCDT0E2zhRn NhUg6G/+hgaUwYfEmphdM/ky1CUmqfqa5+LE+Uwv9aVy1fFuql+jhED8hRlNAITXOsf5qK jnzkOdlqZ3MW9j4TUF4418OVK59XxHE= 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 AE2BEDA7; Thu, 17 Oct 2024 07:01:11 -0700 (PDT) Received: from [10.57.78.172] (unknown [10.57.78.172]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4F7AB3F528; Thu, 17 Oct 2024 07:00:35 -0700 (PDT) Message-ID: Date: Thu, 17 Oct 2024 16:00:33 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 19/30] arm64: add POE signal support To: Catalin Marinas , Will Deacon Cc: Joey Gouly , 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, 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 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> <20241015095911.GA3777204@e124191.cambridge.arm.com> <20241015114116.GA19334@willie-the-truck> Content-Language: en-GB From: Kevin Brodsky In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 86037100029 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: hioh58xotwgjk61ry3r5i7jswcdmtq8f X-HE-Tag: 1729173624-728214 X-HE-Meta: U2FsdGVkX19OPqe8JoOxZ+feHl3VYapD0zAAovZDlG8RcdpUSoOb4mq8SwKOux0LdlOe1FQlGv5tGlVqqksZiRblkziQGL3adOfVHvPSqMglsc6edQ4tbodOkDALSLC2VDU1tG2aiFU7cqYiVFxhF+ZxzFmbie7G8vCVfgfO5FDcRstOS9ebq3Cdu8no9OHAU7zznr5SH9lG0ZKkrd7uGKlqbcHayaoPa1ubblOIdqR7YQsCnEd1dLHQ7miKFcYSZzyYbwTgbJrVzHuExyXw/N2grWc6DXfAQTzltABH45IR1XxtxwlC2HFM31zYnYtron3pW7OMa/QwxRfzVP/DJWWNV3HJw2c8vC7U6UezJyJ4D0JyQeLoJyLZyFuxd4wu7UdtBf3NTvGCTNtncUKaHYm5Erpwj0cBonTkiNffTmF6A74rOF8ue3eyf0aEM4hhx0cCap5o1m7J5va1xu2cruH+OaZsVtw56c8utw2tA8YBWabVGfWahzM4pSdm3e0JU4NVimjRvNuZqqIjlAijsLchlDXKK+fAE2YbxJosDYAjDl2Rfy5H1Rvchcrv2E1cTA+f0ALkVW9WyYNQAY+4g6yMPooH2+3KkTcNkKhRvqI46BzovGvSKrNfXZRcLJhnCGynGMrWyMYpnt7JRX7MHQLLV6nA2d60eRtCLvDFbVx7klwMYfd21lb04tTWIs3U2sAJZuteH71mPFav8TNNzVoRQLi5jTjbOKEftIgnyOmaJEen54QbU5ADJfZpO7Xtn2bmhvIms+EHz6ByHmT8TN61nVZW3XSeRQ6+cl0MM4lDxkespWUMt6sYnJPUENA1jJgrEhFK8jUFTofHWjY7d3OVs21sOl+DwauRhm1PowsAZzaU4v0aeH/2dvvv0sXB6rfJ0uVcF/xrp/b96TMpxj0eNgtJ2/5V3kUq74iY24GgVqn8UuuXIWjk+NSwtPby7gBKyNUmTrSv9pOix9G GGOBxZhp uuLMTHOFd6iWd4j9qV1bH1FD+6V2Evwn1ZbPlHcd5vcxxIJQP8HciecvHwRwh4tTTVMZsCioEqkozd6+n72ZRuf+qRSZJfoVTcG+R6hVRuIeWoG/w4riJXskUSPHXDbJJ4w4Trv5q6mzTurC9n0A+61yRJlcrb15pnEWMCfNNryB7qCjz7ekxIZt2H8gpT/7W7ua5iCEDLlqdOFv2WXBiLFvg3nL7G4+b2b9b 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 15/10/2024 17:01, Catalin Marinas wrote: >> We also still need to resolve Kevin's concern, which probably means >> keeping the thread's original POR around someplace. > If we fail to allocate context for POR_EL0 (or anything else), we'll > deliver a SIGSEGV. I think it's quite likely that the SIGSEGV will also > fail to allocate context we end up with a fatal SIGSEGV. Not sure the > user can affect the allocation/layout, though it can change stack > attributes where the frame is written. > > Assuming that the user tricks the kernel into failing to write the > context but allows it to succeed on the resulting SIGSEGV, POR_EL0 > wouldn't have been reset and the SIGSEGV context will still have the > original value. I don't think we need to do anything here for 6.12. > > However, in for-next/core, we have gcs_signal_entry() called after > resetting POR_EL0. If this fails, we can end up with a new POR_EL0 on > sigreturn (subject to the above user toggling permissions). I think this > needs to be fixed, POR_EL0 only reset when we know we are going to > deliver the signal. In the series I've just posted [1], POR_EL0 is reset to "allow all" before we do anything, so it sounds like we may have a problem there. However, it does keep track of that state, so I think the fix may be simple. If any error occurs in setup_rt_frame(), we could call restore_unpriv_access_state() to restore the original value of POR_EL0, like in sigreturn(). Otherwise we call set_handler_unpriv_access_state() to set POR_EL0 to POR_EL0_INIT as we do today. I can make that change in v2 if that sounds helpful. Kevin [1] https://lore.kernel.org/linux-arm-kernel/20241017133909.3837547-4-kevin.brodsky@arm.com/T/#u