From patchwork Fri Jun 24 15:06:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 12894755 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 369F6C43334 for ; Fri, 24 Jun 2022 15:14:00 +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=iKJJvop92rZV/OiP3s8GNmuldZ+70BZ90qN+mdUlxWc=; b=mvCwwxqP24V8tQ pjt+/Q0o4fO/WhSW0hkpGIhImyh2Xc0kc15QM3p60glWjgqlHaCkCCpX9Lkarz+7IWWoNCt5hW0cI QNMqk5R8yG6aJMJUGKEj34UXmGhifbPwOzdGXqqArO2/1C+iu0eD9rF8yuQUqYYydWmlirtTtUtbB 3thvHYnEosR5V6ALup/DQEykqe+EiD5CspHHYsQETWZnul5y3cHaE3tCQD7gCvXysg2ZRec8Oz9DW sgodubpoi3ou9pdv2eTK5yf0qxPmZHwKuRXvlHRU7FVCIsuqBy2P3stJ35KGmfzgbYlumIGizCSKt SGwG00wEZAqIb4BUdbfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4kzL-002l46-J6; Fri, 24 Jun 2022 15:12:52 +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 1o4kuO-002iVK-QY for linux-arm-kernel@lists.infradead.org; Fri, 24 Jun 2022 15:07:46 +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 57635621D1; Fri, 24 Jun 2022 15:07:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A192C341C0; Fri, 24 Jun 2022 15:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656083264; bh=eMPSGj9Rs5On/3JVQhKqjI71n1zDlZtNVzFx/c1LtqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lvJw32fA+Wq47+BbMgKHOVbnHDTHBqpkfwncWiu/vmawdLTy1jW0h59YPxH5hJY5x vEPCo4ZoM5ZNO8SEZE7ORA9aiCIyfeZ38gaLZ63qN8dr9dV23QnjfH68rRakLYaAy6 MxdEoYh7xnaJ2CFAeR2rc6FZa48qg42OtQNeU2eRi31rHQ56sFoOrObI4gwIwmtNIg qqF/qEuDESmOaLD/3NLTcmSOVv1Yk1foitoD3R3HwQE8YscizkX2GWjkkD5YCrmo2h LZxKmJ1X50apq0V7w7dEGqBYutEdfz9oGE/UmKDPrX0qwklmPLf/x26IHbvmB5zBMv oOLWGkwYxeBXA== 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 15/21] arm64: idreg-override: use early FDT mapping in ID map Date: Fri, 24 Jun 2022 17:06:45 +0200 Message-Id: <20220624150651.1358849-16-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=2544; h=from:subject; bh=eMPSGj9Rs5On/3JVQhKqjI71n1zDlZtNVzFx/c1LtqU=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBitdMAAofEOujGB2k/uwZkXxISjPLZssYFhlSgxCTO ISoo9cGJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYrXTAAAKCRDDTyI5ktmPJN9zC/ 9IYWwHzP5miObH+vE7Zt1q2CRWox4TYxZKylzz5whuFZ52uMr+K18xHlqaHHmYYawq7M8bX+oGuWi9 dLJXCUt+t7uUO44/iOwjwCcoZ7P2CNf4R1sirNoTXg9O34mcd/y/8X+sG1oJ7986/bXvbfh/Hz7IeC jB06uwi1IyiyktNF+kphXrX4Wm0nF40G1/I1NiTCquk57euPt51OmczNcUeTqVO+WJEZJ6EFYsYZbe 69ZiVw4htp2ZoCVmXAR2Zax+QxQMp1g3FPHrgXA6pAtCUqq8z+xUG1fPzA+UABcFUGbB6K2fLqMZDQ XMKIPQoGVy/6YG4ZVKeMgQI/D6zioXGzL+S+rGYxwGsjp1EBZoNGiEjVVRANzga3iycHVAkNEnbG6+ WGyNMA4U6LfKy7iOJnvINETWRa+aM2Ezmtf+5hDOkwdBWO6hftrElMJgbh8H2/xnUxHBVsPOo6Jkcy KwTfsQWXtNO9e0bQCJ7DOkSJGF3epmAvNujHgJii/7Mtk= 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_080744_987645_5BF1471F X-CRM114-Status: GOOD ( 16.82 ) 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 Instead of calling into the kernel to map the FDT into the kernel page tables before even calling start_kernel(), let's switch to the initial, temporary mapping of the device tree that has been added to the ID map. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/head.S | 1 + arch/arm64/kernel/idreg-override.c | 17 ++++++----------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 8283ff848328..64ebff634b83 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -472,6 +472,7 @@ SYM_FUNC_START_LOCAL(__primary_switched) #endif mov x0, x21 // pass FDT address in x0 bl early_fdt_map // Try mapping the FDT early + mov x0, x22 // pass FDT address in x0 bl init_feature_override // Parse cpu feature overrides #ifdef CONFIG_RANDOMIZE_BASE tst x23, ~(MIN_KIMG_ALIGN - 1) // already running randomized? diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c index 8a2ceb591686..f92836e196e5 100644 --- a/arch/arm64/kernel/idreg-override.c +++ b/arch/arm64/kernel/idreg-override.c @@ -201,16 +201,11 @@ static __init void __parse_cmdline(const char *cmdline, bool parse_aliases) } while (1); } -static __init const u8 *get_bootargs_cmdline(void) +static __init const u8 *get_bootargs_cmdline(const void *fdt) { const u8 *prop; - void *fdt; int node; - fdt = get_early_fdt_ptr(); - if (!fdt) - return NULL; - node = fdt_path_offset(fdt, "/chosen"); if (node < 0) return NULL; @@ -222,9 +217,9 @@ static __init const u8 *get_bootargs_cmdline(void) return strlen(prop) ? prop : NULL; } -static __init void parse_cmdline(void) +static __init void parse_cmdline(const void *fdt) { - const u8 *prop = get_bootargs_cmdline(); + const u8 *prop = get_bootargs_cmdline(fdt); if (IS_ENABLED(CONFIG_CMDLINE_FORCE) || !prop) __parse_cmdline(CONFIG_CMDLINE, true); @@ -234,9 +229,9 @@ static __init void parse_cmdline(void) } /* Keep checkers quiet */ -void init_feature_override(void); +void init_feature_override(const void *fdt); -asmlinkage void __init init_feature_override(void) +asmlinkage void __init init_feature_override(const void *fdt) { int i; @@ -247,7 +242,7 @@ asmlinkage void __init init_feature_override(void) } } - parse_cmdline(); + parse_cmdline(fdt); for (i = 0; i < ARRAY_SIZE(regs); i++) { if (regs[i]->override)