Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4792900rdb; Fri, 29 Dec 2023 13:51:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEsnA4j+YFakACOm6CYXfKVQTEJYs3YI1bN3fA93G24WNxW8IZLOGORYKr1FsYcZ52tZqKS X-Received: by 2002:a05:6a20:4326:b0:196:9d69:d557 with SMTP id h38-20020a056a20432600b001969d69d557mr522787pzk.15.1703886691363; Fri, 29 Dec 2023 13:51:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703886691; cv=none; d=google.com; s=arc-20160816; b=Y7LCSbtfbEFw9w7A2NL/CAPh7XlluN9dQtCfohdlojgUFsxDmECCK5Ly6Gouh+wL7E Bm3kJF0UThpyJgEliseG6V+8D5PhYwGZsdYXI/y9SnGgGtIUEXaEm9iw3Dt5beVVN3Ak VWZ/S65EM3R8smDc1TtuwPAB75fbh1PSNrxKlCKCdTlbl2Ew6e7ub3WMDVIs1XFHzWgB ZjwqXvoQz/T1nk8Li3nHr3HUUO57sfL6AK61o7M4vL/wtLElY7VWUl8RWQ30RmT7fsRh tEwdu1Po0fRO/QNJGU+Un8V5S9R4htiukO/+zbdpghP3OJKeU81UPrqJdW9OmvhHZAEE ycpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Bzy66lxPBsLKj7NzWfh0sHPmHGdfbEMoaok8d/cKAlM=; fh=lUUv6V9XABNkWas2Gkm4B9sMhav4GHim/4qIPi2TEOw=; b=0prBzXEE8jOVuj/DQO+pKO/sDmvb6Lk/ZQPDYaNWUlo12C2Uy9CHlAryzhGGRLX0Av 18pniGVGn4Q8LH+XHICcWo6eg92vDUuhnz5IhDJcSh/Hkuk+H20fwRz2BFOLZOY3S+sL sYH6Ldn2Uck2Xoxq5EzdtY7fIjqDnPuAYtEUiSWOsDrqovBPaMQqyHiXuV1XvZCAetEA guDcTAk271jKMdIT9YTSetyQI8D3+EXkkaXL9n/jRE7iWlKBGOPyLZoxli9aBbsqbCwo ipNXPBa5feujnfKSUQdgbuSxNhPb/mLAGyrEZiQ+bv05Ja3Pr13Yl418Vlrqhdxng9dQ eN1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=x6qHJOUI; spf=pass (google.com: domain of linux-kernel+bounces-13251-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13251-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 q14-20020a170902dace00b001d481302139si5021506plx.360.2023.12.29.13.51.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 13:51:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13251-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=x6qHJOUI; spf=pass (google.com: domain of linux-kernel+bounces-13251-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13251-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 0B59A283F5D for ; Fri, 29 Dec 2023 21:51:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7AC6815AFA; Fri, 29 Dec 2023 21:50:09 +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="x6qHJOUI" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) (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 69CFC156E5 for ; Fri, 29 Dec 2023 21:50:07 +0000 (UTC) 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-oo1-f45.google.com with SMTP id 006d021491bc7-59496704246so2366361eaf.2 for ; Fri, 29 Dec 2023 13:50:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1703886605; x=1704491405; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Bzy66lxPBsLKj7NzWfh0sHPmHGdfbEMoaok8d/cKAlM=; b=x6qHJOUIl8u3MbW8LNtDl1CWgSvqprj/ug6IYuMJtIwJxY6J9mN9joJvYFQOga5Bu2 bqltuxci5iYWQXlE8/CDOj6UygPLIttV3pNLgWNF+aCqdhnEnQw5ETzB79dfMylNA2Ok 0ar1o9s5BhYWQoNJxS7ljTV9kEsgAY2MRwzKOpiANeZzam8ez6v9tXjai6A9xNCbOorb UIj1VSYScrrXzJfTWuZoBvUdwPsKOT+So7sX+Bk+RGkx91Ybek0roZuq7SsudKZ4vlBy qnPhRB+z7DvTTpAGhncmzkTzqPRVFAeen5ALlGY+XpClvbulTk718TScm2B5XVGG1Adb lo+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703886605; x=1704491405; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bzy66lxPBsLKj7NzWfh0sHPmHGdfbEMoaok8d/cKAlM=; b=JpRWGGJoXBEFk7cODRaBUJSJ5XUcq7MCtPRqSAFK9zf9RheLt701h7CDoMGzdLM6Ps hN7tr2ZMyNBG75f5tsH6b0If/YAKuIypNOvEw83yhLh4JgtA+1Q+uY9z7A44rp/or1S/ 98X1RZKpTjwc/YvLqBBek0ATD2Y/msdisr7MiWG65HfbkIekr9RqndnrrzKYPqhQ2N4H ST+fEBhIn46tUdiAEBwnZSzL3Fl0ySYTfks0jyRD67+91AtEsWfmVWFFqoThCyPFvG4q r72ue3HxTtIFAvHX4pgs8va7IJVejt0atGMG6MiOJOpb+ojXCeKlM2+BgQ5Zv3bSu68k gRCg== X-Gm-Message-State: AOJu0YzYpLic7A4o5hHRFJScAdzG8GNkT36kOhi0+7v+8q6fLj1Y76aW mpm+rL6EVX/tgC9dosuYtTww5e5aJb84UvRmP6NGVL5D3S0= X-Received: by 2002:a05:6820:606:b0:594:c97:2e39 with SMTP id e6-20020a056820060600b005940c972e39mr9339958oow.4.1703886605705; Fri, 29 Dec 2023 13:50:05 -0800 (PST) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id r126-20020a4a4e84000000b00594e32e4364sm1034751ooa.24.2023.12.29.13.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 13:50:05 -0800 (PST) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Anup Patel , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Andrew Jones , Atish Patra , Conor Dooley , Guo Ren , Heiko Stuebner , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paul Walmsley , Will Deacon Subject: [v2 04/10] RISC-V: Add SBI PMU snapshot definitions Date: Fri, 29 Dec 2023 13:49:44 -0800 Message-Id: <20231229214950.4061381-5-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231229214950.4061381-1-atishp@rivosinc.com> References: <20231229214950.4061381-1-atishp@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit SBI PMU Snapshot function optimizes the number of traps to higher privilege mode by leveraging a shared memory between the S/VS-mode and the M/HS mode. Add the definitions for that extension and new error codes. Reviewed-by: Anup Patel Acked-by: Palmer Dabbelt Signed-off-by: Atish Patra --- arch/riscv/include/asm/sbi.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h index 914eacc6ba2e..75e95a7d9aa3 100644 --- a/arch/riscv/include/asm/sbi.h +++ b/arch/riscv/include/asm/sbi.h @@ -123,6 +123,7 @@ enum sbi_ext_pmu_fid { SBI_EXT_PMU_COUNTER_STOP, SBI_EXT_PMU_COUNTER_FW_READ, SBI_EXT_PMU_COUNTER_FW_READ_HI, + SBI_EXT_PMU_SNAPSHOT_SET_SHMEM, }; union sbi_pmu_ctr_info { @@ -139,6 +140,13 @@ union sbi_pmu_ctr_info { }; }; +/* Data structure to contain the pmu snapshot data */ +struct riscv_pmu_snapshot_data { + u64 ctr_overflow_mask; + u64 ctr_values[64]; + u64 reserved[447]; +}; + #define RISCV_PMU_RAW_EVENT_MASK GENMASK_ULL(47, 0) #define RISCV_PMU_RAW_EVENT_IDX 0x20000 @@ -235,9 +243,11 @@ enum sbi_pmu_ctr_type { /* Flags defined for counter start function */ #define SBI_PMU_START_FLAG_SET_INIT_VALUE (1 << 0) +#define SBI_PMU_START_FLAG_INIT_FROM_SNAPSHOT BIT(1) /* Flags defined for counter stop function */ #define SBI_PMU_STOP_FLAG_RESET (1 << 0) +#define SBI_PMU_STOP_FLAG_TAKE_SNAPSHOT BIT(1) enum sbi_ext_dbcn_fid { SBI_EXT_DBCN_CONSOLE_WRITE = 0, @@ -276,6 +286,7 @@ struct sbi_sta_struct { #define SBI_ERR_ALREADY_AVAILABLE -6 #define SBI_ERR_ALREADY_STARTED -7 #define SBI_ERR_ALREADY_STOPPED -8 +#define SBI_ERR_NO_SHMEM -9 extern unsigned long sbi_spec_version; struct sbiret { -- 2.34.1