Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3954309rdg; Wed, 18 Oct 2023 10:25:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0+dFjb5ZzH2p+BTaeB+Diii0La5yQS0mCX69kdCTPr1JLtwv6AT2cksY/O/7azLn2bK7E X-Received: by 2002:a05:6a21:3b49:b0:15e:bf2b:e6c8 with SMTP id zy9-20020a056a213b4900b0015ebf2be6c8mr5319439pzb.2.1697649906592; Wed, 18 Oct 2023 10:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697649906; cv=none; d=google.com; s=arc-20160816; b=fDHLyPve7imJugUs9CMo7ykrMcaGSGdufwr/tlCrZkxwwi989wGvkSVYxRpKJnzHRX XL0LN4sWvVkZVjveVv26aU/2pamNYY8kG8oALZAWExdxpb9eLPVAJiqRuHWYLSV3n5yi c8b/OFSOwRfOyKsEbdqnyCsFSPudJFonr5/QXphrj81E7/C24yVPB11n91M+lWX8Qzeg DvPB/PSt0Ok3QYSaLF0whU7H/NpnEa/4nc57L42Q1FXJiZylcxrVQEeG6jhWwYEsvDii sZ5tS0xHg5+SrVe+PDk6cqT1zklmQxLIe80ZEr8azltoyAlPGoquoy3+UaKv5GS6sAyI tLSw== 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=JGr+wt8mibKQk7V/xmPHf9oID5HtJ6aKoUQCNWyJYkI=; fh=H+zLew9COpjImfZW/7m535He/UK/q+/ga4lRW1i3Je0=; b=G3mIaTsbYsBiM88uT608bvTFiEjHeG5+v1id3kJdbup3/qtehSqUEMyIjaMBF1yhPC 2Z8dGANMrM3gNoeNzj9m5ar/aj0R0GkrcAgz6O4TMrLjr7O33+ktBiXmEy2nmiV1iwRf 5PIb0gZ+1A0NkCUKiq9RcFQN3/jXG5C8zi1ddbu2PkJ1bdcHSl3khKXCYrv39DVWX6la Je6wHGBwKqjAWIbPDQp5HxPJmaTjTuvjnSK/cV+gNs2Z/IbCifbrQ4lyT1w2RqS/x+dw GSx1TxLh8njVgAlib1zgGMu4ihTAhvEJDOMOK3aREKXoUe/4i44gAgVaLKZISqfYJUzZ kdFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=ssIAHBd6; 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 Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id mq2-20020a17090b380200b0027d23073d19si270489pjb.165.2023.10.18.10.25.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 10:25:06 -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=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=ssIAHBd6; 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 Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id B54DE8023AA4; Wed, 18 Oct 2023 10:25:03 -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 S229447AbjJRRY5 (ORCPT + 99 others); Wed, 18 Oct 2023 13:24:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjJRRY4 (ORCPT ); Wed, 18 Oct 2023 13:24:56 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8953B4482 for ; Wed, 18 Oct 2023 10:24:53 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2b9338e4695so95991241fa.2 for ; Wed, 18 Oct 2023 10:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1697649892; x=1698254692; 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=JGr+wt8mibKQk7V/xmPHf9oID5HtJ6aKoUQCNWyJYkI=; b=ssIAHBd6c/4fTV2H6cqWVl4JvFRuctqTiihxcorkMy6+Gnq2FKGTWRMMgB6SLzTj09 umOucqfIiNFYTVL8DJyWye2AGcDKPNzN7isZPIflFdmSIWyrtTXravm6OkVgGH7myDwE hAzQcYycD2CojE8wwGxmQfmcnztTME+OzHf9m1XEd6hASlvCG1Ryme9J1g8WW5faCNMl HtddF0/Vdk1l2V/YsXJXkQnbVBPYnE76/jKGrrDwFsk0kT/URJipZpMbw3afvoZkQ1JV tWXI05ziWsTen0ftM3GB5QQH84U8FXQCmkTpX4u1SWjT2nC51jR2rLMX8R7ShQS6ykE4 FHeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697649892; x=1698254692; 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=JGr+wt8mibKQk7V/xmPHf9oID5HtJ6aKoUQCNWyJYkI=; b=pqv/KtOPW888yGJo+P5iXo5esmd81j/7qdO8SBTUojukT5XRZhORLAWzOLGzaIZvlU kPretPUzhlcYlKLOM89oCTp8+lkuys102qWi0xhLm+zWqPDh3Kr4kszHaQEtuNQjV1Ux VCKyRNd/dXm9N8H7HZftuS/24icZLm568m2W8cRrPv0cxWAnLlwFd+zusGUyWs1oPFYs McY3FG6efhIYIUfrzcjVWQole+M97Du0ukSmu6Kn4e6hUfWvJ4tL9pl5/uHjFmvWYX/D sZ7vE6PUWJH2f9MB+ZGAP/ZxGseCbVSNt0/cmfJ0x+CyLzeTBvbsk9uD2tJUOnvupRFX 56Kw== X-Gm-Message-State: AOJu0YywNTNS8ggjMIkz5V5QBPhUPYfBHs1cloGHewS8Ah3HqYlWyGAQ Je2eHxQtyxfVtYI+wG6zNNPSwGL2Ur82p7CDREnr/Q== X-Received: by 2002:a2e:9b13:0:b0:2c5:3492:5d96 with SMTP id u19-20020a2e9b13000000b002c534925d96mr4576190lji.12.1697649891740; Wed, 18 Oct 2023 10:24:51 -0700 (PDT) MIME-Version: 1.0 References: <20231017131456.2053396-1-cleger@rivosinc.com> <20231017131456.2053396-2-cleger@rivosinc.com> In-Reply-To: <20231017131456.2053396-2-cleger@rivosinc.com> From: Evan Green Date: Wed, 18 Oct 2023 10:24:15 -0700 Message-ID: Subject: Re: [PATCH v2 01/19] riscv: hwprobe: factorize hwprobe ISA extension reporting To: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= Cc: 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 , Conor Dooley , 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 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:25:03 -0700 (PDT) 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_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_##__ex= t; \ > + else = \ > + missing |=3D RISCV_HWPROBE_EXT_##__ext; = \ > + } while (false) > + > + /* > + * Only use CHECK_ISA_EXT() for extensions which can be e= xposed > + * to userspace, regardless of the kernel's configuration= , as no > + * other checks, besides presence in the hart_isa bitmap,= are > + * made. This comment alludes to a dangerous trap, but I'm having trouble understanding what it is. Perhaps some rewording to more explicitly state the danger would be appropriate. Other than that: Reviewed-by: Evan Green