]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
LoongArch: KVM: Move LBT capability check in exception handler
authorBibo Mao <maobibo@loongson.cn>
Fri, 6 Feb 2026 01:27:47 +0000 (09:27 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Fri, 6 Feb 2026 01:27:47 +0000 (09:27 +0800)
Like FPU exception handler, check LBT capability in the LBT exception
handler rather than function kvm_own_lbt().

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kvm/exit.c
arch/loongarch/kvm/vcpu.c

index 74b427287e96678d2c175d00bc31b9ac58999f30..65ec10a7245a96011957716ea0c186254ad9021b 100644 (file)
@@ -820,8 +820,10 @@ static int kvm_handle_lasx_disabled(struct kvm_vcpu *vcpu, int ecode)
 
 static int kvm_handle_lbt_disabled(struct kvm_vcpu *vcpu, int ecode)
 {
-       if (kvm_own_lbt(vcpu))
+       if (!kvm_guest_has_lbt(&vcpu->arch))
                kvm_queue_exception(vcpu, EXCCODE_INE, 0);
+       else
+               kvm_own_lbt(vcpu);
 
        return RESUME_GUEST;
 }
index 53d720a15617a07996a4e4937b8933cfe9ff5615..07c427a5e15661a09d0ec4fc0916e0a529480e05 100644 (file)
@@ -1304,9 +1304,6 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
 #ifdef CONFIG_CPU_HAS_LBT
 int kvm_own_lbt(struct kvm_vcpu *vcpu)
 {
-       if (!kvm_guest_has_lbt(&vcpu->arch))
-               return -EINVAL;
-
        preempt_disable();
        if (!(vcpu->arch.aux_inuse & KVM_LARCH_LBT)) {
                set_csr_euen(CSR_EUEN_LBTEN);