Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp186453rbe; Wed, 28 Feb 2024 17:06:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW+kAjKID8VVEh72qpb+oKRsAb+KrPlBwJHMueYIph+Sqdmm/J7cdNTTsjCIXpesOtXxJD97wuho9SxSvak2FPgknHm9xJ7RDG8jm+9tg== X-Google-Smtp-Source: AGHT+IGg6Z96xUO7O362kxIRFwad1l3KFWmOxVu9Wvf6ffjRKFjtf4OxFCmAZKvXkws2jj7uRUO1 X-Received: by 2002:a05:6402:901:b0:566:59f5:26db with SMTP id g1-20020a056402090100b0056659f526dbmr288780edz.11.1709168777566; Wed, 28 Feb 2024 17:06:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709168777; cv=pass; d=google.com; s=arc-20160816; b=bYBkuV5Wawn/VkcgjZQl4nFL39Qi40Cqm0lVIkYB70fgKSlQA3vbadJxPmeoIRidU4 NqCjFhHw2UTCyHWYdlq/oDgbBg5oehoRRosdnfuNxI0xRkADQIiFN4rrRQNmTI2L7MJO Tsbs8ic2MtPNrnaCH9adBMCvJGSkU2pVyQ8cNHDIXvaWmwftp2tmzILHeYviJFWmDcKM OO8ZxZtnl2FkuYrEMVqhuB4BKhTzmxoMxBmHis4ZCVfzw2XFkvTr5B+oBjx5mPh8k9T7 mUx1NzWc8iTMlnlXh9mfKHInkPR9bjgeMQZzHZ9S7+GghVWVGDzSNf/q2ditbbmuK9X8 xnaA== 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=bg0Ox/oYKnbNuFBhdI6ydLs8+8yl3bqZRH2qF1RxaPE=; fh=BfSDJNFqndmBIVl7P8qvZkYoX1vx39f2jrPzYWYNph8=; b=zzrpSIwI2ElOVWun0JHDjdPsE70T4tbIsilwVfidpofOOlbnUrWGoU5rARJMGEh2Pe WZmzL7I7SnnRG/pdOebLKm1DS9e4YREa1rMwC2ugoc+imd334kYLb7jeTppILSMk3IAM UDbGTMF71FxBtuI5JNsUQUHKGyQbsuH+d1EW3Yyh4CPl47Q9zWNvKruSmLP5bAzV9RpI yxFmQkfw9D5s8Asd0Wo7ysWRbJWExu9g1tMDh6b77hyaKbY/rRrXQWOwArl0/mEytlV3 rXt0FFP/p/46lRxXE36MwGZdmD4KXPX5GOiGVRVhyiRJndvKw9EjIU9/34Zdl2Z9LXLO PCFA==; 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=hVDsczk3; 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-85971-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85971-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e8-20020a056402088800b00562167084e0si80736edy.260.2024.02.28.17.06.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 17:06:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85971-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=hVDsczk3; 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-85971-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85971-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3CC651F237E5 for ; Thu, 29 Feb 2024 01:06:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B8277481BF; Thu, 29 Feb 2024 01:01:52 +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="hVDsczk3" Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 524A745037 for ; Thu, 29 Feb 2024 01:01:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709168511; cv=none; b=Vh+lYCXJ2uNtrwWpu355sU1UhtfwEqzwEO8kRjrlGHJ1Db+VR7NSsTQmtX1HAa5HgHkeyBfGRKo5E0Jpej5QYNRDEcHuNN/ASUuOmD8Jbd3RQ5iloaKrAEmSnXPIHa51D5EOcQXwSy5aki2hRAHuy0csws4Kmj/ZkXqkHx8RE2o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709168511; c=relaxed/simple; bh=JxDVdSm0uYBTaiw3to0ly84+7T5bBOKxKOHBRjRjqXE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G39D0SnAMyTb77PF4SkKFeeG6h9I5ey2bWmeYYrU8NEU52AXbUgprhvj+jWOwXxEhQB6YgqShagAyltl9nC4Hkja6OefIiHEbqpB+WviEaeka+A0VSXKJ2PjC3j0vHfmv4vPjfTAM3VErpwkiMF6osamEj0nVVjHmSMJXRZjxTI= 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=hVDsczk3; arc=none smtp.client-ip=209.85.214.175 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-f175.google.com with SMTP id d9443c01a7336-1d95d67ff45so3821155ad.2 for ; Wed, 28 Feb 2024 17:01:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1709168509; x=1709773309; 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=bg0Ox/oYKnbNuFBhdI6ydLs8+8yl3bqZRH2qF1RxaPE=; b=hVDsczk3nG0JVdnTWsZNyvgv5smdsCDLINu/FsyfeqeJiufmRUXfG/Yxfu7zsFvJww 6AFF9eYWrgimABrt2Bg6OmS7G+f7D/F3PyDJqbgnKiMoqgvUIPgOaSq5QtlOZrwrQuYn JEhMW8gPAMulwlcFaGrrtX1eiW9cvggARIleVRsHza0+mxcQLjXUZtXGlGLDy3kH4maU 3u+0VlSHVMWg6nwXLk1lND6o33ALSIbx2cx9W5i1FskPId0/YQ3I75d8RrBalulPKPUG G9HmAQ3kKLBPeBIp7cuMUsHdVn60Hzbi2dA5ySw7+mYPuan79PSVw/vhf3ESgprWa5fW 3Kcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709168509; x=1709773309; 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=bg0Ox/oYKnbNuFBhdI6ydLs8+8yl3bqZRH2qF1RxaPE=; b=QHMmo9/ZT5DhqFGx3bWlTHqOOBOQ9D8OM/B+siZG250TLAy0/tsqxfJYdi38LPhBRl H0Sm2bfSd7wRCdpBjYkH+zIy8IoCYWkWChCDSmC17uwPwZCFjQZV0ac94bHYsyYTftAP 8JwPsEzn0mk0Rj6Mb/Ud2MnQpwHHop4vsjdKgE9ylC60OpUMuQMutLneHuwOSG2ugzME qhACpByZ3tbCkdZF0gwiEh4+ae6z31PAOzq74Ihh6YDD8J10uQHgbSSDOPGNSzxRK8tf Hl6n7LJNhRu9A2k1rhSDTMNw+8ogWrlsMEuLH+PrNWqfElCRA5xJ3jtddqAa3/jArA/L BXDQ== X-Gm-Message-State: AOJu0YyCKZaXIZ/6olEyyfIcv/N7ZBnBuM/v/1ni8AcKUqf4DcFLNN1F Ff53+O7T3Rr9y+0u5iJYsP56zzLUDXpAYmOO44zYZhOBUCruU1yj51NNQys74ihGeOFXgfM45F3 J X-Received: by 2002:a17:902:ec8f:b0:1dc:696d:ec64 with SMTP id x15-20020a170902ec8f00b001dc696dec64mr829830plg.22.1709168508693; Wed, 28 Feb 2024 17:01:48 -0800 (PST) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id j14-20020a170902da8e00b001dc8d6a9d40sm78043plx.144.2024.02.28.17.01.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 17:01:48 -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 , Icenowy Zheng , 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 , Will Deacon Subject: [PATCH v4 04/15] RISC-V: Add SBI PMU snapshot definitions Date: Wed, 28 Feb 2024 17:01:19 -0800 Message-Id: <20240229010130.1380926-5-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229010130.1380926-1-atishp@rivosinc.com> References: <20240229010130.1380926-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 ef8311dafb91..dfa830f7d54b 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 (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, @@ -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