Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp188503lqp; Fri, 12 Apr 2024 14:43:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUbR1CW7N039uas2a3hTFGunGRfBOF+2d/4lWknj0mjpOmO1bdcMcTx7AG3JijCylooRrHy3en2fUMv5KEtlKeT/lOYUMaMR063CF4jzg== X-Google-Smtp-Source: AGHT+IEhYbawnSYkVbedena5b3JbViEHzRSZrUmb4U4YifAdB1uOOL42CgTGDx+nemHp9wO2rDh5 X-Received: by 2002:a17:906:c9c2:b0:a52:3874:6208 with SMTP id hk2-20020a170906c9c200b00a5238746208mr1543901ejb.61.1712958232079; Fri, 12 Apr 2024 14:43:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712958232; cv=pass; d=google.com; s=arc-20160816; b=c3p3RSNAkiz3N3EXBmv5yBNPtXIN87lE8tzxnD4b2JFvlKnxF0UtWU2rHkdquScOyo vUTn7l92OJGz12JexXOA1sHHx8Dq0fIHdqXMebXZMWtlZb1kICPGUrrQr8V/BYAqASvT Hb2GWbHhz4rJwZYEUh/NY0xUz2ELOWcOU3MQQYZSM0Qi72MTcvMfHRL9sgB6WTeZ+5tx etD24Jvy0iNNbO932g3cJIWZeSgkJ6Hcr6DnGX/tH0P3vciGh1MpC5q63gLXvfQX8Gbq B75GE/P9z1xL4QSuDXFFgT6Z5YHfFW4rwTI5JGyVDBrN47Ji2UHCxOZ6R5btk8TAprBL 1AIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=BZqnpoJrYnyKUwwBneXw4v4bZBhm4v+etrm4n/HZz3w=; fh=RbFqHZFpEwlANgiNPwEMU76EjO6jIn+qgBOQXbjBSpk=; b=z07ZcytrWITqeqTffFZzHpymqplrHKw96cvTdQM0wYBLiO95k88mJ9t2im9KEVT2bP NjW6SO6T/I5itzSHIi8synXdVe79kh3Hc56+qGIgA3tUGXE6coJvCpxkMOqZEwswXBNh +ZStceJfcYWBFC5CtNkZOSXiZ6rA4HecC6R0MKMaVWyxH3Xj8aCLxFhSH/+d9OBXkBV9 mgrhhhJju+QO8NZMLVdiklE6ZP1biXe6zjgI+qqfj0f48/NTq/3arJ6MRR94l0n8qjkW eyhkHwmwtmEU0wZKkcqdGogs/ZKhxz7SWL7Rz8++oKq0pSNvP+wF7rcUNdinM6icSUJr yBJw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=wo7hYiVs; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-143393-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143393-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id jt1-20020a170906dfc100b00a52358372f8si1061505ejc.876.2024.04.12.14.43.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 14:43:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143393-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=wo7hYiVs; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-143393-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143393-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A37B91F23BB3 for ; Fri, 12 Apr 2024 21:43:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB3F915217E; Fri, 12 Apr 2024 21:43:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="wo7hYiVs" Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 26DEE15217D for ; Fri, 12 Apr 2024 21:43:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712958221; cv=none; b=ZOZiGej3HGEDd3vetSJ7vJH+ivOQpuGEkxhPfG5K4Zdp+b7zvH3pXQvSzK+xz3J5UbwJUh8z+9VCUUnS8GspcVGuuINjOTMeR3ZtL0dXMJGr2Tb68zYKrTqDqSjdwNnAci3wpqFVzvSCbZrdoFnZyXPj0jHe33I04Gp8OMzO4Cc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712958221; c=relaxed/simple; bh=W5flOzUs9hCgNtSsncoT/3wpdKFgVE5/nt0SDyojtsE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=XLlnFaV+JyQqfmX8Qskbgf8yq/P9ATVNBxDUUXh6OlkHDbIpGegDY1hmVfZwnaW6+OWvDC+TVOEAX4UidYFLZgsV7esCmVbM5wlhPkwYEQ+ELGjo+lD7eOcxQDguIsBjVBkUaEn7fFG263utGpldd+SJx2xz8mayavvCKeKmv8g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=wo7hYiVs; arc=none smtp.client-ip=209.85.208.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2d6ff0422a2so15889781fa.2 for ; Fri, 12 Apr 2024 14:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712958217; x=1713563017; 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=BZqnpoJrYnyKUwwBneXw4v4bZBhm4v+etrm4n/HZz3w=; b=wo7hYiVsCfmLKSjGzY0aoJ8kpfZwg2CnMHwKBzVcXdWe66+Z2nh4p+5A38If74Tpy1 ckAVp5wamnpUUD5zHZio1Vvd2Xu3mXArBZgsA0xHX3s70T8FpmjbNBW/KGkQnqfKxBhP gy6J+FjvFyJCfuC0yROpV274CR93StzN8tfp3YLX1PzpjDD46zPlvVvoVL71yFd25icP WuzORvFzyB4sWHPgQmBW5eVZ3p/HjmZ67T1335VheMzwLdaim6MJASSZfO/ovA+RnR0o uk2/b/stJ/X3HM1Ncd5sugC6F1DYqb28AHVQ0tEkaF8AGu9N7lvEgqgeYmVlYwjbIIcT z3vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712958217; x=1713563017; 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=BZqnpoJrYnyKUwwBneXw4v4bZBhm4v+etrm4n/HZz3w=; b=WI1DIsqgiiNUwOlMdL3CDSw0g32SMB9WXZACA6BqqnZLSQ4byRpXACKyHqBTD9uK9O ntXTC+IZYf+hJaqG4dnaCl3hg7b4xuogvHih5gdsI94sfDydkJuEdEoPDq9SNKTkfJ9E d0QgTI7GJfOHBj/j2Cg/36ByIVBxEtrcCQ3sMCsNhjl2s3Rtig1Aa7J3jHjUimj31WDQ fMLO1uyMAHiJSUi0YsTkF3dzKifavmhkms1XOn/Id0ukx7+ROQ8D3uahyLZYO4vDSuIh gfF6gQmZqlwQDre8wV61h318F9b8H7vRuwOP7h/4JqrbQMtoCiL1geri3VXNUbg59TcF oHoQ== X-Forwarded-Encrypted: i=1; AJvYcCWhhRMAHmbRWKnePCVSFc1Y6vOV8HYGa6KAFcbp7ZemAGf9cRCMfoxzMx8gT5qDPCk0CphhzUxA0eQWwolOrtJlombCxc1pq3Zenr/u X-Gm-Message-State: AOJu0Yy1sDepI0T29D5w1jGTZkYUNGegoqIteJHOnXK5UTwkR8upnkJS 49ejRHCGZbzJF5L6B+tbCRzViXKBvwaWBDak9NRQKdI0h9sQd1k66lNjA2tcTkkeREuEM3XG9UH gLShCnG1rys90Hemzjf6gumzjkhN9/F9vBB9+mQ== X-Received: by 2002:a2e:a696:0:b0:2d8:c151:80ec with SMTP id q22-20020a2ea696000000b002d8c15180ecmr1868287lje.52.1712958217206; Fri, 12 Apr 2024 14:43:37 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240411-dev-charlie-support_thead_vector_6_9-v1-0-4af9815ec746@rivosinc.com> <20240411-dev-charlie-support_thead_vector_6_9-v1-16-4af9815ec746@rivosinc.com> In-Reply-To: From: Evan Green Date: Fri, 12 Apr 2024 14:43:01 -0700 Message-ID: Subject: Re: [PATCH 16/19] riscv: hwprobe: Add vendor extension probing To: Charlie Jenkins Cc: Conor Dooley , Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Palmer Dabbelt , Albert Ou , Guo Ren , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Conor Dooley , =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= , Jonathan Corbet , Shuah Khan , linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Apr 12, 2024 at 1:20=E2=80=AFPM Charlie Jenkins wrote: > > On Fri, Apr 12, 2024 at 12:07:46PM -0700, Evan Green wrote: > > On Fri, Apr 12, 2024 at 11:17=E2=80=AFAM Charlie Jenkins wrote: > > > > > > On Fri, Apr 12, 2024 at 10:05:21AM -0700, Evan Green wrote: > > > > On Thu, Apr 11, 2024 at 9:12=E2=80=AFPM Charlie Jenkins wrote: > > > > > > > > > > Add a new hwprobe key "RISCV_HWPROBE_KEY_VENDOR_EXT_0" which allo= ws > > > > > userspace to probe for the new RISCV_ISA_VENDOR_EXT_XTHEADVECTOR = vendor > > > > > extension. > > > > > > > > > > Signed-off-by: Charlie Jenkins > > > > > --- > > > > > arch/riscv/include/asm/hwprobe.h | 4 +-- > > > > > arch/riscv/include/uapi/asm/hwprobe.h | 10 +++++- > > > > > arch/riscv/kernel/sys_hwprobe.c | 59 +++++++++++++++++++++= ++++++++++++-- > > > > > 3 files changed, 68 insertions(+), 5 deletions(-) > > > > > > > > > > diff --git a/arch/riscv/include/asm/hwprobe.h b/arch/riscv/includ= e/asm/hwprobe.h > > > > > index 630507dff5ea..e68496b4f8de 100644 > > > > > --- a/arch/riscv/include/asm/hwprobe.h > > > > > +++ b/arch/riscv/include/asm/hwprobe.h > > > > > @@ -1,6 +1,6 @@ > > > > > /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ > > > > > /* > > > > > - * Copyright 2023 Rivos, Inc > > > > > + * Copyright 2023-2024 Rivos, Inc > > > > > */ > > > > > > > > > > #ifndef _ASM_HWPROBE_H > > > > > @@ -8,7 +8,7 @@ > > > > > > > > > > #include > > > > > > > > > > -#define RISCV_HWPROBE_MAX_KEY 6 > > > > > +#define RISCV_HWPROBE_MAX_KEY 7 > > > > > > > > > > static inline bool riscv_hwprobe_key_is_valid(__s64 key) > > > > > { > > > > > diff --git a/arch/riscv/include/uapi/asm/hwprobe.h b/arch/riscv/i= nclude/uapi/asm/hwprobe.h > > > > > index 9f2a8e3ff204..6614d3adfc75 100644 > > > > > --- a/arch/riscv/include/uapi/asm/hwprobe.h > > > > > +++ b/arch/riscv/include/uapi/asm/hwprobe.h > > > > > @@ -1,6 +1,6 @@ > > > > > /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ > > > > > /* > > > > > - * Copyright 2023 Rivos, Inc > > > > > + * Copyright 2023-2024 Rivos, Inc > > > > > */ > > > > > > > > > > #ifndef _UAPI_ASM_HWPROBE_H > > > > > @@ -67,6 +67,14 @@ struct riscv_hwprobe { > > > > > #define RISCV_HWPROBE_MISALIGNED_UNSUPPORTED (= 4 << 0) > > > > > #define RISCV_HWPROBE_MISALIGNED_MASK (= 7 << 0) > > > > > #define RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE 6 > > > > > +/* > > > > > + * It is not possible for one CPU to have multiple vendor ids, s= o each vendor > > > > > + * has its own vendor extension "namespace". The keys for each v= endor starts > > > > > + * at zero. > > > > > + */ > > > > > +#define RISCV_HWPROBE_KEY_VENDOR_EXT_0 7 > > > > > + /* T-Head */ > > > > > +#define RISCV_HWPROBE_VENDOR_EXT_XTHEADVECTOR (= 1 << 0) > > > > > /* Increase RISCV_HWPROBE_MAX_KEY when adding items. */ > > > > > > > > > > /* Flags */ > > > > > diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/= sys_hwprobe.c > > > > > index e0a42c851511..365ce7380443 100644 > > > > > --- a/arch/riscv/kernel/sys_hwprobe.c > > > > > +++ b/arch/riscv/kernel/sys_hwprobe.c > > > > > @@ -69,7 +69,8 @@ static void hwprobe_isa_ext0(struct riscv_hwpro= be *pair, > > > > > if (riscv_isa_extension_available(NULL, c)) > > > > > pair->value |=3D RISCV_HWPROBE_IMA_C; > > > > > > > > > > - if (has_vector() && !riscv_has_vendor_extension_unlikely(= RISCV_ISA_VENDOR_EXT_XTHEADVECTOR)) > > > > > + if (has_vector() && > > > > > + !__riscv_isa_vendor_extension_available(NULL, RISCV_I= SA_VENDOR_EXT_XTHEADVECTOR)) > > > > > pair->value |=3D RISCV_HWPROBE_IMA_V; > > > > > > > > > > /* > > > > > @@ -112,7 +113,8 @@ static void hwprobe_isa_ext0(struct riscv_hwp= robe *pair, > > > > > EXT_KEY(ZACAS); > > > > > EXT_KEY(ZICOND); > > > > > > > > > > - if (has_vector() && !riscv_has_vendor_extension_u= nlikely(RISCV_ISA_VENDOR_EXT_XTHEADVECTOR)) { > > > > > + if (has_vector() && > > > > > + !riscv_has_vendor_extension_unlikely(RISCV_IS= A_VENDOR_EXT_XTHEADVECTOR)) { > > > > > EXT_KEY(ZVBB); > > > > > EXT_KEY(ZVBC); > > > > > EXT_KEY(ZVKB); > > > > > @@ -139,6 +141,55 @@ static void hwprobe_isa_ext0(struct riscv_hw= probe *pair, > > > > > pair->value &=3D ~missing; > > > > > } > > > > > > > > > > +static void hwprobe_isa_vendor_ext0(struct riscv_hwprobe *pair, > > > > > + const struct cpumask *cpus) > > > > > +{ > > > > > + int cpu; > > > > > + u64 missing =3D 0; > > > > > + > > > > > + pair->value =3D 0; > > > > > + > > > > > + struct riscv_hwprobe mvendorid =3D { > > > > > + .key =3D RISCV_HWPROBE_KEY_MVENDORID, > > > > > + .value =3D 0 > > > > > + }; > > > > > + > > > > > + hwprobe_arch_id(&mvendorid, cpus); > > > > > + > > > > > + /* Set value to zero if CPUs in the set do not have the s= ame vendor. */ > > > > > + if (mvendorid.value =3D=3D -1ULL) > > > > > + return; > > > > > + > > > > > + /* > > > > > + * Loop through and record vendor extensions that 1) anyo= ne has, and > > > > > + * 2) anyone doesn't have. > > > > > + */ > > > > > + for_each_cpu(cpu, cpus) { > > > > > + struct riscv_isainfo *isavendorinfo =3D &hart_isa= _vendor[cpu]; > > > > > + > > > > > +#define VENDOR_EXT_KEY(ext) = \ > > > > > + do { = \ > > > > > + if (__riscv_isa_vendor_extension_available(isaven= dorinfo->isa, \ > > > > > + RISCV_IS= A_VENDOR_EXT_##ext)) \ > > > > > + pair->value |=3D RISCV_HWPROBE_VENDOR_EXT= _##ext; \ > > > > > + else = \ > > > > > + missing |=3D RISCV_HWPROBE_VENDOR_EXT_##e= xt; \ > > > > > + } while (false) > > > > > + > > > > > + /* > > > > > + * Only use VENDOR_EXT_KEY() for extensions which can be = exposed to userspace, > > > > > + * regardless of the kernel's configuration, as no other = checks, besides > > > > > + * presence in the hart_vendor_isa bitmap, are made. > > > > > + */ > > > > > + VENDOR_EXT_KEY(XTHEADVECTOR); > > > > > + > > > > > +#undef VENDOR_EXT_KEY > > > > > > > > Hey Charlie, > > > > Thanks for writing this up! At the very least I think the > > > > THEAD-specific stuff should probably end up in its own file, otherw= ise > > > > it'll get chaotic with vendors clamoring to add stuff right here. > > > > > > Great idea! > > > > > > > What do you think about this approach: > > > > * We leave RISCV_HWPROBE_MAX_KEY as the max key for the "generic > > > > world", eg 6-ish > > > > * We define that any key above 0x8000000000000000 is in the vendor > > > > space, so the meaning of the keys depends first on the mvendorid > > > > value. > > > > * In the kernel code, each new vendor adds on to a global struct, > > > > which might look something like: > > > > struct hwprobe_vendor_space vendor_space[] =3D { > > > > { > > > > .mvendorid =3D VENDOR_THEAD, > > > > .max_hwprobe_key =3D THEAD_MAX_HWPROBE_KEY, // curr= ently > > > > 1 or 0x8000000000000001 with what you've got. > > > > .hwprobe_fn =3D thead_hwprobe > > > > }, > > > > ... > > > > }; > > > > > > > > * A hwprobe_thead.c implements thead_hwprobe(), and is called > > > > whenever the generic hwprobe encounters a key >=3D0x800000000000000= 0. > > > > * Generic code for setting up the VDSO can then still call the > > > > vendor-specific hwprobe_fn() repeatedly with an "all CPUs" mask fro= m > > > > the base to max_hwprobe_key and set up the cached tables in userspa= ce. > > > > * Since the VDSO data has limited space we may have to cap the num= ber > > > > of vendor keys we cache to be lower than max_hwprobe_key. Since the > > > > data itself is not exposed to usermode we can raise this cap later = if > > > > needed. > > > > > > I know vendor extensions are kind of the "wild west" of riscv, but in > > > spite of that I want to design a consistent API. The issue I had with > > > having this "vendor space" for exposing vendor extensions was that th= is > > > is something that is inherently the same for all vendors. I see a ven= dor > > > space like this more applicable for something like > > > "RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE" where a vendor has a specific > > > value they would like to expose. I do agree that having a vendor spac= e > > > is a good design choice, but I am not convinced that vendor extension= s > > > are the proper use-case. > > > > > > By having RISCV_HWPROBE_KEY_VENDOR_EXT_0 we can expose the vendor > > > extensions in the same way that standard extensions are exposed, with= a > > > bitmask representing each extension. If these are instead in the vend= or > > > space, each vendor would probably be inclined to introduce a key like > > > RISCV_HWPROBE_KEY_THEAD_EXT_0 that returns a bitmask of all of the th= ead > > > vendor extensions. This duplicated effort is what I am trying to avoi= d. > > > The alternative would be that vendors have a separate key for each > > > vendor extension they would like to expose, but that is strictly less > > > efficient than the existing bitmask probing. > > > > > > Do you think that having the vendor space is appropriate for vendor > > > extensions given my concerns? > > > > I do see what you're going for. It's tidy for a bitmask to just let > > anyone allocate the next bit, but leaves you with the same problem > > when a vendor decides they want to expose an enum, or decides they > > want to expose a bazillion things. I think a generalized version of > > This patch is strictly to expose if a vendor extension is supported, > how does exposing enums factor in here? > > > the approach you've written would be: simply let vendors allocate keys > > from the same global space we're already using. My worry was that it > > I am missing how my proposal suggests allowing vendors to allocate keys > in a global space. > > > would turn into an expansive suburban sprawl of mostly dead bits, or > > in the case of vendor-specific keys, full of "if (mvendor_id() !=3D > > MINE) return 0;". My hope with the vendored keyspace is it would keep > > An application will always need to check vendorid before calling hwprobe > with a vendor-specific feature? If that hwprobe support is a key above > 1<<63, then the application will need to pass that vendor-specific key > and interpret the vendor-specific value. If that hwprobe support is what > I have proposed here, then the user calls the standardized vendor > extension hwprobe endpoint and then needs to interpret the result based > on the vendor of the cpumask. In both cases they need to check the > vendorid of the cpumask. In the test case I added I failed to check the > vendorid but I should have had that. > > > the sprawl from polluting the general array of (hopefully valuable) > > info with stuff that's likely to become less relevant as time passes. > > It also lowers the bar a bit to make it easier for vendors to expose > > bits, as they don't consume global space for everyone for all of time, > > just themselves. > > The vendor keys are tied directly to the vendor. So as it grows we would > have something like: > > #define RISCV_HWPROBE_KEY_VENDOR_EXT_0 7 > /* T-Head */ > #define RISCV_HWPROBE_VENDOR_EXT_XTHEADVECTOR (1 << 0) > #define RISCV_HWPROBE_VENDOR_EXT_XTHEAD2 (2 << 0) > #define RISCV_HWPROBE_VENDOR_EXT_XTHEAD3 (3 << 0) > /* Vendor 2 */ > #define RISCV_HWPROBE_VENDOR_EXT_XVENDOR1 (1 << 0) > #define RISCV_HWPROBE_VENDOR_EXT_XVENDOR2 (2 << 0) > /* Vendor 3 */ > ... > > The keys overlap between vendors. To determine which extension a vendor > supports, hwprobe gets data from hart_isa_vendor[cpu]. If the vendor is > vendor 2, it is not possible for a vendor extension from vendor 3 to end > up in there. Only the extensions from that vendor can be supported by > that vendor's hardware. Gotcha. You're right I had misinterpreted this, thinking XTHEADVECTOR was a valid bit regardless of mvendorid, and that other vendors would have to choose new bits for their features and always return 0 for XTHEADVECTOR. With your explanation, it seems like you're allocating keys (in no particular order) whose meaning will change based on mvendorid. I guess I'm still not convinced that saving each vendor from having to add a VENDOR_EXT key in their keyspace is worth the sacrifice of spraying the vendor-specific keys across the generic keyspace. Are there advantages to having a single key whose category is similar but whose bits are entirely vendor-defined? Maybe if I were userspace and my feature could be satisfied equivalently by XTHEADVECTOR or XRIVOSOTHERTHING, then I could do one hwprobe call instead of two? But I don't think the vendors are going to be consistent enough for that equivalency to ever prove useful. The advantages in my head of the separate vendor keyspace are: * Keeps the kernel code simple: if key >=3D (1 >> 63) vendor_config->do_hwprobe(), rather than having all these little calls in each specific switch case for vendor_config->do_vendor_ext0(), vendor_config->do_vendor_ext1(), etc. * It extends easily into passing other forms of vendor hwprobe info later, rather than solving only the case of risc-v extensions now, and then having to do this all again for each additional category of vendor data. * Similarly, it discourages future vendors from trying to squint and find a way to make a vaguely generic sounding category for their own hwprobe key which will ultimately only ever be filled in by them anyway. -Evan