From mboxrd@z Thu Jan 1 00:00:00 1970 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 2F227C433EF for ; Tue, 7 Jun 2022 09:25:59 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NrO1y+5VVfgHPs0AQ2sAPAmn0KK5gnryi02BbpJowEw=; b=xPLjouGMIm42F3 gt2ArWGzjlJ6Mr29mGWEh90F5qpXFihg/XhAbiIn9pYbJTn0qMQFXvG47JbnupoIAV9wJegkF2Cm7 9sCxi4p69ZgQerTO7NmNfDhJ/b11hsOKUh7V3DHceI59Zy4EgjssXYnQ6+dyARMEO8N4DOVzq7sFG I9asRXNA1xiQjJNdWwhu2S3w/l3rG5VFjhvk5rnwGEzCKRuMQQlbQHCMNILHnJzIyFOd9sw6edVHX ff8Bu2ze623JqiDN26/FVYMAkJCvD72NH7N82ligjZIRxgofiqjYK7bALoAFloGZqIqh2Vrk4zh5t vV+KqXv/OkQRx52UD9Gg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyVS0-006BmV-Ro; Tue, 07 Jun 2022 09:24:37 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyVJC-0067tZ-3e for linux-arm-kernel@lists.infradead.org; Tue, 07 Jun 2022 09:15:31 +0000 Received: by mail-wr1-x42a.google.com with SMTP id s1so124975wra.9 for ; Tue, 07 Jun 2022 02:15:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=message-id:date:mime-version:user-agent:subject:to:cc:references :from:in-reply-to:content-transfer-encoding; bh=s+usQNQe61fUNXtftBnDDPOoqNzLMBH21NqyRZq7YLo=; b=QcJFOZkr6N0djzaiBVtwqiI34B4U1YPZDK+qqBxhWRvksqYGTnrdJ2l7ks6TzStesp CLefRAOdeVlWHQFXzog5tGhwMpXNRIK8rxeKr1KewPQnqDMI/TEosM2Oyidtx2FgNDkv heHtFS1yJhRiiNE1d2ZfRmVJmmpFVWPWDGsMQ8KTW/BxHe6NXSsxnEnkGR9y2I+xCAN/ lYcVSSYtJoV2uSRZHEGaN8h+805AB5fGDQUfR352OQi25LWIjK+XwZ9DoHNTGmMZxafM rpdEA4LHFHBvqNW58ewZc2pwQN0+fcihCYVyXmOThiBzZpJGeS04EYqcHU9AEy3Vk76M fiZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :to:cc:references:from:in-reply-to:content-transfer-encoding; bh=s+usQNQe61fUNXtftBnDDPOoqNzLMBH21NqyRZq7YLo=; b=ZS+5OjNTAdvb5LPXcYFJfwCyIfHGFJGMMcjaJYSEu6xKsx/c0KzbsO+R+H7coLVW9Z cibQlGJ3++OCqZ6WiHgODlPqA2zlUIy685VW7QiVv29Xb9eD3Pd3b/6b0GCHRPAQyv/g mPSd7hPFQUDq53sK0mYKvzIBIqpmeArvZHyi8Y6L2lbyOLojH+XBZpHvIjPpKcMWN+Pv zCoLONFzNeOzKSH8qAMOX3PstOgA5ebJRlPLJ3jF6mWKg8AC2BsHnIrwc9E1EWq8RXzK JmUmZ1QkalVKTbpuU67CEdHPAaQoYEkvQUwb02DMNbH2ama8owry7mijLAB+1lBmnS6+ jWCQ== X-Gm-Message-State: AOAM531mXSqX8xObkoq9z/ac1ir1OL/H16BcBFfCQbBkp4aGW8yawNtc EJOzU/ciIVMJ6hH9DmwTmntQGw== X-Google-Smtp-Source: ABdhPJxHljRDXDB6metlo+Ntzo/NbEmYZujGJW4daxhb1Oxt07a0tqGsmnY141RzHKXAo+xezbaUFw== X-Received: by 2002:adf:fe0c:0:b0:218:4312:1230 with SMTP id n12-20020adffe0c000000b0021843121230mr7830352wrr.223.1654593327814; Tue, 07 Jun 2022 02:15:27 -0700 (PDT) Received: from ?IPV6:2a00:1098:3142:14:901f:dbcb:c1e4:e4b8? ([2a00:1098:3142:14:901f:dbcb:c1e4:e4b8]) by smtp.gmail.com with ESMTPSA id n5-20020a05600c3b8500b0039c4e2ff7cfsm6411598wms.43.2022.06.07.02.15.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Jun 2022 02:15:27 -0700 (PDT) Message-ID: <8c3fe744-0181-043a-3af9-dd00165a6356@raspberrypi.com> Date: Tue, 7 Jun 2022 10:15:27 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v2] ARM: initialize jump labels before setup_machine_fdt() To: "Jason A. Donenfeld" Cc: Russell King - ARM Linux , Russell King , linux-arm-kernel , LKML , Catalin Marinas , Stephen Boyd , Ard Biesheuvel , stable References: <8cc7ebe4-442b-a24b-9bb0-fce6e0425ee6@raspberrypi.com> From: Phil Elwell In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220607_021530_326347_0360DEF5 X-CRM114-Status: GOOD ( 25.00 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 07/06/2022 09:43, Jason A. Donenfeld wrote: > Hi Phil, > > On Tue, Jun 7, 2022 at 10:29 AM Phil Elwell wrote: >> >> This patch is fatal for me in the downstream Raspberry Pi kernel - it locks up >> on boot even before the earlycon output is available. Hacking jump_label_init to >> skip the jump_entry for "crng_is_ready" allows it to boot, but is likely to have >> consequences further down the line. > > Also, reading this a few times, I'm not 100% sure I understand what > you did to hack around this and why that works. Think you could paste > your hackpatch just out of interest to the discussion (but obviously > not to be applied)? This is the minimal version of my workaround patch that at least allows the board to boot. Bear in mind that it was written with no previous knowledge of jump labels and was arrived at by iteratively bisecting the list of jump_labels until the first dangerous one was found, then later working out that there was only one. diff --git a/kernel/jump_label.c b/kernel/jump_label.c index b156e152d6b48..7b053521f7216 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -466,6 +466,7 @@ void __init jump_label_init(void) struct jump_entry *iter_stop = __stop___jump_table; struct static_key *key = NULL; struct jump_entry *iter; + int iter_count = 0; /* * Since we are initializing the static_key.enabled field with @@ -499,7 +500,9 @@ void __init jump_label_init(void) continue; key = iterk; - static_key_set_entries(key, iter); + iter_count++; + if (iter_count != 1083) + static_key_set_entries(key, iter); } static_key_initialized = true; jump_label_unlock(); I'm sure this could be rewritten in a less fragile manner making reference to crng_is_ready directly, but this is where I got to yesterday. Ha! I just proved the patch's fragility by switching from a Pi 2 to a Pi 4, so the saner version is: diff --git a/drivers/char/random.c b/drivers/char/random.c index ca17a658c2147..ca7c8a67b8314 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -79,7 +79,7 @@ static enum { CRNG_EARLY = 1, /* At least POOL_EARLY_BITS collected */ CRNG_READY = 2 /* Fully initialized with POOL_READY_BITS collected */ } crng_init __read_mostly = CRNG_EMPTY; -static DEFINE_STATIC_KEY_FALSE(crng_is_ready); +DEFINE_STATIC_KEY_FALSE(crng_is_ready); #define crng_ready() (static_branch_likely(&crng_is_ready) || crng_init >= CRNG_READY) /* Various types of waiters for crng_init->CRNG_READY transition. */ static DECLARE_WAIT_QUEUE_HEAD(crng_init_wait); diff --git a/kernel/jump_label.c b/kernel/jump_label.c index b156e152d6b48..b79de9da036fd 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -484,6 +484,7 @@ void __init jump_label_init(void) jump_label_sort_entries(iter_start, iter_stop); for (iter = iter_start; iter < iter_stop; iter++) { + extern struct static_key_false crng_is_ready; struct static_key *iterk; bool in_init; @@ -499,7 +500,8 @@ void __init jump_label_init(void) continue; key = iterk; - static_key_set_entries(key, iter); + if (key != &crng_is_ready.key) + static_key_set_entries(key, iter); } static_key_initialized = true; jump_label_unlock(); And to answer your questions from the other thread: * Without any fixing patches we see the warning messages because we are using rng-seed in DT. * I've seen the problem on a Pi 2 and a Pi 4 running 32-bit kernels. Phil _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel