From: Oliver Upton <oupton@kernel.org>
To: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Cc: Marc Zyngier <maz@kernel.org>, Joey Gouly <joey.gouly@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Jonathan Corbet <corbet@lwn.net>, Shuah Khan <shuah@kernel.org>,
Shuah Khan <skhan@linuxfoundation.org>,
Yury Norov <yury.norov@gmail.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Steffen Eiden <seiden@linux.ibm.com>,
Andrew Jones <andrew.jones@oss.qualcomm.com>,
Fuad Tabba <fuad.tabba@linux.dev>,
Mark Rutland <mark.rutland@arm.com>,
Sean Christopherson <seanjc@google.com>,
Shannon Zhao <shannon.zhao@linaro.org>,
Randy Dunlap <rdunlap@infradead.org>,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
devel@daynix.com, kvm@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v11 08/21] Revert "KVM: arm64: PMU: Reload when resetting"
Date: Mon, 21 Sep 2026 23:43:18 -0700 [thread overview]
Message-ID: <arIjhlqqzt4AKTOr@kernel.org> (raw)
In-Reply-To: <20260920-hybrid-v11-8-03618771b0e1@rsg.ci.i.u-tokyo.ac.jp>
Hi Akihiko,
On Sun, Sep 20, 2026 at 08:15:49PM +0900, Akihiko Odaki wrote:
> This reverts commit fe53538069bb4f625bc8734103ba044a83138fea.
>
> Restore PMU event teardown before system-register reset so existing
> perf events cannot retain configuration from the previous run. All
> counters are disabled by the reset PMCR_EL0 and MDCR_EL2 values, so
> reset does not need to request a PMU reload.
Sorry, I'm not following the intent here. KVM_REQ_RELOAD_PMU should
already be discarding + recomputing perf events based on the state of
the vPMU. What's the problem?
Thanks,
Oliver
> Assisted-by: Codex:gpt-6-astra
> Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
> ---
> arch/arm64/kvm/pmu-emul.c | 14 ++++++++++++++
> arch/arm64/kvm/reset.c | 3 +++
> arch/arm64/kvm/sys_regs.c | 3 ---
> include/kvm/arm_pmu.h | 2 ++
> 4 files changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c
> index a5ccb6ae44d5..14fcdbdb4587 100644
> --- a/arch/arm64/kvm/pmu-emul.c
> +++ b/arch/arm64/kvm/pmu-emul.c
> @@ -258,6 +258,20 @@ void kvm_pmu_vcpu_init(struct kvm_vcpu *vcpu)
> pmu->pmc[i].idx = i;
> }
>
> +/**
> + * kvm_pmu_vcpu_reset - reset pmu state for cpu
> + * @vcpu: The vcpu pointer
> + *
> + */
> +void kvm_pmu_vcpu_reset(struct kvm_vcpu *vcpu)
> +{
> + unsigned long mask = kvm_pmu_implemented_counter_mask(vcpu);
> + int i;
> +
> + for_each_set_bit(i, &mask, 32)
> + kvm_pmu_stop_counter(kvm_vcpu_idx_to_pmc(vcpu, i));
> +}
> +
> /**
> * kvm_pmu_vcpu_destroy - free perf event of PMU for cpu
> * @vcpu: The vcpu pointer
> diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c
> index 10eb7249aa9e..adcb460a5287 100644
> --- a/arch/arm64/kvm/reset.c
> +++ b/arch/arm64/kvm/reset.c
> @@ -185,6 +185,9 @@ void kvm_reset_vcpu(struct kvm_vcpu *vcpu)
> vcpu->arch.reset_state.reset = false;
> spin_unlock(&vcpu->arch.mp_state_lock);
>
> + /* Reset PMU outside of the non-preemptible section */
> + kvm_pmu_vcpu_reset(vcpu);
> +
> preempt_disable();
> loaded = (vcpu->cpu != -1);
> if (loaded)
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index 1481dd5c99a8..75624725adf1 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -5388,9 +5388,6 @@ void kvm_reset_sys_regs(struct kvm_vcpu *vcpu)
> }
>
> set_bit(KVM_ARCH_FLAG_ID_REGS_INITIALIZED, &kvm->arch.flags);
> -
> - if (kvm_vcpu_has_pmu(vcpu))
> - kvm_make_request(KVM_REQ_RELOAD_PMU, vcpu);
> }
>
> /**
> diff --git a/include/kvm/arm_pmu.h b/include/kvm/arm_pmu.h
> index 6b4a118d17ca..51f5e4ca3326 100644
> --- a/include/kvm/arm_pmu.h
> +++ b/include/kvm/arm_pmu.h
> @@ -48,6 +48,7 @@ u64 kvm_pmu_implemented_counter_mask(struct kvm_vcpu *vcpu);
> u64 kvm_pmu_accessible_counter_mask(struct kvm_vcpu *vcpu);
> u64 kvm_pmu_get_pmceid(struct kvm_vcpu *vcpu, bool pmceid1);
> void kvm_pmu_vcpu_init(struct kvm_vcpu *vcpu);
> +void kvm_pmu_vcpu_reset(struct kvm_vcpu *vcpu);
> void kvm_pmu_vcpu_destroy(struct kvm_vcpu *vcpu);
> void kvm_pmu_reprogram_counter_mask(struct kvm_vcpu *vcpu, u64 val);
> void kvm_pmu_flush_hwstate(struct kvm_vcpu *vcpu);
> @@ -125,6 +126,7 @@ static inline u64 kvm_pmu_accessible_counter_mask(struct kvm_vcpu *vcpu)
> return 0;
> }
> static inline void kvm_pmu_vcpu_init(struct kvm_vcpu *vcpu) {}
> +static inline void kvm_pmu_vcpu_reset(struct kvm_vcpu *vcpu) {}
> static inline void kvm_pmu_vcpu_destroy(struct kvm_vcpu *vcpu) {}
> static inline void kvm_pmu_reprogram_counter_mask(struct kvm_vcpu *vcpu, u64 val) {}
> static inline void kvm_pmu_flush_hwstate(struct kvm_vcpu *vcpu) {}
>
> --
> 2.55.0
>
next prev parent reply other threads:[~2026-09-22 6:43 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-20 11:15 [PATCH v11 00/21] KVM: arm64: PMU: Use multiple host PMUs Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 01/21] KVM: arm64: Serialize repeated vCPU initialization Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 02/21] KVM: arm64: PMU: Stop updating MDCR_EL2.HPMN Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 03/21] KVM: arm64: PMU: Freeze counter count after first run Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 04/21] KVM: arm64: selftests: Test SET_NR_COUNTERS " Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 05/21] KVM: arm64: PMU: Mask EL2-reserved bits on guest bitmap reads Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 06/21] KVM: arm64: PMU: Keep implemented counter mask EL-independent Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 07/21] KVM: arm64: PMU: Preserve EL2 bitmap state during migration Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 08/21] Revert "KVM: arm64: PMU: Reload when resetting" Akihiko Odaki
2026-09-22 6:43 ` Oliver Upton [this message]
2026-09-22 7:05 ` Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 09/21] KVM: arm64: PMU: Recreate events after MDCR_EL2 changes Akihiko Odaki
2026-09-22 6:54 ` Oliver Upton
2026-09-22 8:51 ` Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 10/21] KVM: arm64: PMU: Recreate events after PMCR_EL0 changes Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 11/21] KVM: arm64: PMU: Recreate events after userspace event writes Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 12/21] tools headers: Use u* types for bitfield helpers Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 13/21] KVM: arm64: selftests: Cover PMU state in MDCR_EL2 Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 14/21] arm64: errata: Require Apple IMPDEF PMUv3 traps on all CPUs Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 15/21] KVM: arm64: Don't clear vcpu->cpu in kvm_arch_vcpu_put() Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 16/21] KVM: arm64: PMU: Protect the list of PMUs with RCU Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 17/21] KVM: arm64: PMU: Pass the pPMU to kvm_map_pmu_event() Akihiko Odaki
2026-09-20 11:15 ` [PATCH v11 18/21] KVM: arm64: PMU: Pass the target CPU to kvm_pmu_probe_armpmu() Akihiko Odaki
2026-09-20 11:16 ` [PATCH v11 19/21] KVM: arm64: PMU: Implement fixed-counters-only emulation Akihiko Odaki
2026-09-20 11:16 ` [PATCH v11 20/21] KVM: arm64: PMU: Introduce FIXED_COUNTERS_ONLY Akihiko Odaki
2026-09-22 7:11 ` Oliver Upton
2026-09-22 9:13 ` Akihiko Odaki
2026-09-20 11:16 ` [PATCH v11 21/21] KVM: arm64: selftests: Test PMU_V3_FIXED_COUNTERS_ONLY Akihiko Odaki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=arIjhlqqzt4AKTOr@kernel.org \
--to=oupton@kernel.org \
--cc=andrew.jones@oss.qualcomm.com \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=devel@daynix.com \
--cc=fuad.tabba@linux.dev \
--cc=gustavoars@kernel.org \
--cc=joey.gouly@arm.com \
--cc=kees@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
--cc=pbonzini@redhat.com \
--cc=rdunlap@infradead.org \
--cc=seanjc@google.com \
--cc=seiden@linux.ibm.com \
--cc=shannon.zhao@linaro.org \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
--cc=yury.norov@gmail.com \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®