Skip to content

Commit 4be8cef

Browse files
bibo-maochenhuacai
authored andcommitted
LoongArch: KVM: Make function kvm_own_lbt() robust
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: [email protected] Signed-off-by: Bibo Mao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 0078e94 commit 4be8cef

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

12851285
preempt_disable();
1286-
set_csr_euen(CSR_EUEN_LBTEN);
1287-
_restore_lbt(&vcpu->arch.lbt);
1288-
vcpu->arch.aux_inuse |= KVM_LARCH_LBT;
1286+
if (!(vcpu->arch.aux_inuse & KVM_LARCH_LBT)) {
1287+
set_csr_euen(CSR_EUEN_LBTEN);
1288+
_restore_lbt(&vcpu->arch.lbt);
1289+
vcpu->arch.aux_inuse |= KVM_LARCH_LBT;
1290+
}
12891291
preempt_enable();
12901292

12911293
return 0;

0 commit comments

Comments
 (0)