Received: by 2002:a05:7412:a9a3:b0:f9:327e:43ab with SMTP id o35csp9474rdh; Mon, 18 Dec 2023 02:43:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEiwoN0qfHrNpDaqSxvEDQEnfmYLGZtAGAweFlgSuecLAKw0JE/d+p6KKHqGdyK/oHD1t5C X-Received: by 2002:a05:6358:4403:b0:172:c42f:37a7 with SMTP id z3-20020a056358440300b00172c42f37a7mr1086983rwc.24.1702896187094; Mon, 18 Dec 2023 02:43:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702896187; cv=none; d=google.com; s=arc-20160816; b=RlehctAHmhBh72AjigtME3joV4pXlGjuWZoo2A1mEKRrfuIBvRYvuTPGf5uTuSKk+m eyLDP7L5C3hyRfR+jBsSLly1uond8M5Lig5fOw4Bm5aCYckTxXwGqDQVusmDpltoolPc qtXZvBfcKypTXh3qTxd1WbicmAKOx37Z2d0Wo32ylK/pjU4BAm/1CPfdiMqL8kZfsxFj spwAkk0AjZgKiMGBOiaVQ1jhdKBNQv2GUUR9N1jnPO0fLFtRTe5sMqhvb46KBhF8BoKP pklh1sUokbv8krL9prDm24dCmLMmcfC0NhhWAV5rewi1Uqut7AGBl6pNllJQDeApYxdH OJCQ== 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=EuZhnPGQBcArCwk7TKa9E5XMHvxU9EnFz3QAUH89JKI=; fh=9NrP4/GMzL5FGtkic9n6G76BXHA7yqDoLFG01y05tIo=; b=Fhl6+oRq+f1e0GqVdqY+SBHSYtxe0l5F0IVodGfmfTYmv7OPyQkk3gp3BO0l9jdP5m HkBHhPKG3VTDCfTF8cKiI5kNW5uGaRqqOXybViCuWd4DQrlF0Ac77tOt9k+UcDCSaKmv qowyfsTkrl0M1atlbToBOgNBRci8RiuFTXvClE2CrrOazPxPaXBmjWhhTgdhpqfwMh02 M2ws1drUGGGQRY9CFe8HvGohdY5YxW/PGKqpgtmhVBULvSl9IyeWO3H2aJFb76NH6VVI 0jClqh8uvUU1XagGthg+0ZCKuBQjH7XvqmiOt3E6JVTVZQij3g/uBh8hiZCQMelLDkCD U5rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=mlU7iF0H; spf=pass (google.com: domain of linux-kernel+bounces-3352-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3352-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 kq8-20020a056a004b0800b0069026fd5a48si17320862pfb.34.2023.12.18.02.43.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 02:43:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3352-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=mlU7iF0H; spf=pass (google.com: domain of linux-kernel+bounces-3352-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3352-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 B64FA283606 for ; Mon, 18 Dec 2023 10:43:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E9401B293; Mon, 18 Dec 2023 10:41:27 +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="mlU7iF0H" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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 457B61A59B for ; Mon, 18 Dec 2023 10:41:25 +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-ot1-f50.google.com with SMTP id 46e09a7af769-6da5250357fso2263517a34.2 for ; Mon, 18 Dec 2023 02:41:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1702896083; x=1703500883; 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=EuZhnPGQBcArCwk7TKa9E5XMHvxU9EnFz3QAUH89JKI=; b=mlU7iF0H+X8kH0u88e2s3ebD5URpNJRoXk+OoiXTiNhyu4GKJSEDjiaZvIkCQqPv83 VCQrKNC2HdGIvXpbrsYH2D3zZAtZCkvmUukIlIdqZNwja6OgD0iXYvEUza2HIFGfaPby J6wYIK583Kj+gnEuLm78ayjX9ruD2BUawPygT9om4mG87MUf9Vx9GLzUHF/vf152XkSS BsCdKR0jyfUxSwqq07ofGjNTEPnfLmeFAG+UT0IDsBolWv74c2DgMPGI35h6mkcoSdBy Ew54S7LkKRzlGzNvISTiD7AgbzR3nwhlencFGZHl6JtHfXE3tlAnp9OcwOm8cgCpE3sp ZcJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702896083; x=1703500883; 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=EuZhnPGQBcArCwk7TKa9E5XMHvxU9EnFz3QAUH89JKI=; b=JUeOpUfRHwWF46dnykBV7SCjfjwyEWAzHO8NYqULY2unm3MNoG/fjz2R+G1Ei6fjWu YjvI9rKNZVgFcHfmIxAOX91oM3/NLDIDwuoyPxORAC5eI2W6wi9Gzi7rDw0AritjHgv4 Y3Z/yuuTO19gV90siw2wOyFWQWQLwYD7WCk3t4esSpRULwZQyO0Y18jOhmQ6CsjK9WFU sFX6JbdxKHEAEryZVyWsS1Nbr+qrrdxQ+O79/4OrzzS/R5wWF7jlmDE2pEcltVYWHF3x X+MUvpb3IBxLlr3hYdevnItnS18ZlnyHm1G5d5ZvtO4s9tl97p/UEI/wf/7YxQRPyh23 QZLQ== X-Gm-Message-State: AOJu0YyQ26GHI4XfzcG3z96f0JyezRzKuMAwX9uTDtKl6a3AzvrAWDaH jD0BDbYiYo8xMpcWWfhSvavbHhJyIlcefj8jobA= X-Received: by 2002:a9d:744b:0:b0:6d9:d132:ef24 with SMTP id p11-20020a9d744b000000b006d9d132ef24mr16649366otk.25.1702896083511; Mon, 18 Dec 2023 02:41:23 -0800 (PST) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 185-20020a4a1ac2000000b005907ad9f302sm574970oof.37.2023.12.18.02.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 02:41:23 -0800 (PST) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Anup Patel , Albert Ou , 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 Subject: [v1 04/10] RISC-V: Add SBI PMU snapshot definitions Date: Mon, 18 Dec 2023 02:41:01 -0800 Message-Id: <20231218104107.2976925-5-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231218104107.2976925-1-atishp@rivosinc.com> References: <20231218104107.2976925-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 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 f3eeca79a02d..a24bc4fa34ff 100644 --- a/arch/riscv/include/asm/sbi.h +++ b/arch/riscv/include/asm/sbi.h @@ -122,6 +122,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 { @@ -138,6 +139,13 @@ union sbi_pmu_ctr_info { }; }; +/* Data structure to contain the pmu snapshot data */ +struct riscv_pmu_snapshot_data { + uint64_t ctr_overflow_mask; + uint64_t ctr_values[64]; + uint64_t reserved[447]; +}; + #define RISCV_PMU_RAW_EVENT_MASK GENMASK_ULL(47, 0) #define RISCV_PMU_RAW_EVENT_IDX 0x20000 @@ -234,9 +242,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, @@ -259,6 +269,7 @@ enum sbi_ext_dbcn_fid { #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