]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
LoongArch: KVM: Fix PMU pass-through issue if VM exits to host finally
authorBibo Mao <maobibo@loongson.cn>
Thu, 24 Apr 2025 12:15:52 +0000 (20:15 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Sat, 26 Apr 2025 01:58:13 +0000 (09:58 +0800)
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.

Cc: stable@vger.kernel.org
Fixes: f4e40ea9f78f ("LoongArch: KVM: Add PMU support for guest")
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kvm/vcpu.c

index 2d3c2a2d1d1cb6c4b17721351e59f92c4d406db6..5af32ec62cb16aca8a6e50f17715ed054a01b18d 100644 (file)
@@ -294,6 +294,7 @@ 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()) {
+                       kvm_lose_pmu(vcpu);
                        /* make sure the vcpu mode has been written */
                        smp_store_mb(vcpu->mode, OUTSIDE_GUEST_MODE);
                        local_irq_enable();