Skip to content

Commit c8e5c45

Browse files
bibo-maogregkh
authored andcommitted
LoongArch: KVM: Make function kvm_own_lbt() robust
commit 4be8cef 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>
1 parent bc7d1d2 commit c8e5c45

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arch/loongarch/kvm/vcpu.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,9 +1277,11 @@ int kvm_own_lbt(struct kvm_vcpu *vcpu)
12771277
return -EINVAL;
12781278

12791279
preempt_disable();
1280-
set_csr_euen(CSR_EUEN_LBTEN);
1281-
_restore_lbt(&vcpu->arch.lbt);
1282-
vcpu->arch.aux_inuse |= KVM_LARCH_LBT;
1280+
if (!(vcpu->arch.aux_inuse & KVM_LARCH_LBT)) {
1281+
set_csr_euen(CSR_EUEN_LBTEN);
1282+
_restore_lbt(&vcpu->arch.lbt);
1283+
vcpu->arch.aux_inuse |= KVM_LARCH_LBT;
1284+
}
12831285
preempt_enable();
12841286

12851287
return 0;

0 commit comments

Comments
 (0)