Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp7833354ioo; Fri, 3 Jun 2022 14:49:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3NkqOJO1L/oQGbPtQQKiI895R35yjDRvxBcJj0HSW9BYV2s7FrEiLIWLHNu2C6UpmgO69 X-Received: by 2002:a65:6bce:0:b0:3f2:5f88:6f7d with SMTP id e14-20020a656bce000000b003f25f886f7dmr10846379pgw.253.1654292952625; Fri, 03 Jun 2022 14:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654292952; cv=none; d=google.com; s=arc-20160816; b=FAJxz1qMxd/VG3WFt5b1JE8jC8+O3ifO3dqfKrueerQQjKZbd5o17Mn487dUZyIIwV T/PkfU1Du0NraoRmiRcKY2iDPrxlXOgoxSLTnnFudOGYmVGbVIlZ0CE3Z9QvutPdhDLF 0VMr7fGwDjRJ8URF/s1sVed89q4YAGujx/qxHhU+EX5bLWRET3DpVkAeEZpKg9xjMD5a r455ah907SngR+hUgi41wK94SO6Due+gaV+ZZlIrm1NaXX71D/kbxNnOFKZPbmKZ9Izp MOvujH2488uducuoJ2viekNrDSPXnJQRptgL0JjEpPC+OxotHcxcaOM3/+swQPCuv8Z0 L4iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=DzSM+vMUKAOXQRrg+dwQXzhpc+oWzdrcapny9zGslI8=; b=DZq9YplZBtsBhHYx2EKXRbT6Ry9r/f9/8Ylm+94yUaqjqi5TfGfTudoAWxBTSu8vd5 oOs4gN9jc+NosGyulHBrtwusNgUALl6/sLRK32Aq0GHc//xtXUXqhi3N8dMWG+Y4wB7s xS0oWPwgYhH57H/I0rDi4y22IZ4Pvm53LgssgiYAfp9aapd45zhXPrvNObez5FuLDUGZ UgKoFZP7vGLktsGL5TswkStgN8T/XTViiwLl145M9SvLCve+DBRX16wTQyN76SVumdm1 XIAJzJYHHbNNrdbJOumCcnBqA5nz+/LaE3A5+N5Lm0qfUGp3Vz+Zac8Ak87sD/mEmc3R xLmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZBYlKQXO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020aa79405000000b0051be0158c97si4538155pfo.348.2022.06.03.14.48.49; Fri, 03 Jun 2022 14:49:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZBYlKQXO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241668AbiFCGxX (ORCPT + 99 others); Fri, 3 Jun 2022 02:53:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241525AbiFCGxR (ORCPT ); Fri, 3 Jun 2022 02:53:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDD763669D; Thu, 2 Jun 2022 23:53:14 -0700 (PDT) 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 8D510B8222F; Fri, 3 Jun 2022 06:53:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D4E4C34114; Fri, 3 Jun 2022 06:53:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654239192; bh=4kiwAXxTd5EFLJFklr/uinCBNS2WrG3A8QFkFVilo/Y=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ZBYlKQXOAG9cVfZy3IEd/nTYWdZLYIdW0bbc2KQpa9ePcizpeffMaiJcxOMI9Te8r mrmfLyjdfNKPXUzk2c8tYv56JfShBALH6wc7cvB2AnRbgqPwETeyjha6uw0evbNcdo rMDN9Ur8wCOO4OIvtJwLMtmgVD+oBBeznopvRA0OcEKKinIplReg1u73646gzrqakt 0s0iHYB2MNsPGsqPp2YGwIDLNT+ljyWUHq4G0QrQknAaBcY9Sb5wk6G6qhTaoH+Gcq dRWi02zoqp0ngnCCZ0MjxRBhhvJwuzXgK8Z4FGh8nfcqnpFQ7m4d4DAGYE+D6sFeKR 2DXj/gDrHJwoQ== Received: by mail-oi1-f172.google.com with SMTP id s8so4100172oib.6; Thu, 02 Jun 2022 23:53:12 -0700 (PDT) X-Gm-Message-State: AOAM530zekfoDHeMaa8aOJ6W5jF5iv/7cSlIGO9miI2JP3OBXeuGpiXz xmOCwstGfJTtbgpra05shXipyuum46pfxg0ORN4= X-Received: by 2002:a05:6808:300e:b0:32c:425e:df34 with SMTP id ay14-20020a056808300e00b0032c425edf34mr4652911oib.126.1654239191301; Thu, 02 Jun 2022 23:53:11 -0700 (PDT) MIME-Version: 1.0 References: <20220602212234.344394-1-Jason@zx2c4.com> In-Reply-To: <20220602212234.344394-1-Jason@zx2c4.com> From: Ard Biesheuvel Date: Fri, 3 Jun 2022 08:53:00 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] ARM: initialize jump labels before setup_machine_fdt() To: "Jason A. Donenfeld" Cc: Russell King , Russell King , Linux ARM , Linux Kernel Mailing List , Catalin Marinas , Stephen Boyd , "# 3.4.x" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2 Jun 2022 at 23:22, Jason A. Donenfeld wrote: > > 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()") Wouldn't it be better to defer the static_branch_enable(&crng_is_ready) call to later in the boot (e.g., using an initcall()), rather than going around 'fixing' fragile, working early boot code across multiple architectures? > 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(); > + Is it really necessary to reorder all these calls? What does jump_label_init() actually need? If this is related to the code patching, I wonder whether it wouldn't be better not to rewrite all the NOPs (this is a x86-ism as every new x86 uarch appears to have a better [faster?] NOP than the previous one) The issue with changes like these is that we might end up with bug report in ~3 months' time that 'obscure platform X no longer boots or produces any output'. In the best case, we'll have a bisect report identifying this patch, but we won't be able to simply revert it as it would reintroduce this issue into a kernel that is now stable. > 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 > -- > 2.35.1 >