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 8DD67C3DA59 for ; Tue, 16 Jul 2024 11:41:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 068D46B00B1; Tue, 16 Jul 2024 07:41:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 018336B00B2; Tue, 16 Jul 2024 07:41:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E48EC6B00B3; Tue, 16 Jul 2024 07:41:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C6C696B00B1 for ; Tue, 16 Jul 2024 07:41:08 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 75527804D1 for ; Tue, 16 Jul 2024 11:41:08 +0000 (UTC) X-FDA: 82345424616.19.E29F6E3 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf28.hostedemail.com (Postfix) with ESMTP id 6ACD8C001F for ; Tue, 16 Jul 2024 11:41:06 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf28.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721130023; 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=lqjE0jWOrhYT2jZSFx8geZtOnUjGfNcPTMchXoKzX8I=; b=DE4wqH0NASy0mgnZYWTPndzXdAlVfF/u5yFWl6NyYlHR5HnS+xWBPyjuysws7tecyOdEx4 BuN+pilgWdjIsOwijVgUDycx4FG53aMSWbNsoktnIeqNaNuyL8E4Zknq/k/TVhutdEvRww ZDlxvH3X5PtiVrShqob9AHGk8uC2v/Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721130023; a=rsa-sha256; cv=none; b=13RqpNTuFOavOVR/9yPaw2pYmtATfQQJdfIqe/3zSskev5IO/KDk8T4SlSsyMid2QQBlJO pnK6Iz8DOx+wbScwVq/y1sOtdEuPQZ/U2RaAvMVaJuSLsrCDi7tj/LHfKDiN9O5bEPY/Xl hihGoDG5xmnkgm91M1EzOUti6S1H0V4= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf28.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@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 B19091063; Tue, 16 Jul 2024 04:41:30 -0700 (PDT) Received: from [10.163.52.225] (unknown [10.163.52.225]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BB35A3F766; Tue, 16 Jul 2024 04:40:54 -0700 (PDT) Message-ID: Date: Tue, 16 Jul 2024 17:10:50 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 17/29] arm64: implement PKEYS support To: Kevin Brodsky , Joey Gouly , linux-arm-kernel@lists.infradead.org Cc: 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 References: <20240503130147.1154804-1-joey.gouly@arm.com> <20240503130147.1154804-18-joey.gouly@arm.com> <18aee949-7e07-45e1-85c8-c990f017f305@arm.com> Content-Language: en-US From: Anshuman Khandual In-Reply-To: <18aee949-7e07-45e1-85c8-c990f017f305@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 6ACD8C001F X-Stat-Signature: qbrpytab41hwwrswie99za4azygx81f7 X-Rspam-User: X-HE-Tag: 1721130066-879683 X-HE-Meta: U2FsdGVkX18+6BvnwPRiCyDk78jnPogS++4pewaNvoHqNdgPks+9B/0iZ05irPr8hv1U8hhSKt5ZctirGEQBK296xTmfwsdo+8NnSbkfom82glG5mOJUUgS6Wgxnhd+1Hv/TQ4QWbGmd4bSzNZ2acdiTD7IPT3IlDlyFfQWVZ2lxEVEZZKMSt3FaVjss2olJnaV78E5xGgfKeJtS1x7sYCxV2B5TmQ5KLfvk1N5OBXxqHD+Av7X7xt1gCdxZQM+JDQtSU5nqMlCD7fkqKPQUpaYxCiwDMnBz/Bi7bQefXQbjtEMYpMnyQ9WZEg53ILRxlogROSmhldQwlHc5n8/cyKeFxRmjzA9j3puLOZfEopQWOGHcxKpkpoaq1Pwiw9V3ydCa8dpya/C2Ovya7hphMkyKgJXO0k1XnUJjOMxT2kRKWJM6wnZBZ+tpg1yzYqCA5truuWm1Shs5nT82B0h+tVR3gmcDD5lzu64l1PeKcbxgrufiFGc/g4DAyuEsSFvtDUmFykYUajrvf6NQ9BXJYWj8q8m1PdnYloCRTFdcIW2s1Bc3ZvmMznRZDLrbmHefWmcjXL7MY8EHPMz7MV+tgiag4VUtHMMYy0slZQRzNvpK1vbr706NYd9oTUMVxF2HrQSsdTdEPAxggEVPufE0Tx9RS3Kas5KfgDkWDjpym8OZKzXNCfuCioJilc9xftDyM3Dq9IAXkFOy9jYts+MUaSvi7lFYQTJu4fnSoUVcJi+1cxwRtTYKd570QLwrdxq+oeLSbmQlO1gLS1fIjZhPda0Ir9W2/VHKXUELbwfw3/kAHJugtP20rTw3/5AAftvWGNRdjPS3/epHU4Ga1XU8svdrxqBWEwO2oldj6PpGaxeU+sS49z/1jyFPSp9ANlSwy47gRrdoRjRa7LbDATmJF4tHLotREdbgBWIHu0w4tHKshH8MYxNKfbbjIqShlI+6oCUH+CXwmlaIGRY4x2G IY3tTs/a 81XAePegdTFb+XaM59ly+oHHPPhsrgG+nlpibr8p0vHULwGM6gyCIefHVFGW52uNS0Lx9Yb4F26AWMqJy3r0Yyp1Tt40x1ejbgD1a4wPchRzoxWNGEtXsZKheJ//HsiqQOhAFfHhzNO2hpocaNs5BV9pCLQ== 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 7/9/24 18:37, Kevin Brodsky wrote: > On 03/05/2024 15:01, Joey Gouly wrote: >> @@ -267,6 +294,28 @@ static inline unsigned long mm_untag_mask(struct mm_struct *mm) >> return -1UL >> 8; >> } >> >> +/* >> + * We only want to enforce protection keys on the current process >> + * because we effectively have no access to POR_EL0 for other >> + * processes or any way to tell *which * POR_EL0 in a threaded >> + * process we could use. > > I see that this comment is essentially copied from x86, but to me it > misses the main point. Even with only one thread in the target process > and a way to obtain its POR_EL0, it still wouldn't make sense to check > that value. If we take the case of a debugger accessing an inferior via > ptrace(), for instance, the kernel is asked to access some memory in > another mm. However, the debugger's POR_EL0 is tied to its own address > space, and the target's POR_EL0 is relevant to its own execution flow > only. In such situations, there is essentially no user context for the > access, so It fundamentally does not make sense to make checks based on > pkey/POE or similar restrictions to memory accesses (e.g. MTE). Indeed this makes more sense. There is no memory context even if there is access to another POR_EL0. The comment above could be improved describing this limitation.