Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3962045rdg; Wed, 18 Oct 2023 10:38:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGUK51zgYR6XHavK+b6uhPFuiQZIpNL9pdDiS8B0wBvJOseRQ+Zd4Wz8dloXF/9MB8uLiYw X-Received: by 2002:a05:6e02:2146:b0:351:4f0c:b966 with SMTP id d6-20020a056e02214600b003514f0cb966mr32212ilv.20.1697650692674; Wed, 18 Oct 2023 10:38:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697650692; cv=none; d=google.com; s=arc-20160816; b=f1Zo3Nvx2WGstjBTjwP3DN/wS1gOQr+tAqFjWIXfzsC4ubmHBdbmLDQutQ4P4Tjmed o6U8sCVLd2X8NOAckjIOkIeU4W9bPj2oo+FcXXFoQ59ohENeTq0L0Sd/ftpMcNj7+Z3W wIPVP9IoQTv9cI77nlS2XR61res9aR8X/g0DD/wW0NKqn1lHTPHjVDUNNuE2Nu2Mx8wS aZ3rSu7Pbb6q42ZAMuwOvZVCA7fcMf4GH3/w0A4Ah+GCjvnm69qBarHBG92OKU8f+X2z BY0ETtidKjm6IDLMWUhVBt2qHNdqOFM1wMu3Xfcq79P24/XJUQSuWxAn3lA2m7Yqy1Oh QUIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XZkhT1Wgghb3tsPJM28QqmFbMGAe0la4cA7ocGj8Fzs=; fh=RL40afo3RORNQDMz9JI0DLM3FQgrsyylXv4cM8Lgxnk=; b=mQ3ym3xMqyh4wnIeqzzMXB+uJ+LnS4xT5qoKIcicEVjnXqcYT/1v5Y7n5F/Vlr8uhJ 6EwooV9cU3L7NpZ8/inbl5h6IZYAy962ZEzEsK+fkJ/NOdYMRq60jbHLfV+cmADHasJS mK5rqggPnljHZfpuAkk3Zls18UeeZPgHMCqvIFMivU1Q+bYwTXTHgksyf33Gc5M8HBEp cxDU4fV7lEi/sDDPGIXKd8rD7oELPiTguASlluAL0Blms5c1I/ooikcPwjIFF9w3t0wM kKWE79rNRHZW9cnp2iMxk6ZgpkVHVHtV+uGy82JyRn/lGeyOxeHGHfaSuAllm6jycXET BuKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PGoxBFH7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id cj11-20020a056a00298b00b0069d1639f09esi4137727pfb.190.2023.10.18.10.38.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 10:38:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PGoxBFH7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 091948205FF2; Wed, 18 Oct 2023 10:38:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230421AbjJRRiB (ORCPT + 99 others); Wed, 18 Oct 2023 13:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230234AbjJRRho (ORCPT ); Wed, 18 Oct 2023 13:37:44 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FD92122 for ; Wed, 18 Oct 2023 10:37:05 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1483BC433C8; Wed, 18 Oct 2023 17:37:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697650624; bh=oFj2hOD0FJcu+azHgKmYICzh2htgdd2Wv5h+L8tXxW0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PGoxBFH7kFpGXuNXarPS4c99yt2NmcMHGAG61xiXgEWbuhSQUwdufy6ZcWmie//K6 2jQuz48qza50itX3m+nM3m+zLLxqwx5TNu/1H8FtrTLZESdAtSePpowbxfuT5Som1/ QPL/LCRRiN+oL3q8cCeBAmbndhX3IOgO4kT4U2yMaWE5XkgV9R+nRpulbZ124R93cJ ungaM9yiPw1lhiU37GjtiwsYnLFvTSZ0OBc7Sy8iwKvJ72tQYuRo9EIulRnA6DnKE0 A219HIJQcfYQmv5RCfbfUtzRYWo0CbTk1gzcwIa6Ca9T1AZrZdCczZZ1/wFytbveoI 7iGVvpM33p3iQ== Date: Wed, 18 Oct 2023 18:36:59 +0100 From: Conor Dooley To: Evan Green Cc: =?iso-8859-1?Q?Cl=E9ment_L=E9ger?= , linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Rob Herring , Krzysztof Kozlowski , Albert Ou , Jonathan Corbet , Andrew Jones , Samuel Ortiz Subject: Re: [PATCH v2 01/19] riscv: hwprobe: factorize hwprobe ISA extension reporting Message-ID: <20231018-flagpole-footpad-07a6228485f3@spud> References: <20231017131456.2053396-1-cleger@rivosinc.com> <20231017131456.2053396-2-cleger@rivosinc.com> <20231018-scrap-bankable-a0f321d97a46@spud> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="cYWeMTHrHEjyZ4VV" Content-Disposition: inline In-Reply-To: <20231018-scrap-bankable-a0f321d97a46@spud> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 18 Oct 2023 10:38:10 -0700 (PDT) --cYWeMTHrHEjyZ4VV Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 18, 2023 at 06:33:34PM +0100, Conor Dooley wrote: > On Wed, Oct 18, 2023 at 10:24:15AM -0700, Evan Green wrote: > > On Tue, Oct 17, 2023 at 6:15=E2=80=AFAM Cl=C3=A9ment L=C3=A9ger wrote: > > > > > > Factorize ISA extension reporting by using a macro rather than > > > copy/pasting extension names. This will allow adding new extensions m= ore > > > easily. > > > > > > Signed-off-by: Cl=C3=A9ment L=C3=A9ger > > > --- > > > arch/riscv/kernel/sys_riscv.c | 32 ++++++++++++++++++-------------- > > > 1 file changed, 18 insertions(+), 14 deletions(-) > > > > > > diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_ri= scv.c > > > index 473159b5f303..e207874e686e 100644 > > > --- a/arch/riscv/kernel/sys_riscv.c > > > +++ b/arch/riscv/kernel/sys_riscv.c > > > @@ -145,20 +145,24 @@ static void hwprobe_isa_ext0(struct riscv_hwpro= be *pair, > > > for_each_cpu(cpu, cpus) { > > > struct riscv_isainfo *isainfo =3D &hart_isa[cpu]; > > > > > > - if (riscv_isa_extension_available(isainfo->isa, ZBA)) > > > - pair->value |=3D RISCV_HWPROBE_EXT_ZBA; > > > - else > > > - missing |=3D RISCV_HWPROBE_EXT_ZBA; > > > - > > > - if (riscv_isa_extension_available(isainfo->isa, ZBB)) > > > - pair->value |=3D RISCV_HWPROBE_EXT_ZBB; > > > - else > > > - missing |=3D RISCV_HWPROBE_EXT_ZBB; > > > - > > > - if (riscv_isa_extension_available(isainfo->isa, ZBS)) > > > - pair->value |=3D RISCV_HWPROBE_EXT_ZBS; > > > - else > > > - missing |=3D RISCV_HWPROBE_EXT_ZBS; > > > +#define CHECK_ISA_EXT(__ext) = \ > > > + do { = \ > > > + if (riscv_isa_extension_available(isainfo->is= a, __ext)) \ > > > + pair->value |=3D RISCV_HWPROBE_EXT_##= __ext; \ > > > + else = \ > > > + missing |=3D RISCV_HWPROBE_EXT_##__ex= t; \ > > > + } while (false) > > > + > > > + /* > > > + * Only use CHECK_ISA_EXT() for extensions which can = be exposed > > > + * to userspace, regardless of the kernel's configura= tion, as no > > > + * other checks, besides presence in the hart_isa bit= map, are > > > + * made. > >=20 > > This comment alludes to a dangerous trap, but I'm having trouble > > understanding what it is. >=20 > You cannot, for example, use this for communicating the presence of F or > D, since they require a config option to be set before their use is > safe. Funnily enough, this comment is immediately contradicted by the vector subset extensions, where these CHECK_ISA_EXT() macros are used wrapped in has_vector(). The code looks valid to me, since has_vector() contains the Kconfig check, but does fly in the face of this comment. >=20 > > Perhaps some rewording to more explicitly > > state the danger would be appropriate. Other than that: > >=20 > > Reviewed-by: Evan Green --cYWeMTHrHEjyZ4VV Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZTAXuwAKCRB4tDGHoIJi 0ssgAQCFsE/VyWSVFRI6XGd2p+Q+D0bkhT1pEi2sRvGHdVIbwAEAlRpXF0hcPhDv uK+YFm8QJY4dKBMhZ6EtzbVoIv6ctA8= =a1cl -----END PGP SIGNATURE----- --cYWeMTHrHEjyZ4VV--