Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp165487lqb; Tue, 16 Apr 2024 11:46:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVPUQYZRyL1bHhsnLaypc4U3/hSRYgldeCf6hmMReBPCp7HM4q8ewW/EBkmKMcXvIxE0NKtIBPWTNMrlM5FeSWSjLsjbPXSoZqTlC2RdA== X-Google-Smtp-Source: AGHT+IE22a+SU3CDjF+rJoLk/8zQD1AG0wREtFVYopOCnKRq+WkVGajt+duxMvGn4p9/bJKc3NWV X-Received: by 2002:a17:906:b110:b0:a51:de95:f592 with SMTP id u16-20020a170906b11000b00a51de95f592mr10421196ejy.63.1713293218082; Tue, 16 Apr 2024 11:46:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713293218; cv=pass; d=google.com; s=arc-20160816; b=cCHSj41rCDPYIkDLyLSvYRGSs+pYK2BVOBV1XAi0IQJpIOsqQxMEcGlF3sXSG+kDTG n5vdXDU+Ls89kNIoFwDxXlvhVxpPCm+7HxLXpm7Ck0krK+oyKlH9Ba1ol+kLyiSkriy6 ZkhcJGWfJFlfWMbHwLMOja/DI1VYFzUj3cAHo/Rlk4XSV2PavnApbNku0DRRtI8QlQ7p vtDS6HzR6vLl8kUBM4iSf9GIoowZ5SrHSDfl/zfMi+BpJqy0IBIPtPTgWvKAZwSmjQ2J oFJcfsuM+5ck9MvCboY6es6yIPR6RuC3ynA6roVm9elFJ5YbLaDRFFXHjPL2sy/YMDLb w2yQ== 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=Y0lXa0RA4+kQWkomLRJk1QW7kf666EFgaJ2j58l79bA=; fh=e7y8CGpi+mJcYLH4QVmVL+67H9eO8anB6dWoVL8M7hM=; b=0KZjMLmF0aeBgRxBMSJgDf4d3ButoblxN8Ho0hvzfTR0U9ICJztQ/JOe+2g6yG+hxx 3drBngPAl8K8S8mlVxjNlv/jvgxXJFyb4wG+AiNxnlzPaU7Mm+xPA34GwnpaD9kcz6FW JMzKYvJUw6Lif7i1Jir6nOmVDUn9pRb3IYN5i29KuyqIc/O9Kn9zFGkwDBHY++EOL6ws pEzLcZlhhNEtn1k9IkyWFRG1DK27cB4+Itx3gWcEQWVVFijmDQbQ15vZgpoPulPNmgtE 7D+U2VY+NX39kk0cMROTXswxMYU+2MIRLmqXtlm7MGZKTvQleqClw65yHwujaMmaP4cn qaMg==; 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=1Ll2VWzI; 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-147404-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147404-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 d18-20020a170906175200b00a46c39976ffsi5784686eje.500.2024.04.16.11.46.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 11:46:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147404-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=1Ll2VWzI; 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-147404-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147404-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 8D8BE1F220FF for ; Tue, 16 Apr 2024 18:46:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18DAB13A3EF; Tue, 16 Apr 2024 18:44: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="1Ll2VWzI" Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (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 EE7E6139CE6 for ; Tue, 16 Apr 2024 18:44:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713293091; cv=none; b=d8oi3sp4gudnWTop5VjhCzUH6Blv0W0Bvl2NAb/0uc8ZBG+1v7/N6iwyIvH+TOIPvoY9sZwUea0kO4WiO2xutb8qqc+KsVnCOWEpSniTJC8rb4Hl76chjanlNXXr62b2Rpp+gLMDtHqUpIgHDVkYIw1QmZHnuYoj/krDhblvgf8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713293091; c=relaxed/simple; bh=Gs/9X2hzactn0W0hn5UFwracoeJp45KmCczLf6NHuME=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OG+ZLmMIKl01ZCQXnyqTNbE177zyJI6xRGyNAUMrJh6O7StcV9aXcRcdb8sqCJaARo8y5EuE2YT+ub303RFrEL50kL/OuLB5u9vo6MI+OsiqRONL0u3BFrDWWaEOQmaRefLnzxeHO6axm7JYa0l69C2GCmwuRStHMs8q/8INYHs= 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=1Ll2VWzI; arc=none smtp.client-ip=209.85.210.179 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-pf1-f179.google.com with SMTP id d2e1a72fcca58-6ed2170d89fso32395b3a.1 for ; Tue, 16 Apr 2024 11:44:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1713293088; x=1713897888; 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=Y0lXa0RA4+kQWkomLRJk1QW7kf666EFgaJ2j58l79bA=; b=1Ll2VWzI8W1YGIG7FRLM/yINoz+qdRHCJvrBveY2tk+XPBhORoKAra57rHdvwo0sXx adokXKRUBWSm+ochnEqNK+gjuVnWAo/0pKLfnzrtKQWG9CrsdOJeUqaY/DSXLPFF5W84 r6gTDxi9CDAPCFg5c/DPFdV177A1Cp8E0X+f+mBgZCLph6z6D2kJ0prxOwY+Ty5W1fCA d6wIoJ5fW/QZjdHVPcSKMuvMNhEfIlapKGvdpFmLBGh2/VgZH9nFgvQJgSnbP27oqcjv rCnBTXWTYHBSPJLYQcLpgupcbzSC/ErVJbkKZZnXhcsrhfGkzrkHoUVHVfIRXYf7ivtR YkvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713293088; x=1713897888; 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=Y0lXa0RA4+kQWkomLRJk1QW7kf666EFgaJ2j58l79bA=; b=ScZJnu9amduzr4OGOOZuwcl9kTCFUueuRZAgywENxe0th7rmiPuQz0Rkxt2Rju7iNJ gbJzWJBfhF8jU3Ci4mjCyFusxXmM5tproBKLA5ZpdAdMN924KNwkn6NwnGdTOzdxTBXX MhyU+WKoY6Lu3tkSmnaaxmFV6OEnotUGX0EG9GgNzPWZW0zrkUZZhg646VClM9ndxWVp GwP1oX4QNW2QT1WkKEIFSF1kO/SL3j0+2Sw4vqmlZjdLsU1ByRLxCsbnSL16mJVXh5Qv kjk/6CTm0G0uH3GkOIzVE7Vu5G98JXYEDTgH8v+cszeH1mZX7IZSOUWlGIGilt3OB8+h /VGQ== X-Gm-Message-State: AOJu0YzXQt/Tu0XknAiPg9eWCBsbCUNciFt5oaoKvGE4bcnpYTW8uDnx STmF2JI0+1W2YJeRyGim2BHJAtAcnmDJBBmuW+X5BGExFxGzFA4vo3iRIzHD3pyuzVT9h+HweZq l X-Received: by 2002:a17:90b:4c8e:b0:2aa:b56b:5bdb with SMTP id my14-20020a17090b4c8e00b002aab56b5bdbmr3174156pjb.9.1713293088546; Tue, 16 Apr 2024 11:44:48 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id o19-20020a17090aac1300b002a269828bb8sm8883645pjq.40.2024.04.16.11.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 11:44:48 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Andrew Jones , Anup Patel , Palmer Dabbelt , Ajay Kaher , Albert Ou , Alexandre Ghiti , 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, Will Deacon , x86@kernel.org Subject: [PATCH v7 05/24] RISC-V: Add SBI PMU snapshot definitions Date: Tue, 16 Apr 2024 11:44:02 -0700 Message-Id: <20240416184421.3693802-6-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240416184421.3693802-1-atishp@rivosinc.com> References: <20240416184421.3693802-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: Andrew Jones 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