Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4977221rdb; Sat, 30 Dec 2023 00:06:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4TzCfUoGtzDMGCaLhIHdIiu/vYfcC1NIFAXSCMuHwoOQFk8qvi+rhw6p3nqBsq+4Ge6aM X-Received: by 2002:a17:906:150:b0:a19:a19b:78a8 with SMTP id 16-20020a170906015000b00a19a19b78a8mr7181218ejh.107.1703923587124; Sat, 30 Dec 2023 00:06:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703923587; cv=none; d=google.com; s=arc-20160816; b=grP/Zx67JyybwWHJSiVPDMJZ6/D+wqt/A3ZryFGYdVT2K0xx1yc52Q7pNMsgQDHfaG 6dEF8dZKALCktgF1PJ2g0yWplnfv56h9PpoAFsKgeSQsvXO314yEmdSDQdy+ay9dBXF8 L6KGPJINObpbLZz6DrHz/E7VnuUZS2nocX9P3ZbLiknFFTbRGSBEspK3kUo5jO9law8A rAZk/oUpMbzBcyD0ZNU2ySR4seuG3cG9EVqEFfOgC05ToVqlLXPIQ563jg52Iwm6fCwx dTT9kJ0k5HeOf01dh9VJZGI4rD3i5eUKk+l11BhWQmADJRIvIgIPjRTWnQ906JADPFxG Lm7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=if0hAswI+ibjmElqlMA4QepCKQ7uzBkjrmaw+gvzjcc=; fh=FsN7YI7vtCi1XL+rgBNsdMzf1zwrS55wZ61JkiQB8AM=; b=pnZ0nLvBKk5pXwwMR4zqXXpC58JnZ2IqG9rjVsln4sn4PrxeD4F7SbN6Pp8CJGXHJI Gpql1yiECGDJ/5ike0aGN2FSos7X7owz99Xfxf5r0mDdV7jkVfdoS7VfHTYZ/0CSxqT6 2um9XikDjkZB7S36ry9lv1fv3KvNskDvZAglgU1zj9Z/zZ32/Mbbzx3HNR1eDLGEUS/r Znuo/07eRBDpdgL9+tsgFsXRiCrbIUKhWtlGx18GW66m7/yj1KtuRCxR4/pQZBs3dwAM jhvJWforlHfiBAVj1SJnBC+8CNjFfqaF2lHalm4sUgjd48aZcwlCLjoKBh5ynfmhOYPd mgfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=tYl64bkR; spf=pass (google.com: domain of linux-kernel+bounces-13359-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13359-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 gi9-20020a1709070c8900b00a268583b9d1si7924609ejc.449.2023.12.30.00.06.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Dec 2023 00:06:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13359-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=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=tYl64bkR; spf=pass (google.com: domain of linux-kernel+bounces-13359-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13359-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 B5FAC1F217F1 for ; Sat, 30 Dec 2023 08:06:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D171BAD2C; Sat, 30 Dec 2023 08:06:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.b="tYl64bkR" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-il1-f170.google.com (mail-il1-f170.google.com [209.85.166.170]) (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 52A219463 for ; Sat, 30 Dec 2023 08:06:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brainfault.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=brainfault.org Received: by mail-il1-f170.google.com with SMTP id e9e14a558f8ab-35feb61c91fso25158565ab.3 for ; Sat, 30 Dec 2023 00:06:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20230601.gappssmtp.com; s=20230601; t=1703923569; x=1704528369; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=if0hAswI+ibjmElqlMA4QepCKQ7uzBkjrmaw+gvzjcc=; b=tYl64bkRuA38NCEeZRaO6KO5TvaiXF8js4E8j4MlVW37PZ1MxYgWWAR2hB4dj3RElD 4pCUwbYub+hALRGoy9KvUz44u9wgqd9dPDpaoEhnCsW4W0kVsJJSXmTaryASlMIUIRsP GnjddAgsxscns/YIhP7m+UflJAatRGWsVI6zfPz4Vyrgyg2ow+8dV0KnJonWgxUdPIjV rZOoNyr8WubrIODL4pp04QLbu3Oc8hlxJ13fpJ65oBOPEQMbYl1oSQ9iOF7G5BXlJWMy Gpmqa9ER9zTn6R0QoVT5AH9PfH8f93np7ObSJ8ZrjLGso1xU5sXrstJoNA0uMZFVFVUy 006A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703923569; x=1704528369; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=if0hAswI+ibjmElqlMA4QepCKQ7uzBkjrmaw+gvzjcc=; b=A3hJ96iIDbL+dllOVbTAnFfFRnVEAq3bplzJ7vUNNSaVUy/Kg7Okj96bjDZMCtXbo9 GvOQ9CIdPboI60RMVWjPQJ3LuNgRehP7JG6UocsbP7LTB+hTfPQT2HHEL4BUm24ewJdG Pd47ckLklo5GnU5shVKFe0TC1mErRUibntSytjbZybN5X23JZFrv4Hh6Esk9HMDCsFGx j5Hbgb7zLxDHBy7MlHR0K8V6zR/xi6HT6LxegA+IKCIk8SzbxyE00BPHk0nnxLCyImLZ cQUxlwlEkfKdCTQUWmp8feI1ZNU0Mu1db7+yQ+b2p1GXJfcC+lkgj3A0q/jyLrAahn0Z 15UA== X-Gm-Message-State: AOJu0Yzz256lzpk3ok3id+toRrAqZnyIsaf0hIsyl/cKUSftYyGRSxiH YDCnGEx58/q/ic0EXmAKRhyHn7rDavGsxYThIzo2hyFLPoynKw== X-Received: by 2002:a05:6e02:180d:b0:35f:dc48:9153 with SMTP id a13-20020a056e02180d00b0035fdc489153mr12994086ilv.57.1703923569343; Sat, 30 Dec 2023 00:06:09 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231229214950.4061381-1-atishp@rivosinc.com> <20231229214950.4061381-9-atishp@rivosinc.com> In-Reply-To: <20231229214950.4061381-9-atishp@rivosinc.com> From: Anup Patel Date: Sat, 30 Dec 2023 13:35:59 +0530 Message-ID: Subject: Re: [v2 08/10] RISC-V: KVM: Implement SBI PMU Snapshot feature To: Atish Patra Cc: linux-kernel@vger.kernel.org, Albert Ou , Alexandre Ghiti , Andrew Jones , Atish Patra , Conor Dooley , Guo Ren , Heiko Stuebner , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paul Walmsley , Will Deacon Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Dec 30, 2023 at 3:20=E2=80=AFAM Atish Patra w= rote: > > PMU Snapshot function allows to minimize the number of traps when the > guest access configures/access the hpmcounters. If the snapshot feature > is enabled, the hypervisor updates the shared memory with counter > data and state of overflown counters. The guest can just read the > shared memory instead of trap & emulate done by the hypervisor. > > This patch doesn't implement the counter overflow yet. > > Signed-off-by: Atish Patra LGTM. Reviewed-by: Anup Patel Regards, Anup > --- > arch/riscv/include/asm/kvm_vcpu_pmu.h | 9 ++ > arch/riscv/kvm/aia.c | 5 ++ > arch/riscv/kvm/vcpu_onereg.c | 7 +- > arch/riscv/kvm/vcpu_pmu.c | 120 +++++++++++++++++++++++++- > arch/riscv/kvm/vcpu_sbi_pmu.c | 3 + > 5 files changed, 140 insertions(+), 4 deletions(-) > > diff --git a/arch/riscv/include/asm/kvm_vcpu_pmu.h b/arch/riscv/include/a= sm/kvm_vcpu_pmu.h > index 395518a1664e..d56b901a61fc 100644 > --- a/arch/riscv/include/asm/kvm_vcpu_pmu.h > +++ b/arch/riscv/include/asm/kvm_vcpu_pmu.h > @@ -50,6 +50,12 @@ struct kvm_pmu { > bool init_done; > /* Bit map of all the virtual counter used */ > DECLARE_BITMAP(pmc_in_use, RISCV_KVM_MAX_COUNTERS); > + /* Bit map of all the virtual counter overflown */ > + DECLARE_BITMAP(pmc_overflown, RISCV_KVM_MAX_COUNTERS); > + /* The address of the counter snapshot area (guest physical addre= ss) */ > + gpa_t snapshot_addr; > + /* The actual data of the snapshot */ > + struct riscv_pmu_snapshot_data *sdata; > }; > > #define vcpu_to_pmu(vcpu) (&(vcpu)->arch.pmu_context) > @@ -85,6 +91,9 @@ int kvm_riscv_vcpu_pmu_ctr_cfg_match(struct kvm_vcpu *v= cpu, unsigned long ctr_ba > int kvm_riscv_vcpu_pmu_ctr_read(struct kvm_vcpu *vcpu, unsigned long cid= x, > struct kvm_vcpu_sbi_return *retdata); > void kvm_riscv_vcpu_pmu_init(struct kvm_vcpu *vcpu); > +int kvm_riscv_vcpu_pmu_setup_snapshot(struct kvm_vcpu *vcpu, unsigned lo= ng saddr_low, > + unsigned long saddr_high, unsigned = long flags, > + struct kvm_vcpu_sbi_return *retdat= a); > void kvm_riscv_vcpu_pmu_deinit(struct kvm_vcpu *vcpu); > void kvm_riscv_vcpu_pmu_reset(struct kvm_vcpu *vcpu); > > diff --git a/arch/riscv/kvm/aia.c b/arch/riscv/kvm/aia.c > index a944294f6f23..71d161d7430d 100644 > --- a/arch/riscv/kvm/aia.c > +++ b/arch/riscv/kvm/aia.c > @@ -545,6 +545,9 @@ void kvm_riscv_aia_enable(void) > enable_percpu_irq(hgei_parent_irq, > irq_get_trigger_type(hgei_parent_irq)); > csr_set(CSR_HIE, BIT(IRQ_S_GEXT)); > + /* Enable IRQ filtering for overflow interrupt only if sscofpmf i= s present */ > + if (__riscv_isa_extension_available(NULL, RISCV_ISA_EXT_SSCOFPMF)= ) > + csr_write(CSR_HVIEN, BIT(IRQ_PMU_OVF)); > } > > void kvm_riscv_aia_disable(void) > @@ -560,6 +563,8 @@ void kvm_riscv_aia_disable(void) > > /* Disable per-CPU SGEI interrupt */ > csr_clear(CSR_HIE, BIT(IRQ_S_GEXT)); > + if (__riscv_isa_extension_available(NULL, RISCV_ISA_EXT_SSCOFPMF)= ) > + csr_clear(CSR_HVIEN, BIT(IRQ_PMU_OVF)); > disable_percpu_irq(hgei_parent_irq); > > aia_set_hvictl(false); > diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c > index fc34557f5356..581568847910 100644 > --- a/arch/riscv/kvm/vcpu_onereg.c > +++ b/arch/riscv/kvm/vcpu_onereg.c > @@ -117,8 +117,13 @@ void kvm_riscv_vcpu_setup_isa(struct kvm_vcpu *vcpu) > for (i =3D 0; i < ARRAY_SIZE(kvm_isa_ext_arr); i++) { > host_isa =3D kvm_isa_ext_arr[i]; > if (__riscv_isa_extension_available(NULL, host_isa) && > - kvm_riscv_vcpu_isa_enable_allowed(i)) > + kvm_riscv_vcpu_isa_enable_allowed(i)) { > + /* Sscofpmf depends on interrupt filtering define= d in ssaia */ > + if (host_isa =3D=3D RISCV_ISA_EXT_SSCOFPMF && > + !__riscv_isa_extension_available(NULL, RISCV_= ISA_EXT_SSAIA)) > + continue; > set_bit(host_isa, vcpu->arch.isa); > + } > } > } > > diff --git a/arch/riscv/kvm/vcpu_pmu.c b/arch/riscv/kvm/vcpu_pmu.c > index 08f561998611..e980235b8436 100644 > --- a/arch/riscv/kvm/vcpu_pmu.c > +++ b/arch/riscv/kvm/vcpu_pmu.c > @@ -311,6 +311,81 @@ int kvm_riscv_vcpu_pmu_read_hpm(struct kvm_vcpu *vcp= u, unsigned int csr_num, > return ret; > } > > +static void kvm_pmu_clear_snapshot_area(struct kvm_vcpu *vcpu) > +{ > + struct kvm_pmu *kvpmu =3D vcpu_to_pmu(vcpu); > + int snapshot_area_size =3D sizeof(struct riscv_pmu_snapshot_data)= ; > + > + if (kvpmu->sdata) { > + memset(kvpmu->sdata, 0, snapshot_area_size); > + if (kvpmu->snapshot_addr !=3D INVALID_GPA) > + kvm_vcpu_write_guest(vcpu, kvpmu->snapshot_addr, > + kvpmu->sdata, snapshot_area_= size); > + kfree(kvpmu->sdata); > + kvpmu->sdata =3D NULL; > + } > + kvpmu->snapshot_addr =3D INVALID_GPA; > +} > + > +int kvm_riscv_vcpu_pmu_setup_snapshot(struct kvm_vcpu *vcpu, unsigned lo= ng saddr_low, > + unsigned long saddr_high, unsigned = long flags, > + struct kvm_vcpu_sbi_return *retdata= ) > +{ > + struct kvm_pmu *kvpmu =3D vcpu_to_pmu(vcpu); > + int snapshot_area_size =3D sizeof(struct riscv_pmu_snapshot_data)= ; > + int sbiret =3D 0; > + gpa_t saddr; > + unsigned long hva; > + bool writable; > + > + if (!kvpmu) { > + sbiret =3D SBI_ERR_INVALID_PARAM; > + goto out; > + } > + > + if (saddr_low =3D=3D -1 && saddr_high =3D=3D -1) { > + kvm_pmu_clear_snapshot_area(vcpu); > + return 0; > + } > + > + saddr =3D saddr_low; > + > + if (saddr_high !=3D 0) { > + if (IS_ENABLED(CONFIG_32BIT)) > + saddr |=3D ((gpa_t)saddr << 32); > + else > + sbiret =3D SBI_ERR_INVALID_ADDRESS; > + goto out; > + } > + > + if (kvm_is_error_gpa(vcpu->kvm, saddr)) { > + sbiret =3D SBI_ERR_INVALID_PARAM; > + goto out; > + } > + > + hva =3D kvm_vcpu_gfn_to_hva_prot(vcpu, saddr >> PAGE_SHIFT, &writ= able); > + if (kvm_is_error_hva(hva) || !writable) { > + sbiret =3D SBI_ERR_INVALID_ADDRESS; > + goto out; > + } > + > + kvpmu->snapshot_addr =3D saddr; > + kvpmu->sdata =3D kzalloc(snapshot_area_size, GFP_ATOMIC); > + if (!kvpmu->sdata) > + return -ENOMEM; > + > + if (kvm_vcpu_write_guest(vcpu, saddr, kvpmu->sdata, snapshot_area= _size)) { > + kfree(kvpmu->sdata); > + kvpmu->snapshot_addr =3D INVALID_GPA; > + sbiret =3D SBI_ERR_FAILURE; > + } > + > +out: > + retdata->err_val =3D sbiret; > + > + return 0; > +} > + > int kvm_riscv_vcpu_pmu_num_ctrs(struct kvm_vcpu *vcpu, > struct kvm_vcpu_sbi_return *retdata) > { > @@ -344,20 +419,32 @@ int kvm_riscv_vcpu_pmu_ctr_start(struct kvm_vcpu *v= cpu, unsigned long ctr_base, > int i, pmc_index, sbiret =3D 0; > struct kvm_pmc *pmc; > int fevent_code; > + bool snap_flag_set =3D flags & SBI_PMU_START_FLAG_INIT_FROM_SNAPS= HOT; > > - if (kvm_pmu_validate_counter_mask(kvpmu, ctr_base, ctr_mask) < 0)= { > + if ((kvm_pmu_validate_counter_mask(kvpmu, ctr_base, ctr_mask) < 0= )) { > sbiret =3D SBI_ERR_INVALID_PARAM; > goto out; > } > > + if (snap_flag_set && kvpmu->snapshot_addr =3D=3D INVALID_GPA) { > + sbiret =3D SBI_ERR_NO_SHMEM; > + goto out; > + } > + > /* Start the counters that have been configured and requested by = the guest */ > for_each_set_bit(i, &ctr_mask, RISCV_MAX_COUNTERS) { > pmc_index =3D i + ctr_base; > if (!test_bit(pmc_index, kvpmu->pmc_in_use)) > continue; > pmc =3D &kvpmu->pmc[pmc_index]; > - if (flags & SBI_PMU_START_FLAG_SET_INIT_VALUE) > + if (flags & SBI_PMU_START_FLAG_SET_INIT_VALUE) { > pmc->counter_val =3D ival; > + } else if (snap_flag_set) { > + kvm_vcpu_read_guest(vcpu, kvpmu->snapshot_addr, k= vpmu->sdata, > + sizeof(struct riscv_pmu_snaps= hot_data)); > + pmc->counter_val =3D kvpmu->sdata->ctr_values[pmc= _index]; > + } > + > if (pmc->cinfo.type =3D=3D SBI_PMU_CTR_TYPE_FW) { > fevent_code =3D get_event_code(pmc->event_idx); > if (fevent_code >=3D SBI_PMU_FW_MAX) { > @@ -401,12 +488,18 @@ int kvm_riscv_vcpu_pmu_ctr_stop(struct kvm_vcpu *vc= pu, unsigned long ctr_base, > u64 enabled, running; > struct kvm_pmc *pmc; > int fevent_code; > + bool snap_flag_set =3D flags & SBI_PMU_STOP_FLAG_TAKE_SNAPSHOT; > > - if (kvm_pmu_validate_counter_mask(kvpmu, ctr_base, ctr_mask) < 0)= { > + if ((kvm_pmu_validate_counter_mask(kvpmu, ctr_base, ctr_mask) < 0= )) { > sbiret =3D SBI_ERR_INVALID_PARAM; > goto out; > } > > + if (snap_flag_set && kvpmu->snapshot_addr =3D=3D INVALID_GPA) { > + sbiret =3D SBI_ERR_NO_SHMEM; > + goto out; > + } > + > /* Stop the counters that have been configured and requested by t= he guest */ > for_each_set_bit(i, &ctr_mask, RISCV_MAX_COUNTERS) { > pmc_index =3D i + ctr_base; > @@ -439,9 +532,28 @@ int kvm_riscv_vcpu_pmu_ctr_stop(struct kvm_vcpu *vcp= u, unsigned long ctr_base, > } else { > sbiret =3D SBI_ERR_INVALID_PARAM; > } > + > + if (snap_flag_set && !sbiret) { > + if (pmc->cinfo.type =3D=3D SBI_PMU_CTR_TYPE_FW) > + pmc->counter_val =3D kvpmu->fw_event[feve= nt_code].value; > + else if (pmc->perf_event) > + pmc->counter_val +=3D perf_event_read_val= ue(pmc->perf_event, > + = &enabled, &running); > + /* TODO: Add counter overflow support when sscofp= mf support is added */ > + kvpmu->sdata->ctr_values[i] =3D pmc->counter_val; > + kvm_vcpu_write_guest(vcpu, kvpmu->snapshot_addr, = kvpmu->sdata, > + sizeof(struct riscv_pmu_snap= shot_data)); > + } > + > if (flags & SBI_PMU_STOP_FLAG_RESET) { > pmc->event_idx =3D SBI_PMU_EVENT_IDX_INVALID; > clear_bit(pmc_index, kvpmu->pmc_in_use); > + if (snap_flag_set) { > + /* Clear the snapshot area for the upcomi= ng deletion event */ > + kvpmu->sdata->ctr_values[i] =3D 0; > + kvm_vcpu_write_guest(vcpu, kvpmu->snapsho= t_addr, kvpmu->sdata, > + sizeof(struct riscv_= pmu_snapshot_data)); > + } > } > } > > @@ -567,6 +679,7 @@ void kvm_riscv_vcpu_pmu_init(struct kvm_vcpu *vcpu) > kvpmu->num_hw_ctrs =3D num_hw_ctrs + 1; > kvpmu->num_fw_ctrs =3D SBI_PMU_FW_MAX; > memset(&kvpmu->fw_event, 0, SBI_PMU_FW_MAX * sizeof(struct kvm_fw= _event)); > + kvpmu->snapshot_addr =3D INVALID_GPA; > > if (kvpmu->num_hw_ctrs > RISCV_KVM_MAX_HW_CTRS) { > pr_warn_once("Limiting the hardware counters to 32 as spe= cified by the ISA"); > @@ -626,6 +739,7 @@ void kvm_riscv_vcpu_pmu_deinit(struct kvm_vcpu *vcpu) > } > bitmap_zero(kvpmu->pmc_in_use, RISCV_MAX_COUNTERS); > memset(&kvpmu->fw_event, 0, SBI_PMU_FW_MAX * sizeof(struct kvm_fw= _event)); > + kvm_pmu_clear_snapshot_area(vcpu); > } > > void kvm_riscv_vcpu_pmu_reset(struct kvm_vcpu *vcpu) > diff --git a/arch/riscv/kvm/vcpu_sbi_pmu.c b/arch/riscv/kvm/vcpu_sbi_pmu.= c > index b70179e9e875..9f61136e4bb1 100644 > --- a/arch/riscv/kvm/vcpu_sbi_pmu.c > +++ b/arch/riscv/kvm/vcpu_sbi_pmu.c > @@ -64,6 +64,9 @@ static int kvm_sbi_ext_pmu_handler(struct kvm_vcpu *vcp= u, struct kvm_run *run, > case SBI_EXT_PMU_COUNTER_FW_READ: > ret =3D kvm_riscv_vcpu_pmu_ctr_read(vcpu, cp->a0, retdata= ); > break; > + case SBI_EXT_PMU_SNAPSHOT_SET_SHMEM: > + ret =3D kvm_riscv_vcpu_pmu_setup_snapshot(vcpu, cp->a0, c= p->a1, cp->a2, retdata); > + break; > default: > retdata->err_val =3D SBI_ERR_NOT_SUPPORTED; > } > -- > 2.34.1 >