Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3966358rdg; Wed, 18 Oct 2023 10:46:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNWpKpYpV6jfRnMlWv7P+6dAhFuqu1ciLLMH7xlqxKqZvad5vZv8xkfArBqxgbsKdMQaaD X-Received: by 2002:a05:6a20:3c9f:b0:17b:3917:ad39 with SMTP id b31-20020a056a203c9f00b0017b3917ad39mr3448237pzj.48.1697651174358; Wed, 18 Oct 2023 10:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697651174; cv=none; d=google.com; s=arc-20160816; b=gLC58668QoUQ9BSjRxAoS0JdqEKG8t5GfrlexQsBzdOJuTZmCgyq4pqyq2AWgGul85 RKD9XlB+KakTUm41737hxAkr/Af2Cgwb2lWyt8/1N0srEhbrUVWYgOoGmHBnK/xOhAkW vHcnMUA8gkGbdIBRC00yIZN6OXJfsDXOjc8rL8VMo3Yu1WnsdpW4XFFpWnMdNRrYTcQ1 1JG1FDotB39pBChbWsUyOUoCbImqcen8c7kMqoCeYCJsmipmTktPAL/YEDSCCsLfJM5p rnh4rDYzNSVTQHoAL5uhMHl5Bvx7Eld/Psd7nOXuXEB6y4UcgTGx2cg3RkgEjvuK0W0g Q75g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=xHadPeMbwC2xjZjhyzQo2TzXpSpoTFPJhsEQY4iQg+4=; fh=x/1W7CQAP0Zamorwdd1LP2ydmqHXvHlV5oFM09yhmKM=; b=DAV/48TUVtGSZUDt6gZ+Fa+tJ1adCy6vouunggH5fxu7J24Gm+ZbGRPiU2/6Hq/Jdl +K0+60cKnVGbQqXnazZMjKqHCZ8tt4hPWEZmo9WrNVT42V8tMHryVOUT1J9Q1ca7vNND xkx7tP0jfYZVYQfpGSM/4WRdhijGg71ndBazgcX8IRCOYhPonqE5RKltU+8IW0rMnNYy VJXTBExKmSt7U/Xn+bW36s2EyW7rJYEVPQRmHf1VZsozE7VQZrNaQZgUjxCPJ2V7cG7B BqaigtcwGeKn5ZgfkQsbuo0MI0UFkm89zHaP6mGIUrAb6Njs0j+bX206HFLjJ8B5tIQA Lz/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=cyiiL9MM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id 138-20020a630090000000b005abf640eec5si2803947pga.171.2023.10.18.10.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 10:46:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=cyiiL9MM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id F144F8027F07; Wed, 18 Oct 2023 10:46:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229998AbjJRRps (ORCPT + 99 others); Wed, 18 Oct 2023 13:45:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbjJRRpr (ORCPT ); Wed, 18 Oct 2023 13:45:47 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C282114 for ; Wed, 18 Oct 2023 10:45:44 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2c4fe37f166so88280411fa.1 for ; Wed, 18 Oct 2023 10:45:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1697651143; x=1698255943; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xHadPeMbwC2xjZjhyzQo2TzXpSpoTFPJhsEQY4iQg+4=; b=cyiiL9MMewyKAI3dniJbe8vLlv+W/e98+o9jjMnvP8/bozHaiDJdZNuYub+Y4H9dDD xU0q4X43d49/7aqljTWHCrCw2sYseYxTDJ29i49E8KSVDWUAdA4NqZQ6JQK+qgSMVcGo /K4YMbkuSYJ3Q4RsFCKf6Tgfv5c63CuPg046tpS707IIcNIOPGswUuYI8HzZ3PzmVah0 f9Y/CetrnhQCzT2K+RG1Ouy+3Pp/eqLYDYEVGZ/vLEQz2g493l41AT89dSBJjHezE7f1 uDGaJ6GFvNMUvrRUk1FluAECAQEzgwc3gUyX7ZpQa2oDmMIL50Od/vvkyufAc+bWV/vf JAwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697651143; x=1698255943; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xHadPeMbwC2xjZjhyzQo2TzXpSpoTFPJhsEQY4iQg+4=; b=Rb4n5Y3r+vnXCBmvrou0UiGH5QZPJn7NMpknVs/DMGoGkzBvQf35VIRyN85PXJtYVu BIdXJVWMwUzObK9vttzUR2qRhK6ckcRmM7cG88W09i0hETNBleeSNmb71V/CuFoOsKSE EusXXWBzyAAT8PDNAE3Xp+U6UzBGdyfc/keDGcKCulS6TqImt4uoaw9hHq+iGAPJFxAF RPpCHgZG7QPFv4mPQCo82N6x58JGRU1BFeTiQKTkrKO7RhmBW17dXTH9QWrT4KgW7jBm O4UlCPP3LPD2K+DWgPnYjb8HtYgHz3dJ2G0zTTNVvgIp0nJtT3DJUXFTN33joQoy09fS M56Q== X-Gm-Message-State: AOJu0YyplVALE08iIKRlALF861vDibIEIOHKhR2Agr4nzv/mKkfU/yJt upvwWh9/PR7TmfwyhJolIgIWSTbAl024MwnjONbndw== X-Received: by 2002:a2e:b8c5:0:b0:2c5:8db:1c7b with SMTP id s5-20020a2eb8c5000000b002c508db1c7bmr5726942ljp.2.1697651142704; Wed, 18 Oct 2023 10:45:42 -0700 (PDT) MIME-Version: 1.0 References: <20231017131456.2053396-1-cleger@rivosinc.com> <20231017131456.2053396-2-cleger@rivosinc.com> <20231018-scrap-bankable-a0f321d97a46@spud> <20231018-flagpole-footpad-07a6228485f3@spud> In-Reply-To: <20231018-flagpole-footpad-07a6228485f3@spud> From: Evan Green Date: Wed, 18 Oct 2023 10:45:06 -0700 Message-ID: Subject: Re: [PATCH v2 01/19] riscv: hwprobe: factorize hwprobe ISA extension reporting To: Conor Dooley Cc: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,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 howler.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 (howler.vger.email [0.0.0.0]); Wed, 18 Oct 2023 10:46:02 -0700 (PDT) On Wed, Oct 18, 2023 at 10:37=E2=80=AFAM Conor Dooley wr= ote: > > 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= 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_= riscv.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_hwp= robe *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 ca= n be exposed > > > > + * to userspace, regardless of the kernel's configu= ration, as no > > > > + * other checks, besides presence in the hart_isa b= itmap, are > > > > + * made. > > > > > > 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 o= r > > 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. Ohh, got it. The word "can" is doing a lot of heavy lifting in that comment. So maybe something like: "This macro performs little in the way of extension-specific kernel readiness checks. It's assumed other gating factors like required Kconfig settings have already been confirmed to support exposing the given extension to usermode". ... But, you know, make it sparkle. -Evan