Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp175280rdb; Thu, 19 Oct 2023 00:27:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXUlQCnrMC6xfmtW3IOkR7/8rWStTcTSlfw71uCK3PsLkPBT1y2Ck/aaOtZ7FFUO85kxlS X-Received: by 2002:a05:6a20:3d07:b0:128:ffb7:dcfe with SMTP id y7-20020a056a203d0700b00128ffb7dcfemr1624885pzi.1.1697700420976; Thu, 19 Oct 2023 00:27:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697700420; cv=none; d=google.com; s=arc-20160816; b=PW4ZWI0XwW4lwqux9jxUUzQ08W1wYw/ITb0LRQqOajNVL/10XUG8NldBUxFWJmt8Zr ZiDcE39kBF3nSdizs+lNNlpU4BDjoqIUszvY9W4O4jDiSmbloPjwKu7qXaJtidp6Gxp5 DvlnVjhM6nwa8ig6aXqsvg65a5jJFEO2UvaiaqA5/y8R6y/RlySl0xud/B1t8EfAK3Ei N8EilvlQeZIf+MsQ7jrG9VH3niZZHeKncx8S9cXOYj6JszKa1npKNk7oIiDfz/6nbkML 0ApgdVjE1oH5ci//5jQeHKObs9+u8FCPz/dkF6FNSeCxwGg31NECYAItpDKiFDccDlIl M2KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=wgTcFnd2WuQ3b93x6mtXxA5MmL51CRaK2ux9aDnBicU=; fh=DKqf/QS5W7noB3Gs0wwQiApqtBq2spSi/7Thk9KlhQk=; b=RDDKohUKVkm91+vQqLKmZyGiRbW+T5CGsdcoDZYkyflPZ+DIYro76WPMVWpZi9otlU ZBrveBQYpxYOmM8aFot8mI5smPCy9CMHnz0NVzRzI8OfD4BIyAOLNgMImPMf6T7vrukD X+oO2CRICmg5AUCfitQXRKrJxBvVeWmBVhmvUsmrPANe+crHFabgLGvtMwRlYi9O3xRf +k45s3ETQXyblEhSSRzO6fKA0976MmyQ6m+jBCInH+DF2hIWv1izXZAI2FMUMPiJZGY/ bSf+1WE8ehu5h7qO3Iec70iIPZTNzO+3sPl1V/JVVa9FOTAckjkQWKR9ZFLJkeCdmoO2 qe5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=ALgjGUGV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id o5-20020a655205000000b005b5c924a6c5si3423922pgp.441.2023.10.19.00.27.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 00:27:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=ALgjGUGV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id D16BB809F387; Thu, 19 Oct 2023 00:26:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232854AbjJSH0s (ORCPT + 99 others); Thu, 19 Oct 2023 03:26:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232326AbjJSH0r (ORCPT ); Thu, 19 Oct 2023 03:26:47 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 578A4112 for ; Thu, 19 Oct 2023 00:26:44 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6bbfb8f7ac4so1075526b3a.0 for ; Thu, 19 Oct 2023 00:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1697700404; x=1698305204; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=wgTcFnd2WuQ3b93x6mtXxA5MmL51CRaK2ux9aDnBicU=; b=ALgjGUGVojPdKw06M7V19ORNMHqFpjA1hO9W+3LMyeQym7l7C94maxnHf2Z7AoB4/Q O2cHH3+hGhxUecr0INsYtr2w7u/f9lPLywibkhBH8WlaAGBp4TBy/pK6JLZf1JPzbTRH kLb1o5T0fErCDrFFnBdfwlLYb20q1qVMczrxHzjQtFDnRdlqyogygvyGOS9PFcesXU4U MZHX+ZBRvP7VFTXFyL6NRf9ZwlEPJO1i9SEwnFdQpIeClYhdaLRD6JvHQVuP/h3sqywf 4fIu8+0DRMFDjVxxySHqhGMaukYuUMj8iFV+WPVUHAMe/GqaBEqDgQI05jO5xr3RLT1G cj/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697700404; x=1698305204; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wgTcFnd2WuQ3b93x6mtXxA5MmL51CRaK2ux9aDnBicU=; b=Ia8NQSEXKxv79VtbudxqZCo3KVhqJmZrmwrtGYGPJTWnnPwqcVBEOlIdsPo0B+jcym iJptkivzb1RqrlzORJnaj2D7r9Eny/N+ObMkEi5NDtqUyKsRDIOVyVZJPIEyodbr5L4z CZn11dfcSWQAhdUarS6qtiyZ1mkHtBToY0wTsMkJ00cYtyZ83tvnDkj+RrE0XCymTRY3 1cuwaYM8AoZMkfXyGvvYq8JU8PEb/FMubtIeZ+xXEbkFf/ykZ5hNDOro+Ogvdb/DyIfm XmfdoNPAsJ7/SDS4DsANLuw0HZGs40Fpi0dkvsHRXftC0FsLj7ChfnV+Lx1tZM8EPfj2 0Ibw== X-Gm-Message-State: AOJu0YxdV+lT3V4TWYeX4Kr0mi3v510Weq83tPrlQWQhE86PEsYObGmP 2OzYv1hrp/jiZ0dn7UaLxMttsKQSDIitCaXhWzqbSA== X-Received: by 2002:a62:b613:0:b0:6bc:67ca:671d with SMTP id j19-20020a62b613000000b006bc67ca671dmr1233298pff.1.1697700403743; Thu, 19 Oct 2023 00:26:43 -0700 (PDT) Received: from ?IPV6:2a01:e0a:999:a3a0:6933:1fe3:b858:3dde? ([2a01:e0a:999:a3a0:6933:1fe3:b858:3dde]) by smtp.gmail.com with ESMTPSA id g7-20020aa79f07000000b00693411c6c3csm4455829pfr.39.2023.10.19.00.26.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Oct 2023 00:26:43 -0700 (PDT) Message-ID: <844f6f35-3125-4014-852c-9ad7aee19ddc@rivosinc.com> Date: Thu, 19 Oct 2023 09:26:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 01/19] riscv: hwprobe: factorize hwprobe ISA extension reporting Content-Language: en-US To: Conor Dooley , Evan Green 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 , Samuel Ortiz References: <20231017131456.2053396-1-cleger@rivosinc.com> <20231017131456.2053396-2-cleger@rivosinc.com> <20231018-scrap-bankable-a0f321d97a46@spud> <20231018-flagpole-footpad-07a6228485f3@spud> From: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= In-Reply-To: <20231018-flagpole-footpad-07a6228485f3@spud> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 groat.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 (groat.vger.email [0.0.0.0]); Thu, 19 Oct 2023 00:26:58 -0700 (PDT) On 18/10/2023 19:36, Conor Dooley wrote: > 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 AM Clément Léger 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ément Léger >>>> --- >>>> 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 = &hart_isa[cpu]; >>>> >>>> - if (riscv_isa_extension_available(isainfo->isa, ZBA)) >>>> - pair->value |= RISCV_HWPROBE_EXT_ZBA; >>>> - else >>>> - missing |= RISCV_HWPROBE_EXT_ZBA; >>>> - >>>> - if (riscv_isa_extension_available(isainfo->isa, ZBB)) >>>> - pair->value |= RISCV_HWPROBE_EXT_ZBB; >>>> - else >>>> - missing |= RISCV_HWPROBE_EXT_ZBB; >>>> - >>>> - if (riscv_isa_extension_available(isainfo->isa, ZBS)) >>>> - pair->value |= RISCV_HWPROBE_EXT_ZBS; >>>> - else >>>> - missing |= RISCV_HWPROBE_EXT_ZBS; >>>> +#define CHECK_ISA_EXT(__ext) \ >>>> + do { \ >>>> + if (riscv_isa_extension_available(isainfo->isa, __ext)) \ >>>> + pair->value |= RISCV_HWPROBE_EXT_##__ext; \ >>>> + else \ >>>> + missing |= RISCV_HWPROBE_EXT_##__ext; \ >>>> + } while (false) >>>> + >>>> + /* >>>> + * Only use CHECK_ISA_EXT() for extensions which can be exposed >>>> + * 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. >> >> 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. Yes, the KConfig checks are already done by the headers, adding #ifdef would be redundant even if more coherent with the comment. BTW, wouldn't it make more sense to get rid out of the unsupported extensions directly at ISA string parsing ? ie, if kernel is compiled without V support, then do not set the bits corresponding to these in the riscv_isa_ext[] array ? But the initial intent was probably to be able to report the full string through cpuinfo. Clément > >> >>> Perhaps some rewording to more explicitly >>> state the danger would be appropriate. Other than that: >>> >>> Reviewed-by: Evan Green > >