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 E13C5ECAAD5 for ; Tue, 6 Sep 2022 15:57:51 +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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CNlCuf4m4j922zkTkOODUXJmSNLKiRbyAtzQFQewUfI=; b=jPiffEHY/nMdmR nsN93SbUPVQ622pVJ0R4GvjheTkFgyO2aWmC4HS/gqE1Q6T3jGJC34XLbd+qSyJTuZpPOjgsjtSel l7Upq/OY3oFfMRcGdVBcp+9GB5snAGLG8/NNwgfCMlx+9NForPzDmNFADx66iEcXbVD7490IqGlvn FlrVXK1diGGRkgqaEZ9ROF95vkgeJSTetKtzhBXY8UU46ulxYtxqyMV92fhaeudIxGjS+5oxKWjWR YVgl6CUQkjtyWACSaN8X4PQVAgDheoAJE5QCVVeQ8mIz3lhwPpOzy3bnZpeeY9EL8CSlbk9g7iqcb 7yYUpp9T9wYqt1jurFOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVaw9-00F5oc-6q; Tue, 06 Sep 2022 15:56:29 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVaM5-00Eh9t-JL for linux-arm-kernel@lists.infradead.org; Tue, 06 Sep 2022 15:19:15 +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 sin.source.kernel.org (Postfix) with ESMTPS id 4DB56CE168E for ; Tue, 6 Sep 2022 15:19:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DD1BC433D6 for ; Tue, 6 Sep 2022 15:19:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662477548; bh=553tnvcIx2fR3ekX+1WUUNARakjcWE2QAe2PKX8hng0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ZJbjX8BjZ5B5Ul7MEW5V13D0kqmsqzTi2H/AtPjZEf9ViL60jhKNr6Dni8mQlGBD3 drTnxjPjX0/JcESskhW/IzQfcs+iaOYwQOgCpPGdXiXwwy+UnbmnYpuVMzw77Gm20C kl7C9Tkg+qVD4f4c7Kp0NvgfS55ofipGCIFknMQ/VsLQllmt5Kokt2wOcN5vSGIY5e y9MEkyK0ijVgX60ONLDpMfY1zyxSYpRfQXc0HCprMBm9ClbBDbcYtd2WDRZvgTxjQm ZJFbwziGGC3Z1awdLwYdfWV/JwOSBl9NsRjkyECbK2sbSdVxaJeEp3EO9cnpXvm+Vg R7vIY18z4He7w== Received: by mail-lf1-f41.google.com with SMTP id z6so17878312lfu.9 for ; Tue, 06 Sep 2022 08:19:08 -0700 (PDT) X-Gm-Message-State: ACgBeo1bLsFkIbysVXU09kfyl85X283PtQ2VQOqistHHeUsHqfTaXDwQ TdxLEQA3cM4R4dQe97PhbIaU7VO1TnZ2dPAryLw= X-Google-Smtp-Source: AA6agR4wGOZ/2u1Pp0ye/Dn8/GiCmCZMqs74DB5laMo1eIKIxuDwxTFP/EiYqwmO0s8Yg7MzcSifQy947eagX6CUSSU= X-Received: by 2002:a05:6512:3047:b0:494:716e:4f47 with SMTP id b7-20020a056512304700b00494716e4f47mr12559894lfb.228.1662477546181; Tue, 06 Sep 2022 08:19:06 -0700 (PDT) MIME-Version: 1.0 References: <20220901151403.1735836-1-mark.rutland@arm.com> <20220901151403.1735836-6-mark.rutland@arm.com> In-Reply-To: <20220901151403.1735836-6-mark.rutland@arm.com> From: Ard Biesheuvel Date: Tue, 6 Sep 2022 17:18:54 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 5/9] arm64: alternatives: make alt_region const To: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, james.morse@arm.com, joey.gouly@arm.com, maz@kernel.org, will@kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220906_081914_132301_329F0817 X-CRM114-Status: GOOD ( 28.12 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Mark, On Thu, 1 Sept 2022 at 17:14, Mark Rutland wrote: > > We never alter a struct alt_region after creation, and we open-code the > bounds of the kernel alternatives region in two functions. > > This patch adds a shared struct alt_region, and marks the alt regions as > const to prevent unintentional modification. > What is the point of struct alt_region? Can we just get rid of it entirely? It seems its only purpose is to carry a tuple that could easily be converted into start and end arguments to __apply_alternatives(). > There should be no functional change as a result of this patch. > > Signed-off-by: Mark Rutland > Cc: Ard Biesheuvel > Cc: Catalin Marinas > Cc: James Morse > Cc: Joey Gouly > Cc: Marc Zyngier > Cc: Will Deacon > --- > arch/arm64/kernel/alternative.c | 26 ++++++++++++-------------- > 1 file changed, 12 insertions(+), 14 deletions(-) > > diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c > index d94d97cb4a0bf..2e18c9c0f612b 100644 > --- a/arch/arm64/kernel/alternative.c > +++ b/arch/arm64/kernel/alternative.c > @@ -133,8 +133,9 @@ static void clean_dcache_range_nopatch(u64 start, u64 end) > } while (cur += d_size, cur < end); > } > > -static void __nocfi __apply_alternatives(struct alt_region *region, bool is_module, > - unsigned long *feature_mask) > +static void __nocfi __apply_alternatives(const struct alt_region *region, > + bool is_module, > + unsigned long *feature_mask) > { > struct alt_instr *alt; > __le32 *origptr, *updptr; > @@ -190,17 +191,17 @@ static void __nocfi __apply_alternatives(struct alt_region *region, bool is_modu > } > } > > +static const struct alt_region kernel_alternatives = { > + .begin = (struct alt_instr *)__alt_instructions, > + .end = (struct alt_instr *)__alt_instructions_end, > +}; > + > /* > * We might be patching the stop_machine state machine, so implement a > * really simple polling protocol here. > */ > static int __apply_alternatives_multi_stop(void *unused) > { > - struct alt_region region = { > - .begin = (struct alt_instr *)__alt_instructions, > - .end = (struct alt_instr *)__alt_instructions_end, > - }; > - > /* We always have a CPU 0 at this point (__init) */ > if (smp_processor_id()) { > while (!all_alternatives_applied) > @@ -213,7 +214,8 @@ static int __apply_alternatives_multi_stop(void *unused) > ARM64_NPATCHABLE); > > BUG_ON(all_alternatives_applied); > - __apply_alternatives(®ion, false, remaining_capabilities); > + __apply_alternatives(&kernel_alternatives, false, > + remaining_capabilities); > /* Barriers provided by the cache flushing */ > all_alternatives_applied = 1; > } > @@ -236,17 +238,13 @@ void __init apply_alternatives_all(void) > */ > void __init apply_boot_alternatives(void) > { > - struct alt_region region = { > - .begin = (struct alt_instr *)__alt_instructions, > - .end = (struct alt_instr *)__alt_instructions_end, > - }; > - > /* If called on non-boot cpu things could go wrong */ > WARN_ON(smp_processor_id() != 0); > > pr_info("applying boot alternatives\n"); > > - __apply_alternatives(®ion, false, &boot_capabilities[0]); > + __apply_alternatives(&kernel_alternatives, false, > + &boot_capabilities[0]); > } > > #ifdef CONFIG_MODULES > -- > 2.30.2 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel