Skip to content

Commit 3575d22

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 0a42692 commit 3575d22

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
@@ -1249,9 +1249,11 @@ int kvm_own_lbt(struct kvm_vcpu *vcpu)
12491249
return -EINVAL;
12501250

12511251
preempt_disable();
1252-
set_csr_euen(CSR_EUEN_LBTEN);
1253-
_restore_lbt(&vcpu->arch.lbt);
1254-
vcpu->arch.aux_inuse |= KVM_LARCH_LBT;
1252+
if (!(vcpu->arch.aux_inuse & KVM_LARCH_LBT)) {
1253+
set_csr_euen(CSR_EUEN_LBTEN);
1254+
_restore_lbt(&vcpu->arch.lbt);
1255+
vcpu->arch.aux_inuse |= KVM_LARCH_LBT;
1256+
}
12551257
preempt_enable();
12561258

12571259
return 0;

0 commit comments

Comments
 (0)