Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1603lqh; Fri, 3 May 2024 11:22:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUgUIdVmjU5HCV+rptDQOAPTysF1CSouQOj9TY/rJmrwdmPxLiFQzN+9wD8TXDVEBiiJt+2yMO+bDI8UqD9ehlPmJEVdojvphVMtpyExw== X-Google-Smtp-Source: AGHT+IFXcrTAJWA8UVY9AN40FiKlb0LFjf1aJAT4q4NlfYMlntpf6KwvGgM/70P28adiKUizjlaX X-Received: by 2002:a05:622a:2a06:b0:437:b7bd:368a with SMTP id hc6-20020a05622a2a0600b00437b7bd368amr10888765qtb.19.1714760522284; Fri, 03 May 2024 11:22:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714760522; cv=pass; d=google.com; s=arc-20160816; b=PzQgG9CPp8OrQ8l8Ktfl1njawJz3IyzsvT+Q/Wkzg/zdV3Lfa6tZ5iuFtfbcwt1Ew+ x5dgOOj4obPhA/V4XeMce7sTTvwhR5DzkWMBBlcfvdlNcZpPG1k0EBoMGWXr1G7D8O3s /XJcPG/sLfjRS1M0GgtAEsgZT3cX/DE40zXMIViasI4MyQl9Au/pyGtQsZBeg0+Eexsp vqnbuPWmlxJoXZ2X5v3D1giZyvA5L2XiixDR8eg8So2V4bjjVAJGPjYts7FoBFGOdYsv 8NYS6n8Zz6SFnCoGn8jcOGYryq0mez9h/tk7zLZ5MkHsY6gAC2K5HNIcDB7iV/yZ3pY5 vNrw== 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=2Om3KbNN05GcWVWO2XEIddsnvf/ryylfR81yg2rSdw8=; b=D3Q2np5kw43O5L5qBsqdzg3NkgQngiqlAAsPtwspgfXDIzES6r6LVytMm5OQUX5PL0 9O/mKBYWJv5wPIbjeqYe3T7NCF5OmD2SVmZ9ht7RLQfGACPvsXPEj/qSB3dcAMsmZAXa 1Y/T1JYmMLEzu8HZcPB8eBfHAyVLDZJ956G/jzwqcpB4odIIkjLl1gucpPZmFbwjMxIr eT4slYpKbSPY70q0z1TMG6chPBtN49QJTO5veIXnioszpfgYPAQhP/oh0ntvUGgWlZO5 f1ut4+mRyOnC2/WLy6iDb7gupFRgRhwWI8u/2LK0/BCLC3wkdhUJ21w0zFnIJ6V5LXZR TqpA==; 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=lyba4WAC; 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-168035-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168035-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t37-20020a05622a182500b004347d76f444si4013854qtc.597.2024.05.03.11.22.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 11:22:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168035-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=lyba4WAC; 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-168035-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168035-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 726EE1C20819 for ; Fri, 3 May 2024 18:22:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF95C159914; Fri, 3 May 2024 18:18:57 +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="lyba4WAC" Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 6A8901598FF for ; Fri, 3 May 2024 18:18:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714760336; cv=none; b=jTw4A5hKqE0cBoAbui/wcYOtG2EJJ8+MMxfh3zY413e8ubIVCgl7AMAF073bqTsCUyHUiw7I5hBsTGxlqbd9PAhtzN/su1dUNn2fmzhR+uDl6uueH2S5i0io8PO3Mw4IOzT+FP5hS4PSQNj/hkeWB6inVDE/OR4lQCr1yW+ixWY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714760336; c=relaxed/simple; bh=pqN1lFvFRjrgQQgZqYCWrh0drQd/FoIFRL9Qt9AtemU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Kw2SiOjLLYO8BEW7Zro/pE6J1xFmL9raWPVvLZTE6Lbv47S1vIr1Jk6YCbI7z6iulyrEX2rYiJCUaJ+MSYI4jq1LMB66LwvOUO2ZttaYZ/CnrMsStZdqsGjMTG1fd3Ze8Zzi4QX9VKMV2mk9hafaNtIOm2ozQKnNoTxGCPd2p+A= 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=lyba4WAC; arc=none smtp.client-ip=209.85.210.173 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-pf1-f173.google.com with SMTP id d2e1a72fcca58-6f4302187c0so1909981b3a.1 for ; Fri, 03 May 2024 11:18:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1714760335; x=1715365135; 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=lyba4WACzGSqraro/e4yYMBxoBGMjBs6+b0QtPONCbdHAHV44o4GcfXq5AIYXE1QMJ aaw9KiMooSTgFx2RaoGXbMkvWbcg3bPJxrm9c1ZJFJ+SAmjn3OAK10FdthJ0QnV8lU8P j2OBHg21OXVaaW2YYCH84PN7Q3+yTBFLN0LR+I4njMWwP5rRk4suH5FuJ9qcuHRGVadu GNRrHzIvmAqFUElsHHBlPJvMi6HkI0pwCzNbn42bvpwMTCizEdCnegWpuLT7shZVMOzr I06C3IiVWHGBMdZjDIEfFLw1bdQUEkOvZ13FngaZ+wU/ReddVelxDpAhrjIvbJ1UcTEP uEXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714760335; x=1715365135; 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=WNzJM0ShMIvg24ZVvwM7uahxLwZ9g+/ULV0Rgg0lHIwMIfyDMEvhh/ga5AEZ+rpKVD t6Z5z1tpxSiVrRFLmfXESKPgrZCE3zR39vEDFqIvEoih6OHBuBPB+TC6OJGSrN2y0hdl M0JSnufsDruDGJGd9YxJRCOYhcVT34SU9++Cz2CMAzcrmHAwfsDYCoIExQgBO43oc5ty Tdl83J7rhy6DglnKCeqybZkQchnw21SLLT2eQnHZEh4UNpG2Xl7+okviIDZCDFt/5pSi 6fZzIWNhjCuVswXCQDKvFZrmHQB0hDn14s34AqvjAkVC0Ur0WccnbG8oXf/QurLg0Msj qA3A== X-Forwarded-Encrypted: i=1; AJvYcCW/k89qkSQtmQ/qW/CLJZGYbwHINsqxFb1XRxa8wpHI/xI06eJ9eELa7f1CDijXmfsssCvj2D+WYRaOmUrw7/UpvqiXkySyZT9yl0wv X-Gm-Message-State: AOJu0YynVIsVnG/eP1Zqh3e80zH5/vMLfJOIuBshzYA//e/cCM8VWwMO O2dXWzogUSM7ej26hCseFlE6nK2qnfHmE6Wdexz4DQjwsPY9IRvQ6dLPpR3Gc98= X-Received: by 2002:a05:6a20:104d:b0:1a9:11e5:2915 with SMTP id gt13-20020a056a20104d00b001a911e52915mr3981411pzc.27.1714760334670; Fri, 03 May 2024 11:18:54 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id fu6-20020a056a00610600b006f3f5d3595fsm3355421pfb.80.2024.05.03.11.18.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 11:18:53 -0700 (PDT) From: Charlie Jenkins Date: Fri, 03 May 2024 11:18:21 -0700 Subject: [PATCH v6 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: <20240503-dev-charlie-support_thead_vector_6_9-v6-6-cb7624e65d82@rivosinc.com> References: <20240503-dev-charlie-support_thead_vector_6_9-v6-0-cb7624e65d82@rivosinc.com> In-Reply-To: <20240503-dev-charlie-support_thead_vector_6_9-v6-0-cb7624e65d82@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=1714760318; l=2459; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=pqN1lFvFRjrgQQgZqYCWrh0drQd/FoIFRL9Qt9AtemU=; b=mSKF8x/jDoWL2qt9MbecKfiOANTWEfzH0iw4ND1E+SV0TbNnB9ytivBteSpS+Z2vjGFzFTRiQ UdfwX8NaOz5BpeYweh8Wk3kACtc1ksmEmsYKFfUKkaZcms6Ck2Wyrck 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