Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp469739rdb; Thu, 19 Oct 2023 09:21:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELev25kP7ae1skIXG5llh/9W8iVQq8d1zcITNHYyIGKiQhDYz4SZ59BMvEvcnPdq54+1MA X-Received: by 2002:a17:90a:e38c:b0:27d:9b7:cc7 with SMTP id b12-20020a17090ae38c00b0027d09b70cc7mr2487067pjz.24.1697732474460; Thu, 19 Oct 2023 09:21:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697732474; cv=none; d=google.com; s=arc-20160816; b=Xe53ptrG/IokMXDNrO0gl8S/NEyk9vDPMz8Ugfl1aBmaJPHAb1KTh/VeMdKbsNZHxL HpiD8yirmQ8ZEVbJ+AJKvh+VZPFW/pXNumyni39OLEDa2cFE8m1CFDqAYkBkFxl8ZP26 /WjlTwAyWZig/9GpqzmNuq4b4zG39hAFw+qHQxA2SI3sf+/apO8TqUfQhap2gEk/OjV5 5kpIU9xWWEDzis8KuVZ+ard8uRqyrJDbPhFQATegm8+o3Bhw51EhCfMWpXaUBCxYb7Wz bRrq7OjBOKZDf3CLvUVzKIusGK4J2q8UOXQtxB1w+xa13f0Q3kh5PXcmX8gEW/SX9WSD ID7A== 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=Qrm2o2CouYl5YLE22rhN3Rv3HCs9/q81TyWZQXS7LNY=; fh=KI/wd0XKZyvDOnOU2vZjWuX41t6ynvaaExeNjmxLGgw=; b=vF83N55if5+nZQicKFGMoQUFoUlMLpcWtWu0cGyoXSoB+jsdOw0zqzA9NM7c/2l9ID IJ2xR81V9TKJWomzNGgNISW53kTffZWAOOWr3j6JsCeDYke6CssSvNiNhZUjm4neB+V3 jtsVAXd0juojH01Ywum9CH0R23JI6Gf5aWzB4fwK0kX+x9WmvXdLtipYi1HkudkLtGgZ SubOb+POwUr/NBzVFVVCBlj5eI6nwS6U2PScLZbPggvRW/uFwBCtlWzhh+gCwdlv/jd9 uN0EHQaSO+0Yv+rVtEHgSIg6KueqFhTteGamGnT7EGoBN/LfWedhya30hxlo1pB1JP8O Iahw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=rgIYVI0Y; 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 mp2-20020a17090b190200b002632a1243dbsi2460868pjb.104.2023.10.19.09.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 09:21:14 -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=rgIYVI0Y; 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 74E47825ED95; Thu, 19 Oct 2023 09:21:11 -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 S233119AbjJSQUe (ORCPT + 99 others); Thu, 19 Oct 2023 12:20:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232815AbjJSQUb (ORCPT ); Thu, 19 Oct 2023 12:20:31 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8185A126 for ; Thu, 19 Oct 2023 09:20:28 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2c515527310so77433921fa.2 for ; Thu, 19 Oct 2023 09:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1697732427; x=1698337227; 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=Qrm2o2CouYl5YLE22rhN3Rv3HCs9/q81TyWZQXS7LNY=; b=rgIYVI0YzUrZFRsTOXtETtc+0scSLXuX4kKixp9RQ5l3akUvciWnZWIVUOys3BcXWr NeY08K+o9LoRBt6DBrTZufhB6JmXa778VSqjMHHhDM7dwZOJTWeSwR585UhlM07wMvqn YFfcDj3Dt06Cgu191TI3GvRfOa+Rw2Wibdk6V6aNmM0J5sKq5tAGJI4uFXm2ixaCsQnh 3N7LDyykUGg2b+AP3ENezy4kwKZ9CBSZQxcEDEIZZYoz5ZHrRwg36sfqLzdL/Gea8dYD 0tEML5K6OykE9bp0TU+PoYiPfgWbJ0bC1BpU0vRHaSPOGStb8Nj/XQQYry9lC1icwvJa Sibg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697732427; x=1698337227; 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=Qrm2o2CouYl5YLE22rhN3Rv3HCs9/q81TyWZQXS7LNY=; b=TFSAL8yx9R+qlrH38lkCJ6SC+OOF6izmqiprMcCrHQ6mCSDkjDmNQOoS0RyyLaZ/v/ yMcjgbCnpsaYnspPE+50FfOV9EmRAOmIVzvvuF8xFEiVbgSfO4JI2S8p15BWxZS0Oiye HYDoy4r2PlzG7PC/FwRPdXEKrnHf0Gx03Ga+Zm+iFOMKV//pzstJAuJzBw2d+qKqNwVF AEO5aNmbEmYcVsTpb1tZCLipfjtB6hIUfYKWT0/5F9SolGdu6Ucc2dMb+8gkBQ47HyfA bE3DQET9QNH9WmY00eRYP+NqJ9vt+XyFWPpdO1GupLL7k5Q8IMN8RgtJFPW/vpQEDHyJ FLiQ== X-Gm-Message-State: AOJu0YyaW5WqBWW0HwHG8yv5mI07QbkE5DMivER7Ve/l/VIaxvW51t26 ec84AFLuCRfqYeqRQmTMQHPlvz3id3HaO9eLgwyz5g== X-Received: by 2002:a2e:9d0c:0:b0:2bc:b557:cee9 with SMTP id t12-20020a2e9d0c000000b002bcb557cee9mr1761152lji.43.1697732426653; Thu, 19 Oct 2023 09:20:26 -0700 (PDT) MIME-Version: 1.0 References: <20231017131456.2053396-1-cleger@rivosinc.com> <20231017131456.2053396-6-cleger@rivosinc.com> <7626f978-e9ea-4f8f-b814-aeac02bd3712@rivosinc.com> <20231019-nuclear-vista-ef3e0b9bef71@spud> In-Reply-To: <20231019-nuclear-vista-ef3e0b9bef71@spud> From: Evan Green Date: Thu, 19 Oct 2023 09:19:50 -0700 Message-ID: Subject: Re: [PATCH v2 05/19] riscv: add ISA extension parsing for vector crypto extensions To: Conor Dooley Cc: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= , Jerry Shih , 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 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 09:21:11 -0700 (PDT) On Thu, Oct 19, 2023 at 8:33=E2=80=AFAM Conor Dooley wro= te: > > On Thu, Oct 19, 2023 at 11:35:59AM +0200, Cl=C3=A9ment L=C3=A9ger wrote: > > > > > > On 18/10/2023 19:26, Evan Green wrote: > > > On Wed, Oct 18, 2023 at 5:53=E2=80=AFAM Cl=C3=A9ment L=C3=A9ger wrote: > > >> > > >> > > >> > > >> On 18/10/2023 03:45, Jerry Shih wrote: > > >>> On Oct 17, 2023, at 21:14, Cl=C3=A9ment L=C3=A9ger wrote: > > >>>> @@ -221,6 +261,22 @@ const struct riscv_isa_ext_data riscv_isa_ext= [] =3D { > > >>>> __RISCV_ISA_EXT_DATA(zkt, RISCV_ISA_EXT_ZKT), > > >>>> __RISCV_ISA_EXT_DATA(zksed, RISCV_ISA_EXT_ZKSED), > > >>>> __RISCV_ISA_EXT_DATA(zksh, RISCV_ISA_EXT_ZKSH), > > >>>> + __RISCV_ISA_EXT_DATA(zvbb, RISCV_ISA_EXT_ZVBB), > > >>>> + __RISCV_ISA_EXT_DATA(zvbc, RISCV_ISA_EXT_ZVBC), > > >>>> + __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB), > > >>> > > >>> The `Zvkb` is the subset of `Zvbb`[1]. So, the `Zvkb` should be bun= dled with `Zvbb`. > > >> > > >> Hi Jerry, > > >> > > >> Thanks for catching this, I think some other extensions will fall in > > >> this category as well then (Zvknha/Zvknhb). I will verify that. > > > > > > The bundling mechanism works well when an extension is a pure lasso > > > around other extensions. We'd have to tweak that code if we wanted to > > > support cases like this, where the extension is a superset of others, > > > but also contains loose change not present anywhere else (and > > > therefore also needs to stand as a separate bit). > > > > For Zvbb and Zvknhb, I used the following code: > > > > static const unsigned int riscv_zvbb_bundled_exts[] =3D { > > RISCV_ISA_EXT_ZVKB, > > RISCV_ISA_EXT_ZVBB > > }; > > > > static const unsigned int riscv_zvknhb_bundled_exts[] =3D { > > RISCV_ISA_EXT_ZVKNHA, > > RISCV_ISA_EXT_ZVKNHB > > }; > > > > Which correctly results in both extension (superset + base set) being > > enabled when only one is set. Is there something that I'm missing ? > > > > > > > > IMO, decomposing "pure" bundles makes sense since otherwise usermode > > > would have to query multiple distinct bitmaps that meant the same > > > thing (eg check the Zk bit, or maybe check the Zkn/Zkr/Zkt bits, or > > > maybe check the Zbkb/Zbkc... bits, and they're all equivalent). But > > > when an extension is a superset that also contains loose change, ther= e > > > really aren't two equivalent bitmasks, each bit adds something new. > > > > Agreed but if a system only report ZVBB for instance and the user wants > > ZVKB, then it is clear that ZVKB should be reported as well I guess. So > > in the end, it works much like "bundle" extension, just that the bundle > > is actually a "real" ISA extension by itself. > > > > Cl=C3=A9ment > > > > > > > > There's an argument to be made for still turning on the containing > > > extensions to cover for silly ISA strings (eg ISA strings that > > > advertise the superset but fail to advertise the containing > > > extensions). We can decide if we want to work that hard to cover > > > hypothetical broken ISA strings now, or wait until they show up. > > > Personally I would wait until something broken shows up. But others > > > may feel differently. > > I'm not really sure that those are "silly" ISA strings. People are going > to do it that way because it is much easier than spelling out 5 dozen > sub-components, and it is pretty inevitable that subsets will be > introduced in the future for extensions we currently have. > > IMO, it's perfectly valid to say you have the supersets and not spell > out all the subcomponents. Hm, ok. If ISA strings are likely to be written that way, then I agree having the kernel flip on all the contained extensions is a good idea. We can tweak patch 2 to support the parsing of struct riscv_isa_ext_data with both .id and .bundle_size set (instead of only one or the other as it is now). Looking back at that patch, it looks quite doable. Alright! -Evan