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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47E2FCD5BD2 for ; Tue, 26 May 2026 11:18:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8CKL7Kj0ZKCAU5/OJ/IEB4gg5W1BVxeMyN3Ks5LfDco=; b=AoVzb0MWfCkqzktUmGQE4RpJho kwCBhj3ffj3pS4yfk42Qm96mDdlfSUusnFBXINqHXgrH9NaPUBVhsfvidw+yesjxXUV10e0s8pljE 6BxijpeWigHkRF3NNKsQ4pWs1CvrEURTUscMr9Fn5dG0YMrtXzzLK1DVgHR+mnyQxB7oKcTfZCfV1 IuLtzxS7mqs4owQhEQULUVc5TAu/Lr8MQwM0xNqOZIrIcE1Zo6kzxH40iTX5WzVyfANP2HjVxv4VJ jcZT7COCW96d7Kd2uQPTtIJ4tsXdEHmaF2RYyWnwkuyqtCBBrQnudDYsHkXTLJDEO0KwVyImna+Ud JTYXWlFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wRpnu-00000001lFS-0FK3; Tue, 26 May 2026 11:18:34 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wRpnm-00000001l98-3KOu for linux-arm-kernel@lists.infradead.org; Tue, 26 May 2026 11:18:28 +0000 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 E96A2169C; Tue, 26 May 2026 04:18:20 -0700 (PDT) Received: from localhost.localdomain (e123572-lin.cambridge.arm.com [10.1.194.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 27FF93F7D8; Tue, 26 May 2026 04:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1779794306; bh=Ksvs4ETYtArM4OpjEpTgUeDGNdsc/o015KS8Xfe06BU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=f//46ng0yqzXyYbz5KWfhQJnZiDBCx6Rl/sbBf8Rff2ghq58j0APCVuPAndxPLwhu 2jLygnKRBglQjL5M/9SLsXH8i6qwBsm7E3JigQ5taE1rvTutuRf5ktw1U6+xar480t apzsdI4JWV3NqrH9OX/RukkpJJV/EsnBlMIaTfUk= From: Kevin Brodsky Date: Tue, 26 May 2026 12:16:06 +0100 Subject: [PATCH RFC v8 17/24] arm64: kpkeys: Support KPKEYS_CTX_PGTABLES MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260526-kpkeys-v8-17-eaaacdacc67c@arm.com> References: <20260526-kpkeys-v8-0-eaaacdacc67c@arm.com> In-Reply-To: <20260526-kpkeys-v8-0-eaaacdacc67c@arm.com> To: linux-hardening@vger.kernel.org Cc: Kevin Brodsky , Andrew Morton , Andy Lutomirski , Catalin Marinas , Dave Hansen , "David Hildenbrand (Arm)" , Ira Weiny , Jann Horn , Jeff Xu , Joey Gouly , Kees Cook , Linus Walleij , Marc Zyngier , Mark Brown , Matthew Wilcox , Maxwell Bland , "Mike Rapoport (IBM)" , Peter Zijlstra , Pierre Langlois , Quentin Perret , Rick Edgecombe , Ryan Roberts , Vlastimil Babka , Will Deacon , Yang Shi , Yeoreum Yun , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, x86@kernel.org, Lorenzo Stoakes , Thomas Gleixner X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1779794212; l=1216; i=kevin.brodsky@arm.com; s=20260427; h=from:subject:message-id; bh=Ksvs4ETYtArM4OpjEpTgUeDGNdsc/o015KS8Xfe06BU=; b=HOtK9mBM/YEa1W1AKAgO/LbBhIoiZcz/bGtMqz+cFwafME0nEaGnjIA7ihVVbSs2asa0ZyTDx aJfHsBOF6KCCH74QPffHPLJRZ8lklx5Qz5Ia1O7GPTzyisbDFDX3/df X-Developer-Key: i=kevin.brodsky@arm.com; a=ed25519; pk=N2QG+eJKrvkNovwhhwJhnJ4+ScVfsGCHldmqLfcMTFs= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260526_041826_882957_C24C29D2 X-CRM114-Status: GOOD ( 12.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Enable RW access to KPKEYS_PKEY_PGTABLES (used to map page table pages) if switching to KPKEYS_CTX_PGTABLES, otherwise only grant RO access. Signed-off-by: Kevin Brodsky --- arch/arm64/include/asm/kpkeys.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kpkeys.h b/arch/arm64/include/asm/kpkeys.h index fdf3ebe92810..c1daab643195 100644 --- a/arch/arm64/include/asm/kpkeys.h +++ b/arch/arm64/include/asm/kpkeys.h @@ -12,7 +12,8 @@ * Equivalent to por_set_kpkeys_context(0, KPKEYS_CTX_DEFAULT), but can also be * used in assembly. */ -#define POR_EL1_INIT POR_ELx_PERM_PREP(KPKEYS_PKEY_DEFAULT, POE_RWX) +#define POR_EL1_INIT (POR_ELx_PERM_PREP(KPKEYS_PKEY_DEFAULT, POE_RWX) | \ + POR_ELx_PERM_PREP(KPKEYS_PKEY_PGTABLES, POE_R)) #ifndef __ASSEMBLY__ @@ -33,6 +34,8 @@ static inline bool arch_supports_kpkeys_early(void) static inline u64 por_set_kpkeys_context(u64 por, int ctx) { por = por_elx_set_pkey_perms(por, KPKEYS_PKEY_DEFAULT, POE_RWX); + por = por_elx_set_pkey_perms(por, KPKEYS_PKEY_PGTABLES, + ctx == KPKEYS_CTX_PGTABLES ? POE_RW : POE_R); return por; } -- 2.51.2