From patchwork Fri May 3 18:18:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13653283 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7144CC4345F for ; Fri, 3 May 2024 18:20:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5d9XubNfkkCgv1CfpMKMhvAZevtnFDzoK6o5f8dePbY=; b=JUeJlwsRxFvM8R wUs1W5c/JG8G0P54w+A+HtfXOjcdJZmZvHRu+MDHxl75X4tBU0gywPbkvRELi5mPYZAyupAze/Mi0 M5RVICSEYWQtGLwE9SPhEcuCVoj1onHGui6AdxJQYqbfS0SFd7ZYMKvRDs5BmEmFXFzeV357P7i6F iLpkzgUK1OurlvjLfbmnMkqyaOMfNBJ6R785O81ZvGHur/EEckzK8RmpiLEHprKXMZD/T980fgeAZ neCB+x42AgJ+ReGGBRp+42Q5JJoSqJRfD2O9gbRjcVMempjpbAjiua3Zm7A7//SfsQQWeG0VAwB29 lbEOxDOrrWNxfgOYjBUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2xVe-0000000HXal-2E9T; Fri, 03 May 2024 18:19:50 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2xUx-0000000HX3H-4ACE for linux-arm-kernel@bombadil.infradead.org; Fri, 03 May 2024 18:19:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Cc:To:In-Reply-To:References:Message-Id :Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender :Reply-To:Content-ID:Content-Description; bh=g1x3fnfXZgKbRNZW52PQl31Hn8/VT/niX2j925w6Muw=; b=gtXFKZXzNuXBxt4D0goZ4OFVhE FGu0Da/aCgrKu1WlUYenzI7ymzc+ZYoYQGN9jYFU5vHOL+kH+ULs7Nu3UvwPrD/kCErLpA/uxjvA7 XG9iEZsOHT7UOA99peXbZ31xHpFWdtV+1Wkw/iJ9csmnCUlNfE0CJOpUSU5JzsjwTD7HnSUd8JTRi EwDaAPv4d1tkvRmFHxKC1Q38tU3OAtrxcoTQTq5jf/PX+qhUnHCRmnI5BFlqCs62aqREdnXlEm2HA 5BmGaxkNA/7HT6WX8SXkoWwv5DOHb0tfYIyYCYkvZES38v86DoIxJl1ayBHkos8saXtmvT1cSc8Af pmbVdW0w==; Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2xUu-00000004cxn-2sha for linux-arm-kernel@lists.infradead.org; Fri, 03 May 2024 18:19:06 +0000 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-60585faa69fso2353178a12.1 for ; Fri, 03 May 2024 11:18:56 -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=lists.infradead.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=1DZ4SciUQWMlsK33oWtB2xFhdwqKcN0KRWjTZZMj/2pXOkLiA50dH7Vdk5yTnV2JWc 4IOZXyrpVYRMReCaL9zcCekyzJa5RRjiGbE5cT8uEky3zkhPX9TKE0NRX15BSjDUVu2V 8XxAOwOgnyE+57bOQjCbNKQ0vmXRoXgBKIE4Tu0ML/XmeNn8DrEpE3Sy1hje0rvuDVOE pViGv16wwNlE+g+Nle/JA36q1hZXxhyqXSZ72/SXyYVypCjYoh44Plk4z45I5SJVxwBb w3HCYD2POoqvX8PzoQcqA9+tbgfVxW5GxdMu6TqOdrz6a0WmeHX8B5wPWyetp7peeXeM 0wCg== 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=Cbm8pMg4RJsHizBnD7fiq9v5i6h+KlhJp8GU+XIORVY87D0Twgcev0NHRx+CEY6BKc 3MjeL/5CmiZLxkdo0h189bNrpF29RlvumFzKPr+HIQ5Zkij0Rqq6YO2I9cBAighi48l3 t4+VOUVt7jG6WBc+uT1gA1XZiwfIZ+cTf4LwV/IFGrDtwE++LNYKmwkif3FG5qOApLmY 5jXlWxKGeRDpwOsyivyCiyNanow3MMvBlcd2zD5U6HlPkykq0XNZTX/t2yHz5eM0xc1R jLvqrQ2WeArzDRaCfukcVEsDT0uDV2c1ETJYp6Q6xMJ0rFd88reMEKldLoy/g95hVnj5 Hckw== X-Forwarded-Encrypted: i=1; AJvYcCXs9hmppkCiixlbDFXvH2Q85OAwZtA9ZmkHHJCDYz/4xmFEtFpzJpG71S7m6IKzZQlmx2A2kM2vG7IVcIQbZHmaTeRjeZtFJHx8WFDPeCNhtBZMlyk= X-Gm-Message-State: AOJu0YzqBEZSbmgjeWz0BOVrJVPhPoBzwXuLuh64jU9rc7vDYVD/6j8q PD7jlNrHmhBQPKbownwf4ENkccHLJUNmi7rgqrRs9bYrmAEx8i/aDR3TC8hhVJrfPAcZo1l1l6c b X-Google-Smtp-Source: AGHT+IFtffChuwBhS5Hm7XU8F8qXkdTP8YFkTdZYyG5ns+Etj9MDZuxDDNk7FtJ718xCtJB8CuLs2g== 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 MIME-Version: 1.0 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?b?Q2zDqW1lbnQgTMOpZ2Vy?= , 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= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240503_191904_797036_57BBB9CC X-CRM114-Status: GOOD ( 12.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Evan Green Reviewed-by: Conor Dooley --- 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;