]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
LoongArch: KVM: Move LASX 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 LASX capability in the LASX exception
handler rather than function kvm_own_lasx(). Since LASX capability in
the function kvm_guest_has_lasx() implies FPU and LSX capability, only
checking kvm_guest_has_lasx() is OK here.

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 76eec3f24953cd91a7d886a55e6594e9ad505507..74b427287e96678d2c175d00bc31b9ac58999f30 100644 (file)
@@ -810,8 +810,10 @@ static int kvm_handle_lsx_disabled(struct kvm_vcpu *vcpu, int ecode)
  */
 static int kvm_handle_lasx_disabled(struct kvm_vcpu *vcpu, int ecode)
 {
-       if (kvm_own_lasx(vcpu))
+       if (!kvm_guest_has_lasx(&vcpu->arch))
                kvm_queue_exception(vcpu, EXCCODE_INE, 0);
+       else
+               kvm_own_lasx(vcpu);
 
        return RESUME_GUEST;
 }
index 0fa3981ec7edc0112d163feca50f73ee9a7eb6e6..53d720a15617a07996a4e4937b8933cfe9ff5615 100644 (file)
@@ -1409,9 +1409,6 @@ int kvm_own_lsx(struct kvm_vcpu *vcpu)
 /* Enable LASX and restore context */
 int kvm_own_lasx(struct kvm_vcpu *vcpu)
 {
-       if (!kvm_guest_has_fpu(&vcpu->arch) || !kvm_guest_has_lsx(&vcpu->arch) || !kvm_guest_has_lasx(&vcpu->arch))
-               return -EINVAL;
-
        preempt_disable();
 
        kvm_check_fcsr(vcpu, vcpu->arch.fpu.fcsr);