arch/loongarch/kvm/vcpu.c | 2 ++ 1 file changed, 2 insertions(+)
In function kvm_pre_enter_guest(), it prepares to enter guest and check
whether there are pending signals or events. And it will not enter guest
if there are, PMU pass-through preparation for guest should be cancelled
and host should own PMU hardware.
Fixes: f4e40ea9f78f ("LoongArch: KVM: Add PMU support for guest")
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
arch/loongarch/kvm/vcpu.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c
index 8e427b379661..d96191d65f53 100644
--- a/arch/loongarch/kvm/vcpu.c
+++ b/arch/loongarch/kvm/vcpu.c
@@ -294,6 +294,8 @@ static int kvm_pre_enter_guest(struct kvm_vcpu *vcpu)
vcpu->arch.aux_inuse &= ~KVM_LARCH_SWCSR_LATEST;
if (kvm_request_pending(vcpu) || xfer_to_guest_mode_work_pending()) {
+ /* Lose pmu for guest and let host own it */
+ kvm_lose_pmu(vcpu);
/* make sure the vcpu mode has been written */
smp_store_mb(vcpu->mode, OUTSIDE_GUEST_MODE);
local_irq_enable();
base-commit: 3088d26962e802efa3aa5188f88f82a957f50b22
--
2.39.3
Applied, thanks.
Huacai
On Mon, Apr 21, 2025 at 9:18 AM Bibo Mao <maobibo@loongson.cn> wrote:
>
> In function kvm_pre_enter_guest(), it prepares to enter guest and check
> whether there are pending signals or events. And it will not enter guest
> if there are, PMU pass-through preparation for guest should be cancelled
> and host should own PMU hardware.
>
> Fixes: f4e40ea9f78f ("LoongArch: KVM: Add PMU support for guest")
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
> arch/loongarch/kvm/vcpu.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c
> index 8e427b379661..d96191d65f53 100644
> --- a/arch/loongarch/kvm/vcpu.c
> +++ b/arch/loongarch/kvm/vcpu.c
> @@ -294,6 +294,8 @@ static int kvm_pre_enter_guest(struct kvm_vcpu *vcpu)
> vcpu->arch.aux_inuse &= ~KVM_LARCH_SWCSR_LATEST;
>
> if (kvm_request_pending(vcpu) || xfer_to_guest_mode_work_pending()) {
> + /* Lose pmu for guest and let host own it */
> + kvm_lose_pmu(vcpu);
> /* make sure the vcpu mode has been written */
> smp_store_mb(vcpu->mode, OUTSIDE_GUEST_MODE);
> local_irq_enable();
>
> base-commit: 3088d26962e802efa3aa5188f88f82a957f50b22
> --
> 2.39.3
>
© 2016 - 2025 Red Hat, Inc.