Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2554021lqz; Wed, 3 Apr 2024 01:06:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXCRMBEBfzrag9Bdv/V7q8snxSLCtreYtCj3wfS2JDpB18Lfqx1xB2ev1YnywLqdaB+CapiYuOfRXbxB5w7U7igB2hPP9rvOZxayMZY7g== X-Google-Smtp-Source: AGHT+IG8pM793nS0+7WSk+ed1NhYSsidAzAABfPfFACb5b0ZUEdHj/okt0ROm+XDHFOT/PB94MVF X-Received: by 2002:a05:620a:56c2:b0:78b:ba7f:be10 with SMTP id wh2-20020a05620a56c200b0078bba7fbe10mr3070776qkn.1.1712131619463; Wed, 03 Apr 2024 01:06:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712131619; cv=pass; d=google.com; s=arc-20160816; b=CXxsv4BpvEmxdXosZOWh7yNtsmEIO/9Qium+oewWEYpFs/p+lm2XuFQZZ3Q4ujasjx xWn5hzET9zXRRv/34I3jzos0Ob6rmV+wkDXtNtWSqtgT897DUzk25V4PoxRtspO/9GlN ypYvbERTg54MZoLHQ7eUvg0Q1L/+3GMBNVbLU8O1jVNeGkYTQym/Pky+RudbGDlibLCA rfSZMewL+8GQlEaggkC6jk5LmtOetmUh7LrLYE+tYqAmrHGWLj/t5iWTUUCFtOLh9w+4 a6loHsTIw9d8+Y6YKa3XloGmBRLAGwxKYSqnfEuBXiAdoasWus1q6wz5LvbCi94TYFOh UoTQ== ARC-Message-Signature: i=2; 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=2cY+c1Et8e4Cu0t4snI2MWrn2141KaT0UNrXkfFbuJA=; fh=MX02QoLb53zdtSN8wO4Pd0J1CTR7s8+XrCnbocNWAyc=; b=homZN+6hdGbZBqqkmKCZOkV8B7yBrr+lEDsccvqh7oIVxcbpgAIfwSInPq+b8unBTz KZb8S3FsNGjgX7EdWK66qY6hCyKUt+CrYhLLQM/SYfYQqQRdRXz/OD7Gsriat5QHm4mF FJUxsJHQ6a0d85D7opKNImLr/dXICpRZWRZFOQX4EGtHxjq1W2aaub10Eptipm1TS5X1 4B8IzMRWT0aWYxBh5PvBbk3IumIx3fWL3wjZm2CyP7FqDl9wZkj3lqtDoTaT0ucZrrVr bT+kQsTLPURzgHgHIjm+L0PiAuABqrA1OIUHBo9YRWxYQvQE9a5dO3x2avFp6jahebjr YF1w==; 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=APZqJJ8W; 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-129245-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129245-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 x27-20020a05620a14bb00b0078bc4455adfsi12501388qkj.782.2024.04.03.01.06.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 01:06:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-129245-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=APZqJJ8W; 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-129245-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129245-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 0ACDF1C2549C for ; Wed, 3 Apr 2024 08:06:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17FD074424; Wed, 3 Apr 2024 08:05:28 +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="APZqJJ8W" Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 A75346CDC2 for ; Wed, 3 Apr 2024 08:05:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712131527; cv=none; b=JDLz3/Ao9HHggAFnH77OarjQDy3SVrGdodkKMb4BMiTT6Jg2iof1fu9aIPzYfh3iMhA6dhrcz8uvCHTpkdB1Z++BxDsHmgTz4Sj/DqnvVFrEM32necry6Uax5z/dI5uyA+ptqWn4k++InCsLZc+yToAPWAwPVzUfaASjTcHcd1U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712131527; c=relaxed/simple; bh=hD4T8CbQGFqb30M4m5Qq8QzxJC1eOzrHV+Z0kwBj2NI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XnAE1lyi00QJb1Ja548cedWHrdk1UrKiemIy9jHa1HywrrYlhx4uJ0O6R53lWo5WUx8zwm7Sxfwdj7vccoLIEOlzxO2LA1CBvg2oavVDBlc2E6xG+RRZfwdypR0+J2F0wQLgrrJDsnsX9OOlb2486FUrzYuAu91UuNGZvE9+vDU= 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=APZqJJ8W; arc=none smtp.client-ip=209.85.214.180 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-f180.google.com with SMTP id d9443c01a7336-1e2987e9d67so1069885ad.1 for ; Wed, 03 Apr 2024 01:05:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712131524; x=1712736324; 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=2cY+c1Et8e4Cu0t4snI2MWrn2141KaT0UNrXkfFbuJA=; b=APZqJJ8WSPdO9PXMkbYaajjlgHZk/+LXQVLPNEm7KKgpstdaAxBsJKFvSjRkKyalxj GhI6XbI1lR2S/RAoiqbaITQOrNGnqQuC5ctwCaPrBX9x+3tE535d2qZkghN1qNAUhopi +o07EKoPDnvJeorLpjmDCLJ6H2vdcMe1uF484REY+UtuPnxiHkMkQjKjErWMbfL1KzU3 +24QXhFSpTdSJwSZUm8jd8nkQbrhDXOJ6UibLUnsTI60blqSeH8prptkviOh10sYvhFa lYiJNgfBMUV5QZqMSUf1TZsT/sSwa1+GWWo9JaVcg1qJO62fOd4bnlfpVvuxPfcP7Ckh INUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712131524; x=1712736324; 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=2cY+c1Et8e4Cu0t4snI2MWrn2141KaT0UNrXkfFbuJA=; b=nN1fjAO0K2G6ZVKssv3IdwQZ19uT1gFFAVQOQQD7D2L+T17oVdfOqQE5fKCL9YfDsx oaC+IpyXqc9RFRI6zbfMGWpsKHveXOH8pwXvLjjnyAHmFgOiFT14mzsX1jCYwan6QgvI oa0BT6QAceUEhfb2LNCclNrdUjWPAd050CHyNDsBvsJZN9IhCHxGUCjIBlLAdgC1TFnb MdetnjVOnABOSAXWLxDe8m7ZIkUqAwhzeFZgZBRbgBR8ztKgqDkHP26ERyke1eGZRh/e LR5WntyoBmEUjloUJKn8OvOGiiO4iQQq+tdIuOhb8s329z8e5Aayj2bWyfXge6OIpVzV rfAg== X-Gm-Message-State: AOJu0YyoPNQkxtjD/UpAdd4JBsx/7jqX/RvR4EdeRI1rupOQX59v4woO K4nuKQ6XJM+OUHZ9VfZHgK6yZZPzuev4odPNOzrX7fQbhrkZOMnP64Z4Nr5p8zbjkllksHrkSNS K X-Received: by 2002:a17:902:c412:b0:1de:fdf2:b483 with SMTP id k18-20020a170902c41200b001defdf2b483mr2836035plk.8.1712131524245; Wed, 03 Apr 2024 01:05:24 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id c12-20020a170902d48c00b001e0b5d49fc7sm12557229plg.161.2024.04.03.01.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 01:05:22 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Anup Patel , Palmer Dabbelt , Ajay Kaher , Alexandre Ghiti , Alexey Makhalov , Andrew Jones , Conor Dooley , Juergen Gross , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paolo Bonzini , Paul Walmsley , Shuah Khan , virtualization@lists.linux.dev, VMware PV-Drivers Reviewers , Will Deacon , x86@kernel.org Subject: [PATCH v5 05/22] RISC-V: Add SBI PMU snapshot definitions Date: Wed, 3 Apr 2024 01:04:34 -0700 Message-Id: <20240403080452.1007601-6-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240403080452.1007601-1-atishp@rivosinc.com> References: <20240403080452.1007601-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 4afa2cd01bae..9aada4b9f7b5 100644 --- a/arch/riscv/include/asm/sbi.h +++ b/arch/riscv/include/asm/sbi.h @@ -132,6 +132,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 { @@ -148,6 +149,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 @@ -244,9 +252,11 @@ enum sbi_pmu_ctr_type { /* Flags defined for counter start function */ #define SBI_PMU_START_FLAG_SET_INIT_VALUE BIT(0) +#define SBI_PMU_START_FLAG_INIT_SNAPSHOT BIT(1) /* Flags defined for counter stop function */ #define SBI_PMU_STOP_FLAG_RESET BIT(0) +#define SBI_PMU_STOP_FLAG_TAKE_SNAPSHOT BIT(1) enum sbi_ext_dbcn_fid { SBI_EXT_DBCN_CONSOLE_WRITE = 0, @@ -285,6 +295,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