Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp7234599ioo; Fri, 3 Jun 2022 02:25:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIgmFJkClyKHKyU5em8jx1T9AI3eQV3isX0zNDMuBX8Mgpg/21pFXNXPMBptdCUmkUwW/q X-Received: by 2002:a17:902:cecb:b0:163:fc74:b6a8 with SMTP id d11-20020a170902cecb00b00163fc74b6a8mr9185389plg.82.1654248318883; Fri, 03 Jun 2022 02:25:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654248318; cv=none; d=google.com; s=arc-20160816; b=GsASrMLdPD9r04PhxFfBrD34tR75We5yvE38bYBH07iio3CoY3NpfNPIkVpzGPhKrJ 65WIiRV+dUecCGutYQvZXEskZdc4InLhrg6sFm1iDhw5RUYHFUbDnYyQjy0q4gVFDcfT IV44DSNo/kukTCJ/FQ/hnR7Vvmo93oW2KLu2EaZZQd8ALhIzHc+kFCq/l9HMwsCUO5MJ oyJLkZVOIyaxs/ItjPJixbwIHLc4rwxWIqK8t7TPAZh1o2I4bXdOkmZ3zS07ftDnAuYY DkNgnEdTfGHGsbZvVGPwQiN9gq74cNXO4ipgNIv+Eig0f7kQ2DTCO+mTOQHXj4iwGgJD 5W9w== 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=GCNqehCCOBaJLSCnQ2JT5FXplS98RKaIe2sS11yCEg8=; b=mjwNLtbMtt0AqPdybupQ50B8YpZ6LGxCszO+kFAkqI3iKpeZhbNH40we4agWQ8Qz71 27jKkJL3s6zFCICBOMYJSdA3MDq7NFqSaXnKKipccz3zDTan/VzG1+Nmgs6QPb5sV59M bXU/4CvPoZlQNt1CcOGu9YVwCht03Mbg3J+d6BykaaQoqTMsUjm0KBEaN9c2LYqOXZmj Twmn1dvn0iemY6Q43l/WHUk5C+YFKrzNsjSjgvZcupa8+gy0Dg0h1sGtUTwZJodmd4NM cV5ZgnXxdcLY7u2y8jMYSaCF8TfTqRlAkNFvTgg2FGLTPPZEPv3t0RqscAKMku29JEDD Ndlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KyCuNu85; 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 ng16-20020a17090b1a9000b001d27c72d7c9si15440350pjb.17.2022.06.03.02.25.05; Fri, 03 Jun 2022 02:25:18 -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=KyCuNu85; 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 S242609AbiFCHv6 (ORCPT + 99 others); Fri, 3 Jun 2022 03:51:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242395AbiFCHv4 (ORCPT ); Fri, 3 Jun 2022 03:51:56 -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 E15A2BC8; Fri, 3 Jun 2022 00:51:53 -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 A6547B8213E; Fri, 3 Jun 2022 07:51:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CFAAC34114; Fri, 3 Jun 2022 07:51:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654242711; bh=F6fAf2H6hEuWT2QfME2T7wKPqzsyRfWDVYtaxh8qcOo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=KyCuNu85SmYu+/nw/enKejVqqpWoVN5/rbpg3kQ2wSnlvUBIcqeLGnnmfjTyYcM3Q zm6QZsx0hVk2euVnnW8XMakFi6lUu/hlUmNFmO5FThEKP5FDbJUs8HNfiFXAWS01yE bbBb0G1MQEkyuRZcC74sTuA6p7tK9Q4VV53z9br4AJTtZlvlKEsknr9n9YUupFy1UB visVssr2bFcV3RSh3OJfFEgrGU+UodlWffjs3iAF/SS9IjlMLFSva8SVJ/f0bH+pjq mG5tom24OvXjqjD8G9Ar6YEHf8KIQ0WKsbdUR+lx3gtm7xGUDNNFyK8GWiYsdt+AU8 5rWV/HEJKTYwA== Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-f2cd424b9cso9717098fac.7; Fri, 03 Jun 2022 00:51:51 -0700 (PDT) X-Gm-Message-State: AOAM5305Y5QfZ11pkFZ+hxmVMHCp68YOcdZbGflEraYcwWwOkyCcAtKc f/3F3Snawz0eOl3LT11toiN1SS9yibMk2WOzAbg= X-Received: by 2002:a05:6871:5c8:b0:f3:3c1c:126f with SMTP id v8-20020a05687105c800b000f33c1c126fmr4936557oan.126.1654242710568; Fri, 03 Jun 2022 00:51:50 -0700 (PDT) MIME-Version: 1.0 References: <20220602212234.344394-1-Jason@zx2c4.com> In-Reply-To: From: Ard Biesheuvel Date: Fri, 3 Jun 2022 09:51:38 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] ARM: initialize jump labels before setup_machine_fdt() To: "Jason A. Donenfeld" , Greg Kroah-Hartman 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 (+ Greg) On Fri, 3 Jun 2022 at 09:37, Jason A. Donenfeld wrote: > > Hi Ard, > > On 6/3/22, Ard Biesheuvel wrote: > > 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? > > Yes, maybe. It's just more book keeping that's potentially > unnecessary, which would be nice to avoid. I wrote a patch for this > before, but it wasn't beautiful. And Catalin got a pretty easy arm64 > patch queued up sufficiently fast that I figured this was better. > The problem is that your original patch was already backported as far back as 5.10, and so this fix will need to be as well. Playing with the code that runs before the call to setup_machine_fdt() is risky because it implies that issues that are introduced are likely to limit the ability of the system to generate diagnostic output of any kind, given that the device tree is what describes the topology of the system to the kernel. Before that, there is no serial or graphical console, and the only way to figure out what goes on is to connect a JTAG debugger and single step through the code or dump the contents of __log_buf[]. I like the /dev/random work you have been doing but as you know, I was skeptical about the need to backport all of that work to -stable, and it appears my skepticism may have been justified. The patch in question is an unquantified performance optimization, which means it does not meet the stable-kernel-rules.rst criteria, but it was backported nonetheless. Now, we are in a situation where we must refactor very early boot code to address a regression introduced by that backport. > > > >> 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? > > I'm not quite sure, but it matched how arm64 does things now. Was > hoping somebody with deep arm32 knowledge (e.g. you or rmk) would be > able to eyeball that to confirm. > As far as I can tell, the early patching code on ARM does not rely on the early fixmap code. Did you try just moving jump_label_init() earlier in the function? Also, how did you test this change?