From patchwork Wed Jun 14 16:09:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13280195 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 417AFEB64D8 for ; Wed, 14 Jun 2023 16:12:10 +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:Date:Message-Id:MIME-Version:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Ea7dRNgTNCMf4a2vNJXqiqs+zdxnntqbPC/Y5cU/dtE=; b=bLdkfT3iAEw2yx 7CrML8PhvHlwI8YgFdtOUP+iPl3M5a9w7x2pkSykRgNmCI3eGiOgJC55JfSFivSpSOdppcaRZ1y6Y +78i4ZfLgkl0bYGhUEFHa/tFlrlmFuP9QTVKwF3tAFA9CP1fEmnG3m7WXYmkGKW1P241IY69jwTg4 l060gwTCfh5UObojXzlsD+GMg/9YysCWO0h0dKPo8XUPSMYPVrRQcJteEbzHMshWBPtAcDjJb0rOZ UOdRoJukvM+6JQc3XLCPFvKW2Y/wzU5JkilnIUdXJ+4UeR1lpXUCndWQHYeS3Mjl2gOkcdLPOcOzR 5OSyj+Y7jndltGnorxUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q9T64-00CATN-2t; Wed, 14 Jun 2023 16:11:48 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q9T61-00CAED-12 for linux-arm-kernel@lists.infradead.org; Wed, 14 Jun 2023 16:11:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:Reply-To:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=0+8HKSdza2Fmt2fMGerg0/UWrEtppy6gyA2kANzuY2g=; b=oBSS8q/5Z0q4mD5neDkfPj5gYC jIuYP11ppNunxQGpzMBAwMZTTOM6AKw+PQG0z9h8Psb0OqQCdqQqTO5ilL1LA769bS4D1WtnVtpD0 vTGgAjJYDZVnuDJtnx6nNaYJwLmdrZv2p+f/9Dq1rpadbE6Wu8jJYBXFcqxI3J+oK0kN36jVSOCxF knT2qABfWHUJh3vDo70EfU8zkt7SuJi1vAgqCCvbwCfSaxe2wbEq/7ZeWtwVvtWNNdo0YvVlx/IFx Q9jpetzoenmz+zXwbrFCUEDAY60g0Eqt9e4U5JQSoQznaiTEFNZyjARQ3FEdI8HHbzpPf0EKmvzU8 dsIoBZiw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:47896 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q9T3w-0001x3-0K; Wed, 14 Jun 2023 17:09:36 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1q9T3v-00EDmW-BH; Wed, 14 Jun 2023 17:09:35 +0100 From: "Russell King (Oracle)" To: Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm64: consolidate rox page protection logic MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 14 Jun 2023 17:09:35 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230614_091145_375797_E4DDC38E 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 Consolidate the arm64 decision making for the page protections used for executable pages, used by both the trampoline code and the kernel text mapping code. Acked-by: Mark Rutland Signed-off-by: Russell King (Oracle) --- Mark Rutland said when giving the ack "It seems nice to ensure this is consistent, so regardless of whether we want the series as a whole ..." So I'm sending this patch separately. arch/arm64/mm/mmu.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index af6bc8403ee4..4829abe017e9 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -663,12 +663,17 @@ static void __init map_kernel_segment(pgd_t *pgdp, void *va_start, void *va_end, vm_area_add_early(vma); } +static pgprot_t kernel_exec_prot(void) +{ + return rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC; +} + #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 static int __init map_entry_trampoline(void) { int i; - pgprot_t prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC; + pgprot_t prot = kernel_exec_prot(); phys_addr_t pa_start = __pa_symbol(__entry_tramp_text_start); /* The trampoline is always mapped and can therefore be global */ @@ -723,7 +728,7 @@ static void __init map_kernel(pgd_t *pgdp) * mapping to install SW breakpoints. Allow this (only) when * explicitly requested with rodata=off. */ - pgprot_t text_prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC; + pgprot_t text_prot = kernel_exec_prot(); /* * If we have a CPU that supports BTI and a kernel built for