Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1925725lqm; Fri, 3 May 2024 10:08:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWNq1nd+vZMeH5tzUcmEtnnhZgd8E/nZH4ETWlSPr7nQGoMNmSu5fiPbUmVFSeXWIJ6Es5APchYI5c6yBPoxzQ8WxnIW3QogUROPg9gYQ== X-Google-Smtp-Source: AGHT+IHX2MoRCqdIOltUPUTBNYxJYWhr42myxg6or0czqFq0ttmdqSnH2OaYMPKKIFq+Un0XdKVg X-Received: by 2002:a17:906:2b41:b0:a55:b67c:bd04 with SMTP id b1-20020a1709062b4100b00a55b67cbd04mr4798666ejg.4.1714756138894; Fri, 03 May 2024 10:08:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714756138; cv=pass; d=google.com; s=arc-20160816; b=EJq1WSXymyOu3HBfa/o64m5cPelNM3giFWSNC6p0t1b2I4WtlHcnoGUxeY8G0Izxzt yytBb9PrVC9afIEdQnDItGK+gHxatWPYnMww2hsRRRUZiAbPt2JB/Hv9wisqpbXJn8Dt XtnnlU1SPsgiRPSgXxR0DPPtkweihkGUDbI5c/GyhWe95S9lYDLwXjEZ70d75WHt+vdZ nMKEYqL1g9Kx8mpuimpjJteCrtc2IvnhLmQubPT6c1JZxOssqIo8F+PG14CeqY6ZItU5 8840/TDPzBtAeCp4rCNj/g5AlxHkhmEIBqn7+QmoFI86Hcuc7wExXE1TFmZUL+6rn/es xFtQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gt87Sr6itbk+KMDGSG8ct9g9uJtFf//vhHjuaZsqwkI=; fh=nJEJ0jfBvrghX8iuyfjppxbUIYlDN6HD1paA72qk22o=; b=OVYUnThx9YlfjVFtncvgV240jCo9j+JJ0E15Apc2C3w9ZIXchpjJkV54X18IYKr4Ua HVr+25oMfELvIaDOFwbQfBM4dIYNoxtDExiEMNvqC/pPaHJjpHToTs8qIGtCaDY5hKls Kz38sRJOCKyKgXp/dFTRtOfRdI5go9QXb3rljDfF+9uBcQkJqxUZOBCTZ1715HfGDkbI A8xNlYSNNKno83tN2e0/qo6UJ63pgKx9WoYG9YPG0e0jm09qh6QzfB6kxemd2KntZwUM EuGasHZHrNvJrYNrA4KFR6xafkaFVaPoG1bFLB3dlXvMmaFOGphkwz1CEakxLt0mmUYK cUeg==; 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=BCEkRgcW; 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-167946-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167946-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id k14-20020a1709063e0e00b00a599fc6e3d8si171778eji.659.2024.05.03.10.08.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 10:08:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167946-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=BCEkRgcW; 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-167946-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167946-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 766E61F23850 for ; Fri, 3 May 2024 17:08:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1455157E69; Fri, 3 May 2024 17:08:49 +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="BCEkRgcW" Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 6890F15749A for ; Fri, 3 May 2024 17:08:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714756128; cv=none; b=rLDMtm/xKti5t+2uRcCQuKV9a2eWcm4afVB6FpQXokqC8Zrl452Sz7gHoBbe2Y2CVVmbNnFLygcPnXyL0RBkJkLoFNHSJZNvg2v5izlw88y6uokQqLwxE7xpQFQnd5LmWby1sWAcTDRk5kRja1lm9Z+IkYMCID5XAZQclcBUtVA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714756128; c=relaxed/simple; bh=tjBVqV0e3mB+a3mVKNBc8waALPm4yw/SXl9iYAZEwA8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MsGDHsEO1AFjJAGt5JBSJU9qt61J9vN8eZQJ2WBlx7KZAhYUO8nLeaa2wjKyN+NfesZdFp8vdSeOvKWxMIA4DBezgnvfH/tAHWwnhdK4eZFrWPvPaS3HTkUWXME4hZ7SmbQzmvN1XQFmCjfwcW4PBc3DByOWyb0mkYStwORM1dY= 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=BCEkRgcW; arc=none smtp.client-ip=209.85.216.48 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-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2a2d82537efso6342373a91.2 for ; Fri, 03 May 2024 10:08:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1714756123; x=1715360923; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=gt87Sr6itbk+KMDGSG8ct9g9uJtFf//vhHjuaZsqwkI=; b=BCEkRgcWZzoVlTSP0r3hZj3I2m62la7ouhXHSWwJ23MVcobra2m8kJkP8UoPTGfwuk iWr/20k9qORu1///ne6wofNUPzAawXDZolKfbT+4VmUkc3+ZMhmAmx0gL9jj4w88oiw6 P4xRi4JEe4f33KaoVrWRpkIESEOGEqM+uyRqZm9oIR0mOssk4VwYVv43gioh0WdIKc94 Xn0fBNOJKIXcXGIykXZ7eSTkU8GE55FHQkVw2XLCrmBLQMhlEf7gD6mbsgEo+lmhpMLN bHnFRtAFqU2Ebl/GIv5xgwxusoYthCn3RPqPHpBW7BgabUzFjK81ixpxsbdGHbySDODP f8MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714756123; x=1715360923; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gt87Sr6itbk+KMDGSG8ct9g9uJtFf//vhHjuaZsqwkI=; b=mVOyTgCqF1l9Mx5fGxs+MkSs/3CvM58VZWvGu1wZ4RPtgOPul+j3Y7tW+Z3e+bSY49 lEyBgY3JerVX+eKC/fIy3yDjkB4pvj85Hl8WeaRrJ2AyqJglLBXrmPGdIRjqxdZSUYYk /HDpgPg+NnXfhJGInjl2xctt9ANjbcSxFCmTaWyG8U/9LrGQ5LgZdRlzfoxQBSpqUDoI Nrc7m2DdhpQHoP+ETL2YcH0obm1ytOdaLrs3/aqNFQNwZwQQFfsPys6k107NPXbnhL8I 2+UpdzZOHR6pOYQYbhTiQlfg73dY3spNTIkf6HK/kv5D22QeQjD50s8sIM51vfPeX2hs 8ioQ== X-Forwarded-Encrypted: i=1; AJvYcCUyNKyduZ13HqUtSAcy6AvtxfDSnyrlvsYXdJSW9aRw2hL8hApYhGFfT+UpRzLqqVlb4vR3xmGLuqyZpd88HNaG0WXd6fu4NzMDARY1 X-Gm-Message-State: AOJu0YxEy1+pty09GvcdIi4j2RMqSA0VVF0gQvGhS/jvkup0Vjtp8z6W CAjFppnh+KxF3Da6FFVgUxsPex7dYzshL6ewCsIT2OvJSPm3Xd57N6KxxNCrHNs= X-Received: by 2002:a17:90a:4482:b0:2ac:23ec:6a54 with SMTP id t2-20020a17090a448200b002ac23ec6a54mr4152642pjg.38.1714756123566; Fri, 03 May 2024 10:08:43 -0700 (PDT) Received: from ghost ([2601:647:5700:6860:f8a2:eea3:33:d368]) by smtp.gmail.com with ESMTPSA id pq10-20020a17090b3d8a00b002af8056917csm5267863pjb.29.2024.05.03.10.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 10:08:43 -0700 (PDT) Date: Fri, 3 May 2024 10:08:40 -0700 From: Charlie Jenkins To: Evan Green 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 , =?iso-8859-1?Q?Cl=E9ment_L=E9ger?= , 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 Subject: Re: [PATCH v5 05/17] riscv: Extend cpufeature.c to detect vendor extensions Message-ID: References: <20240502-dev-charlie-support_thead_vector_6_9-v5-0-d1b5c013a966@rivosinc.com> <20240502-dev-charlie-support_thead_vector_6_9-v5-5-d1b5c013a966@rivosinc.com> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, May 03, 2024 at 09:28:24AM -0700, Evan Green wrote: > On Thu, May 2, 2024 at 9:46 PM Charlie Jenkins wrote: > > > > Separate vendor extensions out into one struct per vendor > > instead of adding vendor extensions onto riscv_isa_ext. > > > > Add a hidden config RISCV_ISA_VENDOR_EXT to conditionally include this > > code. > > > > The xtheadvector vendor extension is added using these changes. > > > > Signed-off-by: Charlie Jenkins > > --- > > arch/riscv/Kconfig | 2 + > > arch/riscv/Kconfig.vendor | 19 +++++ > > arch/riscv/include/asm/cpufeature.h | 18 +++++ > > arch/riscv/include/asm/vendor_extensions.h | 34 +++++++++ > > arch/riscv/include/asm/vendor_extensions/thead.h | 16 ++++ > > arch/riscv/kernel/Makefile | 2 + > > arch/riscv/kernel/cpufeature.c | 93 +++++++++++++++++++----- > > arch/riscv/kernel/vendor_extensions.c | 18 +++++ > > arch/riscv/kernel/vendor_extensions/Makefile | 3 + > > arch/riscv/kernel/vendor_extensions/thead.c | 18 +++++ > > 10 files changed, 203 insertions(+), 20 deletions(-) > > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > > index be09c8836d56..fec86fba3acd 100644 > > --- a/arch/riscv/Kconfig > > +++ b/arch/riscv/Kconfig > > @@ -759,6 +759,8 @@ config RISCV_EFFICIENT_UNALIGNED_ACCESS > > > > endchoice > > > > +source "arch/riscv/Kconfig.vendor" > > + > > endmenu # "Platform type" > > > > menu "Kernel features" > > diff --git a/arch/riscv/Kconfig.vendor b/arch/riscv/Kconfig.vendor > > new file mode 100644 > > index 000000000000..85ac30496b0e > > --- /dev/null > > +++ b/arch/riscv/Kconfig.vendor > > @@ -0,0 +1,19 @@ > > +menu "Vendor extensions" > > + > > +config RISCV_ISA_VENDOR_EXT > > + bool > > + > > +menu "T-Head" > > +config RISCV_ISA_VENDOR_EXT_THEAD > > + bool "T-Head vendor extension support" > > + select RISCV_ISA_VENDOR_EXT > > + default y > > + help > > + Say N here to disable detection of and support for all T-Head vendor > > + extensions. Without this option enabled, T-Head vendor extensions will > > + not be detected at boot and their presence not reported to userspace. > > + > > + If you don't know what to do here, say Y. > > +endmenu > > + > > +endmenu > > diff --git a/arch/riscv/include/asm/cpufeature.h b/arch/riscv/include/asm/cpufeature.h > > index 0c4f08577015..fedd479ccfd1 100644 > > --- a/arch/riscv/include/asm/cpufeature.h > > +++ b/arch/riscv/include/asm/cpufeature.h > > @@ -35,6 +35,24 @@ extern u32 riscv_vlenb_of; > > > > void riscv_user_isa_enable(void); > > > > +#define _RISCV_ISA_EXT_DATA(_name, _id, _subset_exts, _subset_exts_size) { \ > > + .name = #_name, \ > > + .property = #_name, \ > > + .id = _id, \ > > + .subset_ext_ids = _subset_exts, \ > > + .subset_ext_size = _subset_exts_size \ > > +} > > + > > +#define __RISCV_ISA_EXT_DATA(_name, _id) _RISCV_ISA_EXT_DATA(_name, _id, NULL, 0) > > + > > +/* Used to declare pure "lasso" extension (Zk for instance) */ > > +#define __RISCV_ISA_EXT_BUNDLE(_name, _bundled_exts) \ > > + _RISCV_ISA_EXT_DATA(_name, RISCV_ISA_EXT_INVALID, _bundled_exts, ARRAY_SIZE(_bundled_exts)) > > + > > +/* Used to declare extensions that are a superset of other extensions (Zvbb for instance) */ > > +#define __RISCV_ISA_EXT_SUPERSET(_name, _id, _sub_exts) \ > > + _RISCV_ISA_EXT_DATA(_name, _id, _sub_exts, ARRAY_SIZE(_sub_exts)) > > + > > #if defined(CONFIG_RISCV_MISALIGNED) > > bool check_unaligned_access_emulated_all_cpus(void); > > void unaligned_emulation_finish(void); > > diff --git a/arch/riscv/include/asm/vendor_extensions.h b/arch/riscv/include/asm/vendor_extensions.h > > new file mode 100644 > > index 000000000000..bf4dac66e6e6 > > --- /dev/null > > +++ b/arch/riscv/include/asm/vendor_extensions.h > > @@ -0,0 +1,34 @@ > > +/* SPDX-License-Identifier: GPL-2.0-only */ > > +/* > > + * Copyright 2024 Rivos, Inc > > + */ > > + > > +#ifndef _ASM_VENDOR_EXTENSIONS_H > > +#define _ASM_VENDOR_EXTENSIONS_H > > + > > +#include > > + > > +#include > > +#include > > + > > +/* > > + * The extension keys of each vendor must be strictly less than this value. > > + */ > > +#define RISCV_ISA_VENDOR_EXT_MAX 32 > > + > > +struct riscv_isavendorinfo { > > + DECLARE_BITMAP(isa, RISCV_ISA_VENDOR_EXT_MAX); > > +}; > > Nice, I think this was a good compromise: being honest with the > compiler about the fixed array sizes, with the tradeoff that all > vendors have to use the same ceiling for the number of bits. If one > vendor raises this ceiling absurdly and starts creating huge amounts > of waste we can revisit. > > > + > > +struct riscv_isa_vendor_ext_data_list { > > + const size_t ext_data_count; > > + const struct riscv_isa_ext_data *ext_data; > > + struct riscv_isavendorinfo per_hart_isa_bitmap[NR_CPUS]; > > + struct riscv_isavendorinfo all_harts_isa_bitmap; > > +}; > > + > > +extern struct riscv_isa_vendor_ext_data_list *riscv_isa_vendor_ext_list[]; > > + > > +extern const size_t riscv_isa_vendor_ext_list_size; > > + > > +#endif /* _ASM_VENDOR_EXTENSIONS_H */ > > diff --git a/arch/riscv/include/asm/vendor_extensions/thead.h b/arch/riscv/include/asm/vendor_extensions/thead.h > > new file mode 100644 > > index 000000000000..48421d1553ad > > --- /dev/null > > +++ b/arch/riscv/include/asm/vendor_extensions/thead.h > > @@ -0,0 +1,16 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ > > +#ifndef _ASM_RISCV_VENDOR_EXTENSIONS_THEAD_H > > +#define _ASM_RISCV_VENDOR_EXTENSIONS_THEAD_H > > + > > +#include > > + > > +#include > > + > > +/* > > + * Extension keys must be strictly less than RISCV_ISA_VENDOR_EXT_MAX. > > + */ > > +#define RISCV_ISA_VENDOR_EXT_XTHEADVECTOR 0 > > + > > +extern struct riscv_isa_vendor_ext_data_list riscv_isa_vendor_ext_list_thead; > > + > > +#endif > > diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile > > index 81d94a8ee10f..53361c50fb46 100644 > > --- a/arch/riscv/kernel/Makefile > > +++ b/arch/riscv/kernel/Makefile > > @@ -58,6 +58,8 @@ obj-y += riscv_ksyms.o > > obj-y += stacktrace.o > > obj-y += cacheinfo.o > > obj-y += patch.o > > +obj-y += vendor_extensions.o > > +obj-y += vendor_extensions/ > > obj-y += probes/ > > obj-y += tests/ > > obj-$(CONFIG_MMU) += vdso.o vdso/ > > diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c > > index 12c79db0b0bb..cc9ec393c8f6 100644 > > --- a/arch/riscv/kernel/cpufeature.c > > +++ b/arch/riscv/kernel/cpufeature.c > > @@ -24,6 +24,7 @@ > > #include > > #include > > #include > > +#include > > > > #define NUM_ALPHA_EXTS ('z' - 'a' + 1) > > > > @@ -102,24 +103,6 @@ static bool riscv_isa_extension_check(int id) > > return true; > > } > > > > -#define _RISCV_ISA_EXT_DATA(_name, _id, _subset_exts, _subset_exts_size) { \ > > - .name = #_name, \ > > - .property = #_name, \ > > - .id = _id, \ > > - .subset_ext_ids = _subset_exts, \ > > - .subset_ext_size = _subset_exts_size \ > > -} > > - > > -#define __RISCV_ISA_EXT_DATA(_name, _id) _RISCV_ISA_EXT_DATA(_name, _id, NULL, 0) > > - > > -/* Used to declare pure "lasso" extension (Zk for instance) */ > > -#define __RISCV_ISA_EXT_BUNDLE(_name, _bundled_exts) \ > > - _RISCV_ISA_EXT_DATA(_name, RISCV_ISA_EXT_INVALID, _bundled_exts, ARRAY_SIZE(_bundled_exts)) > > - > > -/* Used to declare extensions that are a superset of other extensions (Zvbb for instance) */ > > -#define __RISCV_ISA_EXT_SUPERSET(_name, _id, _sub_exts) \ > > - _RISCV_ISA_EXT_DATA(_name, _id, _sub_exts, ARRAY_SIZE(_sub_exts)) > > - > > static const unsigned int riscv_zk_bundled_exts[] = { > > RISCV_ISA_EXT_ZBKB, > > RISCV_ISA_EXT_ZBKC, > > @@ -353,6 +336,21 @@ static void __init riscv_parse_isa_string(unsigned long *this_hwcap, struct risc > > bool ext_long = false, ext_err = false; > > > > switch (*ext) { > > + case 'x': > > + case 'X': > > + if (acpi_disabled) > > + pr_warn_once("Vendor extensions are ignored in riscv,isa. Use riscv,isa-extensions instead."); > > + /* > > + * To skip an extension, we find its end. > > + * As multi-letter extensions must be split from other multi-letter > > + * extensions with an "_", the end of a multi-letter extension will > > + * either be the null character or the "_" at the start of the next > > + * multi-letter extension. > > + */ > > + for (; *isa && *isa != '_'; ++isa) > > + ; > > + ext_err = true; > > + break; > > case 's': > > /* > > * Workaround for invalid single-letter 's' & 'u' (QEMU). > > @@ -368,8 +366,6 @@ static void __init riscv_parse_isa_string(unsigned long *this_hwcap, struct risc > > } > > fallthrough; > > case 'S': > > - case 'x': > > - case 'X': > > case 'z': > > case 'Z': > > /* > > @@ -572,6 +568,59 @@ static void __init riscv_fill_hwcap_from_isa_string(unsigned long *isa2hwcap) > > acpi_put_table((struct acpi_table_header *)rhct); > > } > > > > +static void __init riscv_fill_cpu_vendor_ext(struct device_node *cpu_node, int cpu) > > +{ > > + if (!IS_ENABLED(CONFIG_RISCV_ISA_VENDOR_EXT)) > > + return; > > + > > + for (int i = 0; i < riscv_isa_vendor_ext_list_size; i++) { > > + struct riscv_isa_vendor_ext_data_list *ext_list = riscv_isa_vendor_ext_list[i]; > > + > > + for (int j = 0; j < ext_list->ext_data_count; j++) { > > + const struct riscv_isa_ext_data ext = ext_list->ext_data[j]; > > + struct riscv_isavendorinfo *isavendorinfo = &ext_list->per_hart_isa_bitmap[cpu]; > > + > > + if (of_property_match_string(cpu_node, "riscv,isa-extensions", > > + ext.property) < 0) > > + continue; > > + > > + /* > > + * Assume that subset extensions are all members of the > > + * same vendor. > > + */ > > + if (ext.subset_ext_size) > > + for (int k = 0; k < ext.subset_ext_size; k++) > > + set_bit(ext.subset_ext_ids[k], isavendorinfo->isa); > > + > > + set_bit(ext.id, isavendorinfo->isa); > > + } > > + } > > +} > > + > > +static void __init riscv_fill_vendor_ext_list(int cpu) > > +{ > > + bool first = true; > > + > > + if (!IS_ENABLED(CONFIG_RISCV_ISA_VENDOR_EXT)) > > + return; > > + > > + for (int i = 0; i < riscv_isa_vendor_ext_list_size; i++) { > > + struct riscv_isa_vendor_ext_data_list *ext_list = riscv_isa_vendor_ext_list[i]; > > + > > + if (first) { > > + bitmap_copy(ext_list->all_harts_isa_bitmap.isa, > > + ext_list->per_hart_isa_bitmap[cpu].isa, > > + RISCV_ISA_VENDOR_EXT_MAX); > > + first = false; > > I think this is still not quite right. This behaves properly when > called on the first cpu (let's say 0), but then we call it again with > cpu 1, first gets set to true, and we clobber the old work we did for > cpu 0. If we knew that cpu 0 was always called first (this looks true > since both calls are within a for_each_possible_cpu() loop), and that > this was only called once at boot for cpu 0 (looks true, and > riscv_fill_hwcap() is __init), then it could be bool first = cpu == 0. Assuming that the first cpu is 0 should be safe, but to eliminate that assumption we can pass in a "first" parameter into this function that will only be true the first time this function is called. We also keep "first = false" in this function so the copy only happens on the first iteration of the first cpu. - Charlie