Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3961189rdg; Wed, 18 Oct 2023 10:36:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFu8dr9UTCf2eSwEyKL3k9EBXPofJjweZOWaUZfI4Pb9bXmVuZp0siGZ+yl/iRLOU0Jvq/R X-Received: by 2002:a05:6a21:7802:b0:172:913c:ba36 with SMTP id be2-20020a056a21780200b00172913cba36mr5192016pzc.24.1697650602018; Wed, 18 Oct 2023 10:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697650602; cv=none; d=google.com; s=arc-20160816; b=xD5TCENWOqmuqtI/D+bPxrAKWm1G1GPcc64w8JeyGS2GYIX1lIzZKd+jYtAEXLXvn9 /7C42aaZTvjzoppgwGI5dj/TzLoYOqV8yHc6fQF9gMNV/GF1+agmaTSZRbAFrlvtzfaa cT0phV9+L42ldtwn6rRvg3nmlXYwEeK+BndB6c9gE+k0hoEXFIsGArjwG01qymxWlDOf F/KDzCmwvnTFJS6vVZL4kus44f2CIbFfQH81ulv4W1HP6O6kwkd9PpAcLWs7lNTekj4W g0RvH5urzr/XVSxOyIEBdWPTCRhJdxb419OOS8DDohFlQjQQtBU0E2WEzHCJ9hya/btH ScNA== 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=DsNz8nBguu0G09cTg2WKE38NoK+JtJyHyqMsDVDkxHw=; fh=RL40afo3RORNQDMz9JI0DLM3FQgrsyylXv4cM8Lgxnk=; b=PICeXZU0glLbrNXEQBkQFP5mZrYZ1gWipXn/YGS6Q+eAV80+s5JyxQ0c5cYR189B4C l4EFjTMiXH1MtnCxKZXU2mhY99Lj4ZHNdbjo7E2wGhP2c6kcvcja+RQ+5vou92d/EUVU 6AXoT3eVkKQkk+lXrHwNRB1N807dJ4KTpHslTRjvvID9tMPTH253YJ4mTZriynzpbZ9e Zi+HLNnGzgcvZ+asBbA3VccIf3meDuBeK14fJR1EHNl9XoaYEEyrbB+gD4DqINH8GCfy MjBeSQ/rrtMHjdkdSCMd+SLpZvQzoZGH+qyyiHuSsLwasDknx3gna5FyeL3L/0LMmEBD iCyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KDQnIXWz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id q76-20020a632a4f000000b00563d9ff5157si2578886pgq.547.2023.10.18.10.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 10:36:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KDQnIXWz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 37B3780942C8; Wed, 18 Oct 2023 10:36:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229930AbjJRRgb (ORCPT + 99 others); Wed, 18 Oct 2023 13:36:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232364AbjJRRgT (ORCPT ); Wed, 18 Oct 2023 13:36:19 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A8953276 for ; Wed, 18 Oct 2023 10:33:40 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E13DC433C7; Wed, 18 Oct 2023 17:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697650420; bh=7zgoNI+OfIXrNzrN4IJbV0dCAC9KZrvxc9Xg9ZUOnCA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KDQnIXWzKC43dbxZfVTnVjok0UL7TPypYfSo/HySbMUuG2jPJP4OUM3mzUe7VM+gE mms9iV/gB1AkmMuuX2h3B+4zOOMVDBmag+h0mAFPbwlZOOUR8NT6UvFUflcrEZd3tR 6rBbh7Nps4NTqYoaNfonYLKr9tAKir7b6pxWW59kN4TVczo9qHM06AWoeITO/Hb5yM b8gAmfSmxcK8KUTCDDbWQXU+hUMb7NN0iqf5wYxSpsRrPEf3P9evlz3tm73XT6/5+1 nxAiDkzccHEhMGNuYhVedKK78y2GkNOdiZSTxVFQypjJ1V1HDjN+hw96NclMUD/myH 5HO+xeToqGGhw== Date: Wed, 18 Oct 2023 18:33:34 +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-scrap-bankable-a0f321d97a46@spud> References: <20231017131456.2053396-1-cleger@rivosinc.com> <20231017131456.2053396-2-cleger@rivosinc.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="cAVknSgQgov33/M7" Content-Disposition: inline In-Reply-To: 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 fry.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 (fry.vger.email [0.0.0.0]); Wed, 18 Oct 2023 10:36:39 -0700 (PDT) --cAVknSgQgov33/M7 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 more > > 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_risc= v.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_hwprobe= *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->isa,= __ext)) \ > > + pair->value |=3D RISCV_HWPROBE_EXT_##__= ext; \ > > + else = \ > > + missing |=3D RISCV_HWPROBE_EXT_##__ext;= \ > > + } while (false) > > + > > + /* > > + * Only use CHECK_ISA_EXT() for extensions which can be= exposed > > + * to userspace, regardless of the kernel's configurati= on, as no > > + * other checks, besides presence in the hart_isa bitma= p, are > > + * made. >=20 > This comment alludes to a dangerous trap, but I'm having trouble > understanding what it is. 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. > Perhaps some rewording to more explicitly > state the danger would be appropriate. Other than that: >=20 > Reviewed-by: Evan Green --cAVknSgQgov33/M7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZTAW7gAKCRB4tDGHoIJi 0nhVAQCLhafGLIz6kNxqBPqbvT0nF5pEAuym/4xsHPY7LR48wAEAyEIW4fTv7pLN AshYRoolc15bM671HyzLYWakxep6WAU= =CY63 -----END PGP SIGNATURE----- --cAVknSgQgov33/M7--