Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1295762rdd; Wed, 10 Jan 2024 15:17:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWsKXAiGzBI5IAAF4Bif1hGxAcqHAlZJuwVRskxJjFi8p6HtuTWYXy/+gIuhCoqDrlZoxx X-Received: by 2002:a05:6359:220:b0:175:1f1b:3fe with SMTP id ej32-20020a056359022000b001751f1b03femr263503rwb.61.1704928676160; Wed, 10 Jan 2024 15:17:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704928676; cv=none; d=google.com; s=arc-20160816; b=aro4sGQhedAIp5HHM+DPwsGVtkvY8E6f7V/P2htZ+E5vVWfanF/e/7oM5f3FoYm3Ny QkO5BzN+vIEjZ80/xIyiwVB+/JntFY7YSy8QNiMmNCGZndxm3mCQEpskfQPP9CHaXae6 m33fa2ipEa/d0l6ts9cqwx09oE9zF3qQ3Khb6R8jYZrMLvVPixrXv1tIIPaaH7Cd64ni +e6F8SZ67cBzcdflMNoCKWOEiNk9H6YyKh7BLaI4atLvVa6ba1c8lmIHCLNeBliAaVYH EkUAkgWKRIkAipG96E0R6L4rNWGMoWfflGesPpglZiHN0b38NxGREJ9vsdfkH3b4GZ6D kW8A== 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=zcKptO/GWsPHOo8IIwotBNk7nsu8qIQelp+OxcAwJeM=; b=Dg+Z3ZxG5++Uh7awh3ERRFkgMCSJvomvP/E8xJx1yMP/7jBUoMCvjAtaIQc2Q0k0ns zOh5fVJpceLmXBzW02hjEl/2rY57YD/HTOrAVxk5x3nnP4wrwQbIWhw9Yruky2e/8xOX R5Z4hM+jcAv3TQ9yIxhcuBirbGhc0v1kaLYWxAXyetbnz5L43b96IshWW9Z3Rgj4RvDp UKyTy2l3ersJAAry2wtx+ACuMmoi+Oa1D4O0p/BBGJUn0mJ1AXY9KL+sCPSxGaaaeZ1N jxEUsLyKLLjtbfZY4QBq4zVS9USwlXOOulsqdmS9C0057XkW6icEv9P1bg9txzwizVc6 2hxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=HInTl4eJ; spf=pass (google.com: domain of linux-kernel+bounces-22880-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22880-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e3-20020a636903000000b005ce52db08fbsi4664570pgc.695.2024.01.10.15.17.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 15:17:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22880-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=HInTl4eJ; spf=pass (google.com: domain of linux-kernel+bounces-22880-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22880-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9FB80B2705D for ; Wed, 10 Jan 2024 23:16:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D09DC52F7F; Wed, 10 Jan 2024 23:14:47 +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="HInTl4eJ" Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) (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 A66BA51034 for ; Wed, 10 Jan 2024 23:14:45 +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-io1-f42.google.com with SMTP id ca18e2360f4ac-7bed9c7d33fso83435139f.1 for ; Wed, 10 Jan 2024 15:14:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1704928484; x=1705533284; 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=HInTl4eJDD4Kw1xM3+3KIHchkh+cAZ0BqlJnYlYWf6F1XFFWdBmJHG/KNzaqU3ydJS Z9gse39jt1hKw5Gn3sWxg7PVIwMyZreoKKmRMYJjtyo/TBwxPTOD3aQdIXTTtcdqiFNE 4byZC3Y28CDOZF6q1XHbNbzz0BYPlPAeDB7/REKagzfUfvvHwt4AL9F3sH+ZdlNRHiWH 21/m8foolfeAB2WlTSeThoPebrlbhuDnb+mJS8t7HaxRcuLuaMYQEziw+BuLd4OCEKwu sYy/r7KkbKIoxWCCl3aFY06RZrFxhluLNo0EIX4FgHaGHYzepx6jR51BpVa1vJIPkZLN qtFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704928484; x=1705533284; 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=CvbZyrLhqu5KMseweaRdwjtTe+AI8ojsioJx6CO+h5JAtFCmG9+vLQqrRB4fibsB3b NV8EWpPsX1YH7/4MNZ4Bxq35FGgMPL8tOs253M3OhddXDqXOb5bYWjYzKhq3QKkuqUpN JJBFqJIXcJ9SNxABmxNv8r49z1ONBsH5o8BEqXZ3fWrvHL4oYcIcxCrBtq34BRdABo+7 3B2jl0Jb4eoDz49p2CEWbUcMIY9aRGe7e889m3iJRt4LVcpL7dUIv2kF9/EXGVTVfLYA FzOznCJrFCN1eoDNqUSdOQQk/lqVrguqh6qt5yJS4BwzGC+TVlmXKYykQpSp9h3PHgRz FDJA== X-Gm-Message-State: AOJu0YxJpwyumBTYfsU7FUZhnTR1+H1/nUQtpzgbnomBTGUszDggWSho txupyGC/aZgfp+dVIewG51HeWVaBkCkMrBTBaExFXvU6Zck= X-Received: by 2002:a05:6602:730:b0:7be:eeee:816e with SMTP id g16-20020a056602073000b007beeeee816emr392642iox.4.1704928484498; Wed, 10 Jan 2024 15:14:44 -0800 (PST) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id co13-20020a0566383e0d00b0046e3b925818sm1185503jab.37.2024.01.10.15.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 15:14:44 -0800 (PST) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Anup Patel , Palmer Dabbelt , Alexandre Ghiti , Andrew Jones , Atish Patra , Conor Dooley , Guo Ren , Icenowy Zheng , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paul Walmsley , Will Deacon , Vladimir Isaev Subject: [v3 04/10] RISC-V: Add SBI PMU snapshot definitions Date: Wed, 10 Jan 2024 15:13:53 -0800 Message-Id: <20240110231359.1239367-5-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110231359.1239367-1-atishp@rivosinc.com> References: <20240110231359.1239367-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