Like FPU exception handler, check LASX capability in LASX exception handler rather than function kvm_own_lasx(). LASX capability in function kvm_guest_has_lasx() implies FPU and LSX capability, only checking kvm_guest_has_lasx() is ok here. Signed-off-by: Bibo Mao --- arch/loongarch/kvm/exit.c | 4 +++- arch/loongarch/kvm/vcpu.c | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c index 76eec3f24953..74b427287e96 100644 --- a/arch/loongarch/kvm/exit.c +++ b/arch/loongarch/kvm/exit.c @@ -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; } diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c index aff295aa6b0b..d91a1160a309 100644 --- a/arch/loongarch/kvm/vcpu.c +++ b/arch/loongarch/kvm/vcpu.c @@ -1391,9 +1391,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); -- 2.39.3