Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp657484lqp; Fri, 5 Apr 2024 05:20:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVSvZX4DjPjt6eR2jAGMmMfylEccMlCoRmUj+qH2Wt89PfqJNra6s4ynMVHqvs9mkFDaql+hv8T/yL7gnAsuJSeGOlX8Hdexcij1UTsbg== X-Google-Smtp-Source: AGHT+IH1iZhOEb2ItT1HTZNpr+VPPGsk/v6QfNoOh6cuhR5hXnvunyvzsXlaXz+Gx0gdJ/OMh/aZ X-Received: by 2002:a05:6102:5492:b0:479:dcf5:6780 with SMTP id bk18-20020a056102549200b00479dcf56780mr1363191vsb.18.1712319622134; Fri, 05 Apr 2024 05:20:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712319622; cv=pass; d=google.com; s=arc-20160816; b=C5ml4kgYbOhm5PAnYzKT0qN/X9f92fLb/7yVSuRC2gCnHQzZ8Om2GsAeeIVMVwaUDf Gz7q1DTzS5kMBI4Q9ng/gufWV/GBR8refj9jvxmHtjHxh0DoslI4kI/SoKK/1Ne2qlx/ UiB8lSty9lmXJMLkwHsjoPpX/bwwCJ4arc1zV47EResPXGSOyPv5emGGfTjxxAB/ZD/4 MUqN++cvYEh8Jagsv0aaaaK+l8rQ28pwNPWQSM4kiEqbY+3btHvPNcdysraKcxW7Wb/y quR1DWuaCCjoO8bh4Tei6IuvATWxMRSrFKukyhX36nUvY9Ft1ZxmW63AxPGMU+4qAkVu fmig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=z3Ue/COd7xzip1h5OQAnlWq7u3bU48JD2sac4Wso5xg=; fh=gaKXNLThCBu7XqEF+OIYsPuGXO9AUGCWBxjHRzZNzhM=; b=QBcDl/Val3Qv7czR3K1DQLNq7iYUZeao1hKyWSxLl5lNAqb36qBkPlyFjrvu+wKbrt Ny+iHg434t/1IsjVM6zUtg76WshqYAFjfCfA6Ryw54bMBbS9t7CNTWSwFsnuB5y9LeiU d2uyOCurZO3xeyj/K3zxCHd85WehYgvHoMVoKSSsv04EF658kP7+/JAEokWgqKCQJN3r 2BeWNeSqBZSBG4km25xZWMHGEwtgUNZmIdF+btQpyuWGNJxNgmkEQ0fEei7zz18+L4Oo ufjPFQ0vk23UyUrkNSAhHiNdsBp+sC3f5v/w6QvJSB4sStzou/obLs+een3JxDNdTL2z udpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="Qp/HdHac"; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-132979-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132979-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 f9-20020a67ee09000000b0047842fa9c40si161134vsp.712.2024.04.05.05.20.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:20:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132979-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=@ventanamicro.com header.s=google header.b="Qp/HdHac"; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-132979-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132979-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 C47001C235BC for ; Fri, 5 Apr 2024 12:20:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B35716C87C; Fri, 5 Apr 2024 12:20:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="Qp/HdHac" Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 B243E16ABDE for ; Fri, 5 Apr 2024 12:20:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712319613; cv=none; b=caslzPL08YIMXLOvcEIEUoeGhKR2EojA42DxfLzn6hT6jTdL0yXMe0iBUcNbu8TsjlHywzdactskbJXTkkLZb6/n44yQwGR+WygSU0/ZnQKq8xrvUffAiOD8vm2cZLXgWhNWSMJQo4XZWgxUAtKd0lgWJ7s1SDfqgjU7waoWExQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712319613; c=relaxed/simple; bh=QvT4ozHWD3CjUArG6dq9y/ZxSh4Rx9h9I/c69ZvPWTs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Sa8QlY3L/mss86FL2ssrOR1c7gvlSmy+XB8p2kTzy7mjh7G0VmwaWCaXApwgHu/LEX93iB0MNslcOdZdZix8Cnlt7wGxw7PJCBgtgsqxYhcQSsG94PA04FHKbzgE76lR1x6Qql6x0vRU2rR4ZFlXb5OQ36etW/dV7+fMjmmbBWI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=Qp/HdHac; arc=none smtp.client-ip=209.85.208.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-56829f41f81so2960926a12.2 for ; Fri, 05 Apr 2024 05:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1712319610; x=1712924410; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=z3Ue/COd7xzip1h5OQAnlWq7u3bU48JD2sac4Wso5xg=; b=Qp/HdHacBiC9NzqV3JO6hxgWf2/7u2V84UrEZpfPnvI+UBdzIeuZx1uyUDDDJ9qQLn 3f0b7q9FdnJxYGfPl9pyaVNEuKaQpSojikNiOYpkcCjAeC+v59IENaTxJXwNsX01ypOI MB4pUtVNDGW+l1CCfJj/nlrL0B/FmehMKLiH2Gv3KgEymiNOwZDq477Qwm1aQSHRKle1 kFqQexsUqzQD4qtl9JFqJXje6NXvQrfc3HKUT+kGc46WECyJt/CtTZQsWiz9ZFXQq/Lu sAkxsZIOZ9n9TEvZZ9Sf0vtaFSvSf/6kRi6FMl88+yDzGdAWWbF9CiHmpE3/eL9eF4L5 uDUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712319610; x=1712924410; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=z3Ue/COd7xzip1h5OQAnlWq7u3bU48JD2sac4Wso5xg=; b=DKZN1aivEvxLRkPAf/oNkJKAPuzEisJvRCg+sMkgyQRhk6Kh363o/XxDbc0P8rUClz spqxLYYt4gYubAqPMJuZ9vCo2+EAUfgdiaOQjSox6Sn1xIFakGk1K+qZG1NIQgCXGsm4 105rmE7Lvva5BVKAnnu9RIaQfm9kk1EpX/8aHxYoDbBdrVBdqMSBF8f0sinOimDifVqS 25qyJHjRRklU6wOhv6v6Vcy4JOcQCnHq8o5SZ83h1Z1U9wcAhl6CMwuKCGi+yvzLTMhi K3J8sxxvwXEwQtGLm5uG0CR6pM5pp6FQWsJQU0KfyyjBPkTWYejR2ixhNOcuXpy5LqTV C3ng== X-Gm-Message-State: AOJu0YyaDb6pW89VZnZiHVbI90SJ5xvQEZoKhaLCXc6WTCzgmQi9T1P2 FPl9cFJa1GU+N/6JpHrLQSZ5cn0Ye/7qJ+9jE8a9BoS/eqBw/XCme7AdKL+nVSU= X-Received: by 2002:a17:906:55d4:b0:a4d:b0e9:efbc with SMTP id z20-20020a17090655d400b00a4db0e9efbcmr973887ejp.17.1712319610180; Fri, 05 Apr 2024 05:20:10 -0700 (PDT) Received: from localhost (2001-1ae9-1c2-4c00-20f-c6b4-1e57-7965.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:20f:c6b4:1e57:7965]) by smtp.gmail.com with ESMTPSA id u15-20020a170906408f00b00a4e583adcc7sm767504ejj.99.2024.04.05.05.20.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:20:09 -0700 (PDT) Date: Fri, 5 Apr 2024 14:20:08 +0200 From: Andrew Jones To: Atish Patra Cc: linux-kernel@vger.kernel.org, Anup Patel , Ajay Kaher , Alexandre Ghiti , Alexey Makhalov , 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: Re: [PATCH v5 19/22] KVM: riscv: selftests: Add SBI PMU extension definitions Message-ID: <20240405-1f8409c47501740fe808adbb@orel> References: <20240403080452.1007601-1-atishp@rivosinc.com> <20240403080452.1007601-20-atishp@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240403080452.1007601-20-atishp@rivosinc.com> On Wed, Apr 03, 2024 at 01:04:48AM -0700, Atish Patra wrote: > The SBI PMU extension definition is required for upcoming SBI PMU > selftests. > > Reviewed-by: Anup Patel > Signed-off-by: Atish Patra > --- > .../testing/selftests/kvm/include/riscv/sbi.h | 66 +++++++++++++++++++ > 1 file changed, 66 insertions(+) > > diff --git a/tools/testing/selftests/kvm/include/riscv/sbi.h b/tools/testing/selftests/kvm/include/riscv/sbi.h > index ba04f2dec7b5..6675ca673c77 100644 > --- a/tools/testing/selftests/kvm/include/riscv/sbi.h > +++ b/tools/testing/selftests/kvm/include/riscv/sbi.h > @@ -29,17 +29,83 @@ > enum sbi_ext_id { > SBI_EXT_BASE = 0x10, > SBI_EXT_STA = 0x535441, > + SBI_EXT_PMU = 0x504D55, > }; > > enum sbi_ext_base_fid { > SBI_EXT_BASE_PROBE_EXT = 3, > }; > +enum sbi_ext_pmu_fid { > + SBI_EXT_PMU_NUM_COUNTERS = 0, > + SBI_EXT_PMU_COUNTER_GET_INFO, > + SBI_EXT_PMU_COUNTER_CFG_MATCH, > + SBI_EXT_PMU_COUNTER_START, > + 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 { > + unsigned long value; > + struct { > + unsigned long csr:12; > + unsigned long width:6; > +#if __riscv_xlen == 32 > + unsigned long reserved:13; > +#else > + unsigned long reserved:45; > +#endif > + unsigned long type:1; > + }; > +}; > > struct sbiret { > long error; > long value; > }; > > +/** General pmu event codes specified in SBI PMU extension */ > +enum sbi_pmu_hw_generic_events_t { > + SBI_PMU_HW_NO_EVENT = 0, > + SBI_PMU_HW_CPU_CYCLES = 1, > + SBI_PMU_HW_INSTRUCTIONS = 2, > + SBI_PMU_HW_CACHE_REFERENCES = 3, > + SBI_PMU_HW_CACHE_MISSES = 4, > + SBI_PMU_HW_BRANCH_INSTRUCTIONS = 5, > + SBI_PMU_HW_BRANCH_MISSES = 6, > + SBI_PMU_HW_BUS_CYCLES = 7, > + SBI_PMU_HW_STALLED_CYCLES_FRONTEND = 8, > + SBI_PMU_HW_STALLED_CYCLES_BACKEND = 9, > + SBI_PMU_HW_REF_CPU_CYCLES = 10, > + > + SBI_PMU_HW_GENERAL_MAX, > +}; > + > +/* SBI PMU counter types */ > +enum sbi_pmu_ctr_type { > + SBI_PMU_CTR_TYPE_HW = 0x0, > + SBI_PMU_CTR_TYPE_FW, > +}; > + > +/* Flags defined for config matching function */ > +#define SBI_PMU_CFG_FLAG_SKIP_MATCH BIT(0) > +#define SBI_PMU_CFG_FLAG_CLEAR_VALUE BIT(1) > +#define SBI_PMU_CFG_FLAG_AUTO_START BIT(2) > +#define SBI_PMU_CFG_FLAG_SET_VUINH BIT(3) > +#define SBI_PMU_CFG_FLAG_SET_VSINH BIT(4) > +#define SBI_PMU_CFG_FLAG_SET_UINH BIT(5) > +#define SBI_PMU_CFG_FLAG_SET_SINH BIT(6) > +#define SBI_PMU_CFG_FLAG_SET_MINH BIT(7) > + > +/* 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) > + > struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0, > unsigned long arg1, unsigned long arg2, > unsigned long arg3, unsigned long arg4, > -- > 2.34.1 > Reviewed-by: Andrew Jones