Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1564623lqm; Thu, 2 May 2024 21:48:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXvNyR4bqHddJ2s2IjWYg6pojiI/rUmsAjsr6pmBkA705wjQs/87M0uYhVzbiBDQ1ouFPzxpqGZyJJZZ3tT4qYcRFppcO3IsnOWwb0EYA== X-Google-Smtp-Source: AGHT+IHq8XW1uRutdRZYIVfkVxEeCVDISDv3KvJ6YCP7rERoNmW1q6e1rrnIqAsw+tGOpp9VJTN4 X-Received: by 2002:a17:903:2284:b0:1eb:2f02:cd0d with SMTP id b4-20020a170903228400b001eb2f02cd0dmr2548018plh.0.1714711717431; Thu, 02 May 2024 21:48:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714711717; cv=pass; d=google.com; s=arc-20160816; b=JxUZwTkR+yL4rNL5kYY/644LREWEte3JWrHFiOnysa+cfOwN2FHHCNDS7i3tYNGA7k 0veg+vQFPigFDAmv4eN+YbWtRH38PEW6+pz+9ldnMqJ2ET9Q+yvl7z08Lp877nv9AMsu 0vfJyQ3AT63QLhZQON7TyZHW1AZVJyVGP7j5AYNVoOW9pLdYdg+htIE+bJj9++pVJEV1 DSV3MusDRjw1t6wc7n9yzNpd3H/eOdUJ0LhNtYF0D3v7U7dAG7o3a0ptUmOvYhb+ezue 75Xu/9B3nslHpiTxci3JyxfC87IEMNSaOk8fmWB1LvsYLhBfcfaeUPWaP59LSaAEF4AE OkAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=g1x3fnfXZgKbRNZW52PQl31Hn8/VT/niX2j925w6Muw=; fh=csLojU1HGYGmBDX083sTWovv9EwvEWHjsEovjMjJM4I=; b=bQ4vG25Vbmjn4YVlkM8vGY7MACCxX5c3dtGQ55+5Umj9Pqus0nceCOE5qOuKYYbPvl EFyNXBUUYRvWVQr7wHrJADJr8ywYwr29YZJANsPyH5OS8oSjf6odSkV5zksbpL+LIGUR YK3uQIMB7j8tNLLSgBG7I5ZNAaAGuBzsG7XBOjp7FYJMq3MfkyPrP6+4szqPCO95ZO6g HI/iuTnmfVFqtFjHcFYPFTzfQYBhY82/z0sqB0Ljd4s/uu2escpyQgTtWx4aNIJgNiGG niMb8vcYZRjHYzMCuggQRixtOi6E5XheJnaJ+CV0FK8iWQ7bAL/ulnjeOLVHWXEVyPIg MalQ==; 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=tUmRuimO; 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-167237-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167237-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l4-20020a170902f68400b001eb992b788esi2195634plg.464.2024.05.02.21.48.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 21:48:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167237-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=tUmRuimO; 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-167237-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167237-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id EC718280C78 for ; Fri, 3 May 2024 04:48:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AAFB013B28D; Fri, 3 May 2024 04:46:59 +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="tUmRuimO" Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 45DE613AD3F for ; Fri, 3 May 2024 04:46:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714711618; cv=none; b=Kd7X+IhU2hJC5cmSm/XHBpz5UN5X1N7y95AFr9noXt/Z8ypj9MOoC1qh8C+AfMCt2JIsyc/AGsV8C3vqCJbm8DTU7VoTDbkkcPeITHRyko37lavt9a/hae+JkZSUYF3LwNLFgK/Mw6SYashB0UwXi4oRR6WHkB7Ex6HhOKIP5xg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714711618; c=relaxed/simple; bh=pqN1lFvFRjrgQQgZqYCWrh0drQd/FoIFRL9Qt9AtemU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u1NtUXLXOj0E4Yq/ZdbwfkdPytLNhqbDZZXpcAxeeJ2JvekzZ0amZ/Nn3pOtkLP6qR66tMWsuVej89IHwG4ddXJZ5XO80pylVY6MgQvHdqDbtYLThHSl2zew2USXVH6Ec/XsrE8DMW5j65sc0OhTxLyytaU7511T+4aLXyGqxCU= 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=tUmRuimO; arc=none smtp.client-ip=209.85.214.171 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-pl1-f171.google.com with SMTP id d9443c01a7336-1e65a1370b7so81150305ad.3 for ; Thu, 02 May 2024 21:46:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1714711617; x=1715316417; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=g1x3fnfXZgKbRNZW52PQl31Hn8/VT/niX2j925w6Muw=; b=tUmRuimOjsN/lQbEklDW0kopDD8XeDISMvJEM1n4GrssIVVVJILQi3UKV5qVbz1vYU GTS5AExqQUjiR3SmMdX0hB5/RZwqvZ7/VY/dOoN4ERRuzK3XyJnjOyZEhbJDdgExwajq 0EN+nH3vyrVu9V35uduP54jGTik8u+9/Vx/pqUYJRlG/hgyBJyGAknvn8jk7KE1yLy7/ oozon+OGdwnFEsZ/GZJEC/U4fovqwbDRhy1t28U/9oPeWU4jPWo0IFGtP/TgGdpTafqi RH5loMNS+mTjfMp+QtOXYE48eJEl0WAtJKTRnmek1BT+rWlPoTo5R9fwD1tQl9dvJsav RgJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714711617; x=1715316417; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g1x3fnfXZgKbRNZW52PQl31Hn8/VT/niX2j925w6Muw=; b=wT+fdkfo5PIj7bp6SZl+dOh5L704wfMUW780Q6Ksj+mPgipTZG/0Z7ob3ictaxVHU6 OOLXOU0c1v7wXz1zdcNsGNPWQJTbHo7RnM8b9SpFrg0DptNqW2+UtmpDtHiM9HwIuYGA SAytVeLbL0tfJEmoidCen6jJ3L2/Tp86/7ltg8h/JZyq+FzfGYwbsxg8DmFyT9hRvQGT ZTFwW5nPQiFMX7YYQFH61ktfdwD2zlFvVQO7bFFG99RWn3uNwjgD6bbur9DkyUFWS8dZ 7M2NJOFok4+DTry8U540pst71x024Cyt0wQVWJfe03O+u4JJQOFXFKtvoO1IsDBngNDJ SI1A== X-Forwarded-Encrypted: i=1; AJvYcCWzU+cWka0OKZ+ywiKSDdYL1xMhOKVef+cPYm/Y1KO+5kx2PwFIZgSR/UqcI9NHNzyDWqJtCwzja5UhIhUpu1DJ0HVxHiwPUrxVYREk X-Gm-Message-State: AOJu0YwQgd6F0+FZmvj29DQW6Qn9Hc38qZwojzwQZnDnCOMIyLNg1RVE LWmsRCSNbCLKNc/mEUkDSqjnpOA2cS+IyGmNBh1PwUnCfFS/Fn+SsnF8v77XdQU= X-Received: by 2002:a17:902:ecc7:b0:1eb:dae:bdab with SMTP id a7-20020a170902ecc700b001eb0daebdabmr2129152plh.46.1714711616732; Thu, 02 May 2024 21:46:56 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id e8-20020a17090301c800b001e2bb03893dsm2240411plh.198.2024.05.02.21.46.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 21:46:55 -0700 (PDT) From: Charlie Jenkins Date: Thu, 02 May 2024 21:46:41 -0700 Subject: [PATCH v5 06/17] riscv: Add vendor extensions to /proc/cpuinfo 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-Transfer-Encoding: 7bit Message-Id: <20240502-dev-charlie-support_thead_vector_6_9-v5-6-d1b5c013a966@rivosinc.com> References: <20240502-dev-charlie-support_thead_vector_6_9-v5-0-d1b5c013a966@rivosinc.com> In-Reply-To: <20240502-dev-charlie-support_thead_vector_6_9-v5-0-d1b5c013a966@rivosinc.com> To: 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 , Evan Green , =?utf-8?q?Cl=C3=A9ment_L=C3=A9ger?= , Jonathan Corbet , Shuah Khan Cc: 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, Charlie Jenkins X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1714711602; l=2459; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=pqN1lFvFRjrgQQgZqYCWrh0drQd/FoIFRL9Qt9AtemU=; b=H+DX3cVVjv1vLieQvFF/GzHeHnV6V/D0UYWMIUMz9yJnTEHNzwd2Lhb1bwFvj20Y7hip0X35P f1ya+z76CwvDzykr4rBxhsKf62CDwPGbJNyH02uPIH6mLHUmhes2dAq X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= All of the supported vendor extensions that have been listed in riscv_isa_vendor_ext_list can be exported through /proc/cpuinfo. Signed-off-by: Charlie Jenkins --- arch/riscv/kernel/cpu.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index d11d6320fb0d..2a7924dd809b 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -16,6 +16,7 @@ #include #include #include +#include bool arch_match_cpu_phys_id(int cpu, u64 phys_id) { @@ -203,7 +204,33 @@ arch_initcall(riscv_cpuinfo_init); #ifdef CONFIG_PROC_FS -static void print_isa(struct seq_file *f, const unsigned long *isa_bitmap) +#define ALL_CPUS -1 + +static void print_vendor_isa(struct seq_file *f, int cpu) +{ + struct riscv_isavendorinfo *vendor_bitmap; + struct riscv_isa_vendor_ext_data_list *ext_list; + const struct riscv_isa_ext_data *ext_data; + + for (int i = 0; i < riscv_isa_vendor_ext_list_size; i++) { + ext_list = riscv_isa_vendor_ext_list[i]; + ext_data = riscv_isa_vendor_ext_list[i]->ext_data; + + if (cpu == ALL_CPUS) + vendor_bitmap = &ext_list->all_harts_isa_bitmap; + else + vendor_bitmap = &ext_list->per_hart_isa_bitmap[cpu]; + + for (int j = 0; j < ext_list->ext_data_count; j++) { + if (!__riscv_isa_extension_available(vendor_bitmap->isa, ext_data[j].id)) + continue; + + seq_printf(f, "_%s", ext_data[j].name); + } + } +} + +static void print_isa(struct seq_file *f, const unsigned long *isa_bitmap, int cpu) { if (IS_ENABLED(CONFIG_32BIT)) @@ -222,6 +249,8 @@ static void print_isa(struct seq_file *f, const unsigned long *isa_bitmap) seq_printf(f, "%s", riscv_isa_ext[i].name); } + print_vendor_isa(f, cpu); + seq_puts(f, "\n"); } @@ -284,7 +313,7 @@ static int c_show(struct seq_file *m, void *v) * line. */ seq_puts(m, "isa\t\t: "); - print_isa(m, NULL); + print_isa(m, NULL, ALL_CPUS); print_mmu(m); if (acpi_disabled) { @@ -306,7 +335,7 @@ static int c_show(struct seq_file *m, void *v) * additional extensions not present across all harts. */ seq_puts(m, "hart isa\t: "); - print_isa(m, hart_isa[cpu_id].isa); + print_isa(m, hart_isa[cpu_id].isa, cpu_id); seq_puts(m, "\n"); return 0; -- 2.44.0