]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
LoongArch: KVM: Make function kvm_own_lbt() robust
authorBibo Mao <maobibo@loongson.cn>
Wed, 20 Aug 2025 14:51:14 +0000 (22:51 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:34:31 +0000 (16:34 +0200)
commit 4be8cefc132606b4a6e851f37f8e8c40c406c910 upstream.

Add the flag KVM_LARCH_LBT checking in function kvm_own_lbt(), so that
it can be called safely rather than duplicated enabling again.

Cc: stable@vger.kernel.org
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/loongarch/kvm/vcpu.c

index 5af32ec62cb16aca8a6e50f17715ed054a01b18d..ca35c01fa3638204d22d4028087756f35690fe90 100644 (file)
@@ -1277,9 +1277,11 @@ int kvm_own_lbt(struct kvm_vcpu *vcpu)
                return -EINVAL;
 
        preempt_disable();
-       set_csr_euen(CSR_EUEN_LBTEN);
-       _restore_lbt(&vcpu->arch.lbt);
-       vcpu->arch.aux_inuse |= KVM_LARCH_LBT;
+       if (!(vcpu->arch.aux_inuse & KVM_LARCH_LBT)) {
+               set_csr_euen(CSR_EUEN_LBTEN);
+               _restore_lbt(&vcpu->arch.lbt);
+               vcpu->arch.aux_inuse |= KVM_LARCH_LBT;
+       }
        preempt_enable();
 
        return 0;