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 5B244FEFB6E for ; Fri, 27 Feb 2026 17:57:43 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Uiv++dFAlObl1HHsG/K5OpEIqspmKksjUq9fFh1jeeo=; b=PF+OJNI4mGRgjsPNhgu2pgYwZK PH5LmlWh0sTMH9MsvSKab4g9T1RabQHGvfQQBw/LnzixGoVHZhs2IhYEsooJQkthE0IiVv5XeL+U3 0kefQ7eNLwyJyBT5Ffhs37MlJPlcedbTU+DIvWeTwN4zqLbfUx7D32YeVEmQ23U8oL4801ANsZJ7a nz6Ztbz80bwlVClO50Dmp+raWTBHg3yEXznjRVLDquY/bZB4n1SomUEeluVlZD6eo1aEWiyugcp4s Y9SaOfaK4spukBwXAXYYI+57zppPe0ReFfdBlQITGwnq80n0s0C7laHoFiBThS+D3tjgeyfknbU33 DSBC0DuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vw25p-00000008rnz-1kF6; Fri, 27 Feb 2026 17:57:37 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vw25m-00000008riK-0M7g for linux-arm-kernel@bombadil.infradead.org; Fri, 27 Feb 2026 17:57:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Uiv++dFAlObl1HHsG/K5OpEIqspmKksjUq9fFh1jeeo=; b=G92wIP5PyH4JdqIPTgQS+xbndF uf2hrWzxJ3ACfI1myvbYm30dTcD9suoMInKyW2Qi7iQ/XktXjVkjoTzPx/Ulk8U5467S4e+O4RuA9 8REaHfrLDbsPEB3kql8naADrXFg+cpa7lL/duugyTJyaHqB6AHKzydMaNjWjfcRVxCA73A7SPNTz6 vLiEoPNyRRioEwW/xEpFZGEIwTpesFIFA22Dhsbyg7rrfPb0TqYWuF/JzNl2TltbYxi6BWuG5VoVq TeuZMuIZPi560LAH0gPGBXwJtj20pNdkQgdmR04zwgT3aulZF00VXAkxxcHnAELaPA4/hZZBwYMuD Jwokvpgw==; Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vw25f-0000000DdJq-3PlL for linux-arm-kernel@lists.infradead.org; Fri, 27 Feb 2026 17:57:32 +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 737F419F0; Fri, 27 Feb 2026 09:57:20 -0800 (PST) Received: from e123572-lin.arm.com (e123572-lin.cambridge.arm.com [10.1.194.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5D8A63F73B; Fri, 27 Feb 2026 09:57:22 -0800 (PST) From: Kevin Brodsky To: linux-hardening@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Kevin Brodsky , Andrew Morton , Andy Lutomirski , Catalin Marinas , Dave Hansen , David Hildenbrand , Ira Weiny , Jann Horn , Jeff Xu , Joey Gouly , Kees Cook , Linus Walleij , Lorenzo Stoakes , Marc Zyngier , Mark Brown , Matthew Wilcox , Maxwell Bland , "Mike Rapoport (IBM)" , Peter Zijlstra , Pierre Langlois , Quentin Perret , Rick Edgecombe , Ryan Roberts , Thomas Gleixner , Vlastimil Babka , Will Deacon , Yang Shi , Yeoreum Yun , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH v6 22/30] arm64: kpkeys: Support KPKEYS_LVL_PGTABLES Date: Fri, 27 Feb 2026 17:55:10 +0000 Message-ID: <20260227175518.3728055-23-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20260227175518.3728055-1-kevin.brodsky@arm.com> References: <20260227175518.3728055-1-kevin.brodsky@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260227_175728_154807_AF94BBE2 X-CRM114-Status: GOOD ( 12.13 ) 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_LVL_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 79ae33388088..64d6e22740ec 100644 --- a/arch/arm64/include/asm/kpkeys.h +++ b/arch/arm64/include/asm/kpkeys.h @@ -12,7 +12,8 @@ * Equivalent to por_set_kpkeys_level(0, KPKEYS_LVL_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__ @@ -26,6 +27,8 @@ static inline bool arch_kpkeys_enabled(void) static inline u64 por_set_kpkeys_level(u64 por, int level) { por = por_elx_set_pkey_perms(por, KPKEYS_PKEY_DEFAULT, POE_RWX); + por = por_elx_set_pkey_perms(por, KPKEYS_PKEY_PGTABLES, + level == KPKEYS_LVL_PGTABLES ? POE_RW : POE_R); return por; } -- 2.51.2