From patchwork Thu Jun 2 21:22:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 12868174 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 E1CE5C43334 for ; Thu, 2 Jun 2022 21:24: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: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:In-Reply-To:References: List-Owner; bh=n2PPw9d7Pg+paaYc4Ko4TdcsmTnLXQ0EFxdxd0OQZgo=; b=m6JSHQ5yae3PRc v4PBSiJwDasrp8s4ThdU4KMfdSsmve5EaoOXkaTcMLMgqrGQDuqWbznfJuTn8NTum0fTHOBa9edgo dG5fB/gzFszyaBfTXeOie5qAh5I1QBl8fb4A/vSVmLgIRpuxL47+T7TnPfbV5jUw/Kese8PaXeHUO JWkrF3iBHx7rWZdKQkBdvHGGV7x6FOUHDoUxT2Lzv58Gcsi+KdePMcJms9mgFdQ55uCV5ovzwU7Ff aVup6BHcH0+3XJ7ImO5n4H9ad9mJzJN9ALxWA5CkGeQhMft/E9m+jSAnozv6CK8YX1aK9YsXyhTCp Eg0R26rSeiVLk1FR8XxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwsHT-004MlU-2X; Thu, 02 Jun 2022 21:22:59 +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 1nwsHN-004Ml4-NL for linux-arm-kernel@lists.infradead.org; Thu, 02 Jun 2022 21:22:57 +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 E368B6187D; Thu, 2 Jun 2022 21:22:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F940C385A5; Thu, 2 Jun 2022 21:22:51 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="E0HF5nn8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1654204969; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=dxLGBl7v8u3rcLNq9XWqGXvKeMQ71NgT/hcJ68hc2Bs=; b=E0HF5nn8Q4o/4PCKJOR/T2UbSHr1ys+MqXv+zrUF3ppx9pYapyKM595NthI5ZPIeiMndZS XpMRoLy/51DolGDKqm58VLkplQJBSsFcNtE+FEEbVWJAAmI1NpzVHZv2D8T8RyGOAItwdE 100k8aRo2+flhQEawoDkt4YJXj/kngQ= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 4bb1c12f (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Thu, 2 Jun 2022 21:22:49 +0000 (UTC) From: "Jason A. Donenfeld" To: linux@armlinux.org.uk, rmk+kernel@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com Cc: "Jason A. Donenfeld" , Stephen Boyd , Ard Biesheuvel , stable@vger.kernel.org Subject: [PATCH] ARM: initialize jump labels before setup_machine_fdt() Date: Thu, 2 Jun 2022 23:22:34 +0200 Message-Id: <20220602212234.344394-1-Jason@zx2c4.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220602_142253_840596_CAA9975F X-CRM114-Status: GOOD ( 15.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 Stephen reported that a static key warning splat appears during early boot on arm64 systems that credit randomness from device trees that contain an "rng-seed" property, because setup_machine_fdt() is called before jump_label_init() during setup_arch(), which was fixed by 73e2d827a501 ("arm64: Initialize jump labels before setup_machine_fdt()"). Upon cursory inspection, the same basic issue appears to apply to arm32 as well. In this case, we reorder setup_arch() to do things in the same order as is now the case on arm64. Reported-by: Stephen Boyd Cc: Catalin Marinas Cc: Ard Biesheuvel Cc: stable@vger.kernel.org Fixes: f5bda35fba61 ("random: use static branch for crng_ready()") Signed-off-by: Jason A. Donenfeld --- arch/arm/kernel/setup.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 1e8a50a97edf..ef40d9f5d5a7 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -1097,10 +1097,15 @@ void __init setup_arch(char **cmdline_p) const struct machine_desc *mdesc = NULL; void *atags_vaddr = NULL; + setup_initial_init_mm(_text, _etext, _edata, _end); + setup_processor(); + early_fixmap_init(); + early_ioremap_init(); + jump_label_init(); + if (__atags_pointer) atags_vaddr = FDT_VIRT_BASE(__atags_pointer); - setup_processor(); if (atags_vaddr) { mdesc = setup_machine_fdt(atags_vaddr); if (mdesc) @@ -1125,15 +1130,10 @@ void __init setup_arch(char **cmdline_p) if (mdesc->reboot_mode != REBOOT_HARD) reboot_mode = mdesc->reboot_mode; - setup_initial_init_mm(_text, _etext, _edata, _end); - /* populate cmd_line too for later use, preserving boot_command_line */ strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE); *cmdline_p = cmd_line; - early_fixmap_init(); - early_ioremap_init(); - parse_early_param(); #ifdef CONFIG_MMU