From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f43.google.com (mail-dl1-f43.google.com [74.125.82.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 207B732B9A9 for ; Tue, 30 Jun 2026 06:07:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782799666; cv=none; b=eMC23Waej2qG8HrDkRg+LCJIwhHndPCEu2OwGCEIxfMPQb7OFABa7/vL5oyFq81J0uxj9+9ncqUVzdChDhv07P9aGOxlnDXPBrQK946akm8fbUEhwCP6oXVht4byfPMdltKLIUD3VsOgh4LciV9H7fpWEZkdPPy96cbUJIZttP4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782799666; c=relaxed/simple; bh=AYGGcUatHZzBC9blnkpGO8g4uJIlf8hMCuS/60qaIRI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Gi+Q1bTb6/pdFooGSQeX5P/Dxw/EtBlOlUOpmPDZjbG86AqDoTtouVwRkU0SJgg0UAQUesL8oSPtNtGQIzLjLr6uT2/EjRPiaZ2q0mvvQTWgrQDBPsGWZoKy/nH4OBloXIx27u077HQ9Ay16v0ypGHdZI8HWNpVont8RQYTDiAA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FgIIcYhZ; arc=none smtp.client-ip=74.125.82.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FgIIcYhZ" Received: by mail-dl1-f43.google.com with SMTP id a92af1059eb24-139aff562e1so6018907c88.1 for ; Mon, 29 Jun 2026 23:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782799663; x=1783404463; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=tuwqmf7tbULdN/WriFM1zqIzaDGWLfMn0r/anrEXbCI=; b=FgIIcYhZhIGKBsyykkt5DieuW4QxDPaAX+g05R6eQSnAvQsptlQiHZCVOBStUU2+DF lr48OaE/gKCpkSTcI7z7DfbOsbUIH8DdFeq4iZo9RPvD1t3ZMthDP6dKQCS9tWUIkeQh jG2rU3TvjPEH/1hcDbsTSlgYP41oBQNf0iSe0bTFyBUv2kwAF/f137xfXhQQeaB2BABS 2crgmHr3/JCeAsooVxPBZYIiRwsjgieBEjnrzJps/RYzUrQBraWwO6qOSvDtTtWkFHAH HUO4Jccs1MPiEqSdr8dmoQet9og3yqN3T+QaIcJw/83FZi1V/ljE4Nn2/OFTSrs/UqKm DjbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782799663; x=1783404463; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tuwqmf7tbULdN/WriFM1zqIzaDGWLfMn0r/anrEXbCI=; b=jeyXHBrshzpl40HcxX3swTtrlKpa/vEMwo3tDk5d6RnM0PJfsIEC0oId2WALhcTHkl k8Yj05//2T9cHvLsD4wN7hvOYpO3yJfF02F+KHyI300jh/iibI80JtpPzxqx9jmWewQ9 4E1sc3tGRmqoehuTh8M7KRyWzcZAfuMp0eZnMq9zL9ksGPoZKM0RcOgsM4xFB6bYvZR2 kVj155PldYb0Z1kw2JRIX3VM/y8UvuZHd0iKL5SKcZ38Uv7a02zf0WsgFYMovljoFfCQ bcrOxc5s17ZRb2itTCExzLIleXYaV/tkOCqDEoz5cA/34YpLSFUAwPNvIM4dz/+4q8bO 8OJQ== X-Forwarded-Encrypted: i=1; AFNElJ/RHIRPsMQ4vhmXZwsufbwm4na+Qb6vjhUQ/MMquSPgc/0C4nefbHoVVcftHgggDC9ECFX7+ImMfBHirqQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yw7HD/OIjfwIKMS4xHBmnE9sUw8ZuwadlSInik/Im2aydRxIdMf uxTNYBf46trGqaZATCoTBXIimrul7W54Ti5YkgBX1uHulexCBEdWfJ0/ X-Gm-Gg: AfdE7clgGiFeKhhRK+0awYdP/kHxlwumPhnovgDdxsiwibU9LXy/UYmIC658ID6q3+g bZ9cDKK/NEY1cmOhzJM9knxSegjEh8siurBYcN8oB6ultzrrsFLAkJkErnkqoUmTaNpat1MS+J3 lMdjGjDw1SVL5FKkywg91Bb6lusWut1vpsuy58Q/Wqo93eXTpDQ++y+aV2u+lxsaLWC1KsKk1J/ E+qX+dN7hN9dxg4m1YGrm//6EmcAkvmknDB7Jr1PG84im6eZKg2HfRTaTEbZ83Ng6dpuu8+Wz5j P6PJHUZkDmMIPr8YqyY4e/FimUOIoPWv3EzrZkYiAiNd0ME0k+gjWJuxyja7cWkHh1N2v0fFKeY 6GiDeWfIWmnxC7SX1JYvM6HHZIIPbXBObJYnzXkveGv7NDmFbaLsio0Y2rPSqRPWlSbnNrF4JCZ UVweIqg3AUdqaAMyWX3GOQXb+1lco9NmKW X-Received: by 2002:a05:7022:fe01:b0:139:ed5c:7699 with SMTP id a92af1059eb24-13b2a1d2518mr1236392c88.50.1782799662878; Mon, 29 Jun 2026 23:07:42 -0700 (PDT) Received: from blinky ([2601:647:6700:64d0::94ac]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13b2aba794csm3691329c88.10.2026.06.29.23.07.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2026 23:07:42 -0700 (PDT) Date: Mon, 29 Jun 2026 23:07:40 -0700 From: Charlie Jenkins To: Conor Dooley Cc: Paul Walmsley , Palmer Dabbelt , Alexandre Ghiti , Conor Dooley , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] riscv: Add "g" as an instruction alias Message-ID: References: <20260626-g_ext-v1-1-a9aa7ab9d109@gmail.com> <20260627-spud-qualifier-9a0041fb655e@spud> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260627-spud-qualifier-9a0041fb655e@spud> On Sat, Jun 27, 2026 at 02:58:14PM +0100, Conor Dooley wrote: > On Fri, Jun 26, 2026 at 11:24:46PM -0700, Charlie Jenkins wrote: > > "G" is an official alias for "IMAFDZicsr_Zifencei" [1]. Many common > > What does [1] reference? > > > tools like LLVM, GCC, OpenSBI, QEMU support this alias so make Linux > > follow the status quo and allow users to pass it in the isa string. In > > the ISA string, "G" is expected to written lowercase as "g" like the > > other extensions. Since "g" is a simple alias, follow what OpenSBI does > > and expose "imafd_zicsr_zifencei" instead of "g". > > What does OpenSBI do? Does it covert "g" in Kconfig etc into imafd... in > a devicetree? Actually, I didn't test properly. OpenSBI doesn't crash and it does parse "g" from the devicetree but it pulls from misa to print what extensions are supported in the boot log. > Do you mean that your intention is for a dts with "g" in it to only show > the constituent parts in /proc/cpuinfo etc? Yeah that's what I meant, I'll remove the opensbi wording. > > > > > Signed-off-by: Charlie Jenkins > > --- > > This can be tested with a device tree that passes in "g" to the isa > > string like: > > > > riscv,isa-extensions = "gc"; > > Are you sure this is what you tried? It should not work. > The code dealing with this works on exact matches, so it should end up > comparing "gc" with "g" and "c", detecting neither. > Needs to be ... = "g", "c"; Yeah... I did test "g", "c"; > > Also, you need to document this in the dt binding, along with the exact > meaning. Probably do what b has done and mandate filling in the > constituent parts, retrofitting something that permits the removal of > other extensions will create devicetrees that do not play nicely with > other OSes. Okay sounds good. > > > or > > > > riscv,isa = "rv64gc"; > > And I think this definitely does not work properly, cos you only > modified the riscv,isa-extensions part of > riscv_early_of_processor_hartid(). I'm not convinced that this is worth > permitting at all though, riscv,isa should probably not get any > behavioural changes at this point. It's deprecated after all. > Sure ACPI uses the same format and parser etc, but that's obviously not > affected by what we do in riscv_early_of_processor_hartid()! I should have done a better job reviewing myself. Yes you are right. Since ACPI still uses "riscv,isa" I'm hesitant to say that we shouldn't support it. This has always been a pain that we don't have a good extension story for acpi. My preference would be to support it in riscv,isa at least for ACPI. Maybe it's fine to not allow it for non-ACPI by rejecting it in riscv_early_of_processor_hartid(). - Charlie > > > > > Example test case using qemu: > > 1. Run QEMU with the additional arg "-machine dumpdtb=qemu.dtb" > > 2. Decompile the dts "dtc -O dts -I dtb qemu.dtb -o qemu.dts" > > 3. Set riscv,isa-extensions to "gc" > > 4. Compile the dtb "dtc -O dtb -I dts qemu.dts -o qemu.dtb" > > 5. Boot qemu with "-dtc qemu.dtb" > > 6. Look at /proc/cpuinfo > > --- > > arch/riscv/kernel/cpu.c | 7 ++++--- > > arch/riscv/kernel/cpufeature.c | 11 +++++++++++ > > 2 files changed, 15 insertions(+), 3 deletions(-) > > > > diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c > > index 3dbc8cc557dd..0a2df97a1fd6 100644 > > --- a/arch/riscv/kernel/cpu.c > > +++ b/arch/riscv/kernel/cpu.c > > @@ -81,9 +81,10 @@ int __init riscv_early_of_processor_hartid(struct device_node *node, unsigned lo > > if (!of_property_present(node, "riscv,isa-extensions")) > > return -ENODEV; > > > > - if (of_property_match_string(node, "riscv,isa-extensions", "i") < 0 || > > - of_property_match_string(node, "riscv,isa-extensions", "m") < 0 || > > - of_property_match_string(node, "riscv,isa-extensions", "a") < 0) { > > + if (of_property_match_string(node, "riscv,isa-extensions", "g") < 0 && > > + (of_property_match_string(node, "riscv,isa-extensions", "i") < 0 || > > + of_property_match_string(node, "riscv,isa-extensions", "m") < 0 || > > + of_property_match_string(node, "riscv,isa-extensions", "a") < 0)) { > > pr_warn("CPU with hartid=%lu does not support ima", *hart); > > return -ENODEV; > > } > > diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c > > index f46aa5602d74..f78cbf5ade1e 100644 > > --- a/arch/riscv/kernel/cpufeature.c > > +++ b/arch/riscv/kernel/cpufeature.c > > @@ -322,6 +322,16 @@ static const unsigned int riscv_a_exts[] = { > > RISCV_ISA_EXT_ZALRSC, > > }; > > > > +static const unsigned int riscv_g_bundled_exts[] = { > > + RISCV_ISA_EXT_i, > > + RISCV_ISA_EXT_m, > > + RISCV_ISA_EXT_a, > > + RISCV_ISA_EXT_f, > > + RISCV_ISA_EXT_d, > > + RISCV_ISA_EXT_ZICSR, > > + RISCV_ISA_EXT_ZIFENCEI > > +}; > > + > > #define RISCV_ISA_EXT_ZKN \ > > RISCV_ISA_EXT_ZBKB, \ > > RISCV_ISA_EXT_ZBKC, \ > > @@ -495,6 +505,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { > > __RISCV_ISA_EXT_SUPERSET(a, RISCV_ISA_EXT_a, riscv_a_exts), > > __RISCV_ISA_EXT_DATA_VALIDATE(f, RISCV_ISA_EXT_f, riscv_ext_f_validate), > > __RISCV_ISA_EXT_DATA_VALIDATE(d, RISCV_ISA_EXT_d, riscv_ext_d_validate), > > + __RISCV_ISA_EXT_BUNDLE(g, riscv_g_bundled_exts), > > __RISCV_ISA_EXT_DATA(q, RISCV_ISA_EXT_q), > > __RISCV_ISA_EXT_SUPERSET(c, RISCV_ISA_EXT_c, riscv_c_exts), > > __RISCV_ISA_EXT_SUPERSET_VALIDATE(v, RISCV_ISA_EXT_v, riscv_v_exts, riscv_ext_vector_float_validate), > > > > --- > > base-commit: 5a66900afbd6b2a063eebad35294038a654de2b0 > > change-id: 20260626-g_ext-0ca7d6223ff8 > > > > Best regards, > > -- > > - Charlie > >