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 4AF8EC6FD1D for ; Mon, 27 Mar 2023 16:45:44 +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=rZ52gimkPzDkcjNVhRFgRcDRZjMbSKOpwAVwUJDydpo=; b=l6l0No4WB4if8u y0ws4P5jLCEVeR0Y04TQIgDYPDgOmj/U9WFSaoOgqvQRymnHMhAkWyoE7pG6FiJsr0KEO0t7qauBb 3TZycbn53a33//Y3cORyVkh6y/PStuSx95VbCVTadKTlCkjzvLs1wKdH5NUnR0080XK1wRhGx+Dd+ q+D3p7ZE75xyQN61H3yyqNxqaYwV4QSi8lcmbjoluyW29+nA92Ip+NkATuzTdbN2/DnDEaXT98s58 ER8iLEbnOBtoE1hRFWXVWp0qxPDV1KbrvGRYA0Z3Xk6QSeXKtUsV5kfw25Y2v+y3zKTz9c4EmvoDg aXOajkPMuR/JHUb2MKeA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pgpxe-00BjkF-1G; Mon, 27 Mar 2023 16:44:46 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pgpxb-00Bjjq-0N for linux-arm-kernel@lists.infradead.org; Mon, 27 Mar 2023 16:44:44 +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 A25AB61345; Mon, 27 Mar 2023 16:44:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FDDBC433D2; Mon, 27 Mar 2023 16:44:40 +0000 (UTC) Date: Mon, 27 Mar 2023 17:44:37 +0100 From: Catalin Marinas To: Joey Gouly Cc: linux-arm-kernel@lists.infradead.org, nd@arm.com, broonie@kernel.org, james.morse@arm.com, mark.rutland@arm.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, will@kernel.org, yuzenghui@huawei.com Subject: Re: [PATCH v1 12/18] arm64: add PTE_UXN/PTE_WRITE to SWAPPER_*_FLAGS Message-ID: References: <20230309145246.22787-1-joey.gouly@arm.com> <20230309145246.22787-13-joey.gouly@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230309145246.22787-13-joey.gouly@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230327_094443_211982_62825100 X-CRM114-Status: GOOD ( 17.84 ) 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 Thu, Mar 09, 2023 at 02:52:40PM +0000, Joey Gouly wrote: > With PIE enabled, the swapper PTEs would have a Permission Indirection Index (PIIndex) > of 0. A PIIndex of 0 is not currently used by any other PTEs. > > To avoid using index 0 specifically for the swapper PTEs, mark them as PTE_UXN > and PTE_WRITE, so that they map to a PAGE_KERNEL_EXEC equivalent. > > Signed-off-by: Joey Gouly > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Mark Rutland > --- > arch/arm64/include/asm/kernel-pgtable.h | 4 ++-- > arch/arm64/kernel/head.S | 8 ++++---- > arch/arm64/mm/proc.S | 2 +- > 3 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/arch/arm64/include/asm/kernel-pgtable.h b/arch/arm64/include/asm/kernel-pgtable.h > index fcd14197756f..daf1909116f6 100644 > --- a/arch/arm64/include/asm/kernel-pgtable.h > +++ b/arch/arm64/include/asm/kernel-pgtable.h > @@ -104,8 +104,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 | PTE_WRITE) > +#define SWAPPER_PMD_FLAGS (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S | PTE_UXN | PTE_WRITE) Adding PTE_UXN is fine but we have SWAPPER_RX_MMUFLAGS which is no longer read-only after this change. I don't think this matters much as IIUC we only use init_pg_dir briefly before creating the proper swapper_pg_dir. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel