Skip to content

Commit 37da26e

Browse files
bibo-maochenhuacai
authored andcommitted
LoongArch: KVM: Move LASX capability check in exception handler
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>
1 parent 89b5dc5 commit 37da26e

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

arch/loongarch/kvm/exit.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,10 @@ static int kvm_handle_lsx_disabled(struct kvm_vcpu *vcpu, int ecode)
810810
*/
811811
static int kvm_handle_lasx_disabled(struct kvm_vcpu *vcpu, int ecode)
812812
{
813-
if (kvm_own_lasx(vcpu))
813+
if (!kvm_guest_has_lasx(&vcpu->arch))
814814
kvm_queue_exception(vcpu, EXCCODE_INE, 0);
815+
else
816+
kvm_own_lasx(vcpu);
815817

816818
return RESUME_GUEST;
817819
}

arch/loongarch/kvm/vcpu.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,9 +1409,6 @@ int kvm_own_lsx(struct kvm_vcpu *vcpu)
14091409
/* Enable LASX and restore context */
14101410
int kvm_own_lasx(struct kvm_vcpu *vcpu)
14111411
{
1412-
if (!kvm_guest_has_fpu(&vcpu->arch) || !kvm_guest_has_lsx(&vcpu->arch) || !kvm_guest_has_lasx(&vcpu->arch))
1413-
return -EINVAL;
1414-
14151412
preempt_disable();
14161413

14171414
kvm_check_fcsr(vcpu, vcpu->arch.fpu.fcsr);

0 commit comments

Comments
 (0)