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 E4EF3C43334 for ; Wed, 20 Jul 2022 09:57:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oVg4iaoPLHLO3Egay5MGn/2H1b6RIAzuSSqGkTpQc4k=; b=GRXae7/B4kttEl LpmPOr5GW6khbtJkhCoOmZVzeWDoxFDvucBzn0XJbHZHwpcATSzrugFBejspnrSRjsaM0KO/ctKja s+VebXrQwCuhlzca1bfC+Na/faQNKWVzdnZTtoF6T5HNitgVsPzliz2DcYor0sxno46ORLGpBLXu5 kKigs5ahR8HJiKqAm7QrlQ/bE1MJxPGusIr6jopa3jL7JBudBdKEBZ+TgQRfhU3eDlPGbTVP5P+Ds udXzqYC0JHjDBVkRC5S3OkGTqVeTFu3K/RHgpHfUodB05JbpgXuJp28GGPYGLjqGE4qU7ZIhkcw4g asIIpDcf/92laQepfe4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oE6RL-003air-TV; Wed, 20 Jul 2022 09:56:24 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oE6RJ-003abn-3T for linux-arm-kernel@lists.infradead.org; Wed, 20 Jul 2022 09:56:22 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6980261B6D; Wed, 20 Jul 2022 09:56:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4556C3411E; Wed, 20 Jul 2022 09:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658310979; bh=js06Zg0/NwvC0ll2TLX/8d7GWkdHV1uNtr+se9/lMyY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nEAWi+BZoodU8aqDlpfTe71beJpglLiLkahwWEvZ++HAOhKIcq31gUbhahV4GCFU+ 5W2fRlekj4qQNll/xZhNUanrW4I55dcheTleZbP205D/kQ0fO3KqNRJsedSj8wT28J a/l/FLhnl6Ck24qDZPv/yXDBDUmtlORXv0JAs556sLvUtNNIBXG4jjufHVWFkhiOJA 6x++zvvf3YPZNWKCxwl3B9AaQ+LR+U6sskdiutsAgF36s9FVzjML/5AJUW6SETlug6 R4HbvjNWs0ajnSiCkpWxi3PrRW8ILGsD6My9S9I6jozWa2f3+XxMowoaEEtQBCCZ1O oOihtc+yVxN3Q== Date: Wed, 20 Jul 2022 10:56:15 +0100 From: Will Deacon To: Peter Collingbourne Cc: Marc Zyngier , linux-arm-kernel@lists.infradead.org, Catalin Marinas , stable@vger.kernel.org Subject: Re: [PATCH] arm64: set UXN on swapper page tables Message-ID: <20220720095614.GD15752@willie-the-truck> References: <20220719234909.1398992-1-pcc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220719234909.1398992-1-pcc@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220720_025621_202977_600E6DAD X-CRM114-Status: GOOD ( 21.99 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jul 19, 2022 at 04:49:09PM -0700, Peter Collingbourne wrote: > On a system that implements FEAT_EPAN, read/write access to the idmap > is denied because UXN is not set on the swapper PTEs. As a result, > idmap_kpti_install_ng_mappings panics the kernel when accessing > __idmap_kpti_flag. Fix it by setting UXN on these PTEs. > > Fixes: 18107f8a2df6 ("arm64: Support execute-only permissions with Enhanced PAN") > Cc: # 5.15 > Link: https://linux-review.googlesource.com/id/Ic452fa4b4f74753e54f71e61027e7222a0fae1b1 > Signed-off-by: Peter Collingbourne > --- > This fix is no longer needed since commit c3cee924bd85 ("arm64: head: > cover entire kernel image in initial ID map"), which moved __idmap_kpti_flag > to .data, but that commit is currently only present in next. > > arch/arm64/include/asm/kernel-pgtable.h | 4 ++-- > arch/arm64/kernel/head.S | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/include/asm/kernel-pgtable.h b/arch/arm64/include/asm/kernel-pgtable.h > index 96dc0f7da258..a971d462f531 100644 > --- a/arch/arm64/include/asm/kernel-pgtable.h > +++ b/arch/arm64/include/asm/kernel-pgtable.h > @@ -103,8 +103,8 @@ > /* > * Initial memory map attributes. > */ > -#define SWAPPER_PTE_FLAGS (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED) > -#define SWAPPER_PMD_FLAGS (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S) > +#define SWAPPER_PTE_FLAGS (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED | PTE_UXN) > +#define SWAPPER_PMD_FLAGS (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S | PMD_SECT_UXN) > > #if ARM64_KERNEL_USES_PMD_MAPS > #define SWAPPER_MM_MMUFLAGS (PMD_ATTRINDX(MT_NORMAL) | SWAPPER_PMD_FLAGS) > diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S > index 6a98f1a38c29..8a93a0a7489b 100644 > --- a/arch/arm64/kernel/head.S > +++ b/arch/arm64/kernel/head.S > @@ -285,7 +285,7 @@ SYM_FUNC_START_LOCAL(__create_page_tables) > subs x1, x1, #64 > b.ne 1b > > - mov x7, SWAPPER_MM_MMUFLAGS > + mov_q x7, SWAPPER_MM_MMUFLAGS Heh, nice find: Acked-by: Will Deacon Catalin, I guess this needs to land for 5.19 given that it's no longer relevant after the idmap rework pending for 5.20? If it all explodes in -next, I can merge in for-next/fixes. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel