From patchwork Fri Jun 24 15:06:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 12894749 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 6D44DC433EF for ; Fri, 24 Jun 2022 15:11:05 +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=YViJA9cgygjJTWBsMG5+ugpJaJyPnnapUCdgnhipYsU=; b=Mg+f8TW3bL95lI A1ee23v2os8LW8FxYCeik8UPnNFFR8vsTwGdwUsBuEWqv1IJOY7/FCkYJ2NuFhsfEs3DW1IVviZLw V8gLWIbJQrZVrHDYF3oDOTHaRxTKpMbq/jXUVSsIZ8Sl9CmNcZAiFTKC08hXHQi5cHgg/uy6llbiv L9MUHPzMC/O36uaLhTxWWITrCriPkyKO5JGW47qHDteA+CUCsIwTOvrzLM0Cn8IhbWnJ3aeowa1Uv 4yTdo7cN3qkV8Hbh2BqZgbw1K6tqdnapYsh3ZNP9Iexqw9pNyfC3SVRDv7jVRQ3qt/7WSO3u0Nq7g Qh+DQ0r+5kr/exVuLNGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4kwV-002jWq-9q; Fri, 24 Jun 2022 15:09:55 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4kuB-002iQ5-QT for linux-arm-kernel@lists.infradead.org; Fri, 24 Jun 2022 15:07:33 +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 ams.source.kernel.org (Postfix) with ESMTPS id 93695B82903; Fri, 24 Jun 2022 15:07:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66CFBC341C6; Fri, 24 Jun 2022 15:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656083250; bh=nURZO8SxcJ6o/OcejTN7XMVfqtGnblUp7/ha5UnY1p0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PnBhAZB7noXFrUszBP1M/+r5HLkH792494NP0MbuSwm4rwud+I+xQlOOrXORoRvFl w1JdBshsewT3mpXR7NChWc7FeYj7XYHzAq2FJwvGkU3SlElmO3yl6M3chKpZXSQefJ F8sK8k7tbiQnkdFFrbBtimDHVonVjxGspFUzicWQ0ZDNbpo36KNfgDL6pFQrInOTfZ 76f7v2nRvZgyujJS3PeouSWSboJdGBZoZG4jFXYsWAEmTvX+xO5S1BX5rT2Car2JtE q5nyysJgE3xu4mWWJzfaGvd0OykZu8ycZ48sNJd5lFWugZa/lA2pBBANTUbUlt+W1F n8iA8V3SEvM0A== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Marc Zyngier , Will Deacon , Mark Rutland , Kees Cook , Catalin Marinas , Mark Brown , Anshuman Khandual Subject: [PATCH v5 09/21] arm64: head: pass ID map root table address to __enable_mmu() Date: Fri, 24 Jun 2022 17:06:39 +0200 Message-Id: <20220624150651.1358849-10-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220624150651.1358849-1-ardb@kernel.org> References: <20220624150651.1358849-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2427; h=from:subject; bh=nURZO8SxcJ6o/OcejTN7XMVfqtGnblUp7/ha5UnY1p0=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBitdL2GNtMDVXQU1a/9OpeykZkA53dK/xE5/HPcaRB YsfhWhOJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYrXS9gAKCRDDTyI5ktmPJB1lDA CSAtEmG1BljYYF1rBH8jUb+2kK7m5yNTxErauIl+Qg10vQPA3U9NaHcqs+ngaqu8zPesS7KYYfLC6g jMI+fX/BsbQ+3Dt7BILG9GLYG3PC1/fMA+ldj867w3Aug30fDiBq3w3sPeEU5aAM/DEGYEaEfD0d8k lC1062SOyJQqYtOkJsj7RJXfgy2QX2lAGhSwDiU5MkH8fNsYnLfjIgUJTVrUb9X8V6bTgldGCGYrMY Uq/nUvFjyzwTs75OvQ0dRtwb1DIjV5Qx45Knfhd7bPbUaMvJM8xHQXaSHkSlGh/zqI35yqBNU7pDhg 42xUTbwvhUnDlbiwle6ASK1+32VuDgVD9M7efgpBxY/fqu8xoNlQ6ayAMskymNHvHfuufT+kSp9fzD hGhfdinDv50HvYgRJ2BCr+kC7NcUwZuMKVButDRzV4QDGlWnZ4dHuYPxG1aJ5fsW9W9Rbd8kKGDo97 TRN10KzBirT1D3ELuOveRo3idmsydsNxCZGxQz0wFNaKI= 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-20220624_080732_175122_CDC82BCC X-CRM114-Status: GOOD ( 14.10 ) 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 We will be adding an initial ID map that covers the entire kernel image, so we will pass the actual ID map root table to use to __enable_mmu(), rather than hard code it. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/head.S | 14 ++++++++------ arch/arm64/kernel/sleep.S | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 1cbc52097bf9..70c462bbd6bf 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -595,6 +595,7 @@ SYM_FUNC_START_LOCAL(secondary_startup) bl __cpu_secondary_check52bitva bl __cpu_setup // initialise processor adrp x1, swapper_pg_dir + adrp x2, idmap_pg_dir bl __enable_mmu ldr x8, =__secondary_switched br x8 @@ -648,6 +649,7 @@ SYM_FUNC_END(__secondary_too_slow) * * x0 = SCTLR_EL1 value for turning on the MMU. * x1 = TTBR1_EL1 value + * x2 = ID map root table address * * Returns to the caller via x30/lr. This requires the caller to be covered * by the .idmap.text section. @@ -656,14 +658,13 @@ SYM_FUNC_END(__secondary_too_slow) * If it isn't, park the CPU */ SYM_FUNC_START(__enable_mmu) - mrs x2, ID_AA64MMFR0_EL1 - ubfx x2, x2, #ID_AA64MMFR0_TGRAN_SHIFT, 4 - cmp x2, #ID_AA64MMFR0_TGRAN_SUPPORTED_MIN + mrs x3, ID_AA64MMFR0_EL1 + ubfx x3, x3, #ID_AA64MMFR0_TGRAN_SHIFT, 4 + cmp x3, #ID_AA64MMFR0_TGRAN_SUPPORTED_MIN b.lt __no_granule_support - cmp x2, #ID_AA64MMFR0_TGRAN_SUPPORTED_MAX + cmp x3, #ID_AA64MMFR0_TGRAN_SUPPORTED_MAX b.gt __no_granule_support - update_early_cpu_boot_status 0, x2, x3 - adrp x2, idmap_pg_dir + update_early_cpu_boot_status 0, x3, x4 phys_to_ttbr x1, x1 phys_to_ttbr x2, x2 msr ttbr0_el1, x2 // load TTBR0 @@ -819,6 +820,7 @@ SYM_FUNC_START_LOCAL(__primary_switch) #endif adrp x1, init_pg_dir + adrp x2, idmap_pg_dir bl __enable_mmu #ifdef CONFIG_RELOCATABLE #ifdef CONFIG_RELR diff --git a/arch/arm64/kernel/sleep.S b/arch/arm64/kernel/sleep.S index 4ea9392f86e0..e36b09d942f7 100644 --- a/arch/arm64/kernel/sleep.S +++ b/arch/arm64/kernel/sleep.S @@ -104,6 +104,7 @@ SYM_CODE_START(cpu_resume) bl __cpu_setup /* enable the MMU early - so we can access sleep_save_stash by va */ adrp x1, swapper_pg_dir + adrp x2, idmap_pg_dir bl __enable_mmu ldr x8, =_cpu_resume br x8