Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2941101iob; Mon, 16 May 2022 09:27:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxnyGbthafDoVE4F2roDLu9m9WEvKfLrf1ibLB8/gdIEh9U7ud/wn8MRD0QbVakrrDDzyz X-Received: by 2002:a63:5211:0:b0:3db:1c36:fc37 with SMTP id g17-20020a635211000000b003db1c36fc37mr15461264pgb.572.1652718430939; Mon, 16 May 2022 09:27:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652718430; cv=none; d=google.com; s=arc-20160816; b=zDKj8pudpCTAlOWlAhHiE1o8z/PEgyJuFq38jEcBlM2zN2uCDS4OLWjyRbKxJFXfiV 4I5wPBONa/lb6YfyLvuC00/ZUHofzmuIkLNzPf8bMpcyc6TKiMscZlUHQumcdakMpdEQ 7tXyjI53mzspECfUazBG4mraR5Nn1ib4wl7Fkjn0IJFbN027zrv5/l8shweyiqJzI67H KfmqXPRFJ+vwpt0iN00M0/VSOYSjfTZf2VfKZ5FTRlHkf6XzrC1IMKaQzWx9MMy9WTAH tGGvEmcyoLUln0iaWBB7iJQGviLOzo5ueio2CAdtu2UI2hOPIytISzZBkoMAe/O3g+YF f8XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=wf5zmkN79PNF74jfiomEoSEDmBebJtV7qZ8LdLtnUmA=; b=gp951LLtjTga0sguR0zNu0ccZ1aPeZv2QO/L9KDbfkjJVuiE1VTb5sU1/uAxBCgsY1 OR9Ui19dMaeQuCOvc03v4si8WqnjxD96uczPbsrreT54g5S/zr8MKMlrKM+ZhCApFg3f SxuCXqeBgG5f5HWYPdCxkR8EE7KRvyUinQ78i13oHt+26OXHpAf+5HgvDodRa3RhgFTE x6P2MZPDlEkWnRSI7rJi9cyjhc+7N5sS+uM0oQ3acL95REcUIQo7MUKmUOLRDKkrRsKz 1svNE5Lnv9DAmr+1+JpcT6VCd4aADOzyEsuxUyPLcPt5xEOBmEBF4fCzOpg50ZTJTXpP LBgg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s42-20020a056a0017aa00b0050a9644da4esi14157317pfg.335.2022.05.16.09.26.51; Mon, 16 May 2022 09:27:10 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240150AbiEPGPv (ORCPT + 99 others); Mon, 16 May 2022 02:15:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240114AbiEPGPt (ORCPT ); Mon, 16 May 2022 02:15:49 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F0C820F72 for ; Sun, 15 May 2022 23:15:48 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id 1FF2768B05; Mon, 16 May 2022 08:15:42 +0200 (CEST) Date: Mon, 16 May 2022 08:15:41 +0200 From: Christoph Hellwig To: Heiko Stuebner Cc: palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, wefu@redhat.com, liush@allwinnertech.com, guoren@kernel.org, atishp@atishpatra.org, anup@brainfault.org, drew@beagleboard.org, hch@lst.de, arnd@arndb.de, wens@csie.org, maxime@cerno.tech, gfavor@ventanamicro.com, andrea.mondelli@huawei.com, behrensj@mit.edu, xinhaoqu@huawei.com, mick@ics.forth.gr, allen.baum@esperantotech.com, jscheid@ventanamicro.com, rtrauben@gmail.com, samuel@sholland.org, cmuellner@linux.com, philipp.tomsich@vrull.eu Subject: Re: [PATCH 11/12] riscv: don't use global static vars to store alternative data Message-ID: <20220516061541.GA12877@lst.de> References: <20220511192921.2223629-1-heiko@sntech.de> <20220511192921.2223629-12-heiko@sntech.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220511192921.2223629-12-heiko@sntech.de> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,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 Wed, May 11, 2022 at 09:29:20PM +0200, Heiko Stuebner wrote: > Right now the code uses a global struct to store vendor-ids > and another global variable to store the vendor-patch-function. > > There exist specific cases where we'll need to patch the kernel > at an even earlier stage, where trying to write to a static > variable might actually result in hangs. > > Also collecting the vendor-information consists of 3 sbi-ecalls > (or csr-reads) which is pretty negligible in the context of > booting a kernel. > > So rework the code to not rely on static variables and instead > collect the vendor-information when a round of alternatives is > to be applied. > > Signed-off-by: Heiko Stuebner > Reviewed-by: Guo Ren > Reviewed-by: Philipp Tomsich > --- > arch/riscv/kernel/alternative.c | 51 ++++++++++++++++----------------- > 1 file changed, 24 insertions(+), 27 deletions(-) > > diff --git a/arch/riscv/kernel/alternative.c b/arch/riscv/kernel/alternative.c > index e6c9de9f9ba6..27f722ae452b 100644 > --- a/arch/riscv/kernel/alternative.c > +++ b/arch/riscv/kernel/alternative.c > @@ -16,41 +16,35 @@ > #include > #include > > -static struct cpu_manufacturer_info_t { > +struct cpu_manufacturer_info_t { > unsigned long vendor_id; > unsigned long arch_id; > unsigned long imp_id; > -} cpu_mfr_info; > + void (*vendor_patch_func)(struct alt_entry *begin, struct alt_entry *end, > + unsigned long archid, unsigned long impid, > + unsigned int stage); Please drop the confusing vendor_ prefix for the function pointer while you're at it. The vendor id is just one of three inputs for the patching. Otherwise this looks good: Reviewed-by: Christoph Hellwig