From patchwork Thu Jun 30 14:42:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 12901948 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 40071C433EF for ; Thu, 30 Jun 2022 14:44:15 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=E25jvtRJFUsMyQlBSPTQz2TxB3LnwjtF2VHRhjjDYi4=; b=UKPQBLVvDHLHP/ jifpqq6DP9EhwJVfrvdfvYMBZKfRrmTFEGgnodcbZTpyfBZGlOBSucNL4QyfNn1l2byos1HbIqHdq /VdF7SVv6bbtbjm/5nW1jkZ9NRxrkhd+VZ1fckuWTX48pr7VwfuZisUWIYCMJImo3vNRMOhGkrVUF +oKhbIrZJmAd0LnoFlJm0pw+Z7SWoG1dmDndYaHgs12sTY+B/5tcfek5HVdi6FeWfeBO/42E0wbRe WSy9MeEIJZ1Nv0iV+GrzbxVXqerCcI2/++yzGKnoqHJDDBKsJ4OC3UH0bwpdhp0DqF6seg3Fpg8e7 CG9MvtmeNkbkttPrNDzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6vNo-0007lf-2k; Thu, 30 Jun 2022 14:43:04 +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 1o6vNQ-0007eB-Ge for linux-arm-kernel@lists.infradead.org; Thu, 30 Jun 2022 14:42:41 +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 DE4C76231F; Thu, 30 Jun 2022 14:42:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3A13C3411E; Thu, 30 Jun 2022 14:42:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656600159; bh=N1GtE6NvYykzcTIJ4gqDcO1sHS3/meS1CkMcN6NWlh8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oVg7gPxT5a9EL+87JspAk29cuWgAYN+qU+MQEOwv+XkTg/Z/3z4PhnxhW9I7aUiF4 r309M5kxli3/6YMCzsndanPNIt9oZM4CJwYAXah89F4XoOXRsriRaNho+zulbREBgM GhmuAmO/RsxiNO0y5yX6ICeYe4k4XTe6ThVjwUDRxiDMkIbst6zZGr1QPTWxd0wBmD Br9avkDFtBMkad+kfoOGtrIqUTlMgZNFHjrNWr477I3QqDqeRvEIcr0vjFVTvq9NN5 r2RInU7Xs4y2EnnH3Gn/cik4kC1fs9LPgh3i01KEaDWFgbncaHP9C2mLs7AD3nAPH5 GjTO7328dFhvQ== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Will Deacon , Marc Zyngier , =?utf-8?q?Pierre-Cl=C3=A9ment_Tosi?= , Quentin Perret , Mark Rutland Subject: [PATCH 2/6] arm64: kernel: move ID map out of .text mapping Date: Thu, 30 Jun 2022 16:42:26 +0200 Message-Id: <20220630144230.2332555-3-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220630144230.2332555-1-ardb@kernel.org> References: <20220630144230.2332555-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2791; h=from:subject; bh=N1GtE6NvYykzcTIJ4gqDcO1sHS3/meS1CkMcN6NWlh8=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBivbZM6hXt5zZOdSwlKQMQBAgQ49jBTPzOSvcIWV0Q w2CZON+JAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYr22TAAKCRDDTyI5ktmPJDVBC/ 9tWnGoKPxljrvY1zaSUjWb7wA1GqNtS1bG3w+3pk3XlMgLEzHuOLBzGPFDtT4dDxffaqKQ7GFIGZ8u pF1IrTTI3oNAwZDrWlW1wgLDiUnYAe9qTtjztXpioqylj3DSzqCMQoJKKPRJZee380XwVl6UDcsCJg egbsglF21+cNRbgookKyypsRKcMALRDx4zUsKuexkqkoVYcez8ZGzZZUenCdnwqID2guLFaVRf98Cs LuBW/L2Hvo7OtyN5xQzLNpuTnjFw/509vHa2wsagEUvtvued0gMNWsek+sGlWWOY27YRd5sYkQ5z2v gL9uwbVnZ83hLfgJycUsmtQ0Rmteo5zsoXs/P260d61BmdFc6grLFEMJZ8a0JDX6D0nLZt1y2RBKMX Fy2RIb1ozoP6cPy9j9ISlvcxu5Rnrr6AAZtG/7c8WOcIWHIKWoIKq+Bf5sX2lVnlA9vFXpyFrqSsYx afQrxKDJAVJFDqCGy8C/A329vOZSmOaAJauMEy+WDU6A4= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220630_074240_660914_B6C4506A X-CRM114-Status: GOOD ( 14.15 ) 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 Reorganize the ID map slightly so that only code that is executed via the 1:1 mapping remains. This allows us to move the ID map out of the .text segment, as it will no longer need executable permissions via the kernel mapping. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/head.S | 5 ++++- arch/arm64/kernel/vmlinux.lds.S | 2 +- arch/arm64/mm/proc.S | 2 -- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 09b0cddf2161..2210bbd13cf9 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -464,7 +464,7 @@ SYM_FUNC_END(__primary_switched) * end early head section, begin head code that is also used for * hotplug and needs to have the same protections as the text region */ - .section ".idmap.text","awx" + .text /* * Starting from EL2 or EL1, configure the CPU to execute at the highest @@ -556,6 +556,7 @@ SYM_FUNC_START_LOCAL(set_cpu_boot_mode_flag) ret SYM_FUNC_END(set_cpu_boot_mode_flag) + .section ".idmap.text","awx" /* * This provides a "holding pen" for platforms to hold all secondary * cores are held until we're ready for them to initialise. @@ -600,6 +601,7 @@ SYM_FUNC_START_LOCAL(secondary_startup) br x8 SYM_FUNC_END(secondary_startup) + .text SYM_FUNC_START_LOCAL(__secondary_switched) mov x0, x20 bl set_cpu_boot_mode_flag @@ -659,6 +661,7 @@ SYM_FUNC_END(__secondary_too_slow) * Checks if the selected granule size is supported by the CPU. * If it isn't, park the CPU */ + .section ".idmap.text","awx" SYM_FUNC_START(__enable_mmu) mrs x3, ID_AA64MMFR0_EL1 ubfx x3, x3, #ID_AA64MMFR0_TGRAN_SHIFT, 4 diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index 0efccdf52be2..5002d869fa7f 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -168,7 +168,6 @@ SECTIONS LOCK_TEXT KPROBES_TEXT HYPERVISOR_TEXT - IDMAP_TEXT *(.gnu.warning) . = ALIGN(16); *(.got) /* Global offset table */ @@ -195,6 +194,7 @@ SECTIONS TRAMP_TEXT HIBERNATE_TEXT KEXEC_TEXT + IDMAP_TEXT . = ALIGN(PAGE_SIZE); } diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S index 7837a69524c5..113a4fedf5b8 100644 --- a/arch/arm64/mm/proc.S +++ b/arch/arm64/mm/proc.S @@ -107,7 +107,6 @@ SYM_FUNC_END(cpu_do_suspend) * * x0: Address of context pointer */ - .pushsection ".idmap.text", "awx" SYM_FUNC_START(cpu_do_resume) ldp x2, x3, [x0] ldp x4, x5, [x0, #16] @@ -163,7 +162,6 @@ alternative_else_nop_endif isb ret SYM_FUNC_END(cpu_do_resume) - .popsection #endif .pushsection ".idmap.text", "awx"