Skip to content

Commit 89b5dc5

Browse files
bibo-maochenhuacai
authored andcommitted
LoongArch: KVM: Move LSX capability check in exception handler
Like FPU exception handler, check LSX capability in the LSX exception handler rather than function kvm_own_lsx(). Since LSX capability in the function kvm_guest_has_lsx() implies FPU capability, only checking kvm_guest_has_lsx() is OK here. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent c5cb12b commit 89b5dc5

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
@@ -792,8 +792,10 @@ static long kvm_save_notify(struct kvm_vcpu *vcpu)
792792
*/
793793
static int kvm_handle_lsx_disabled(struct kvm_vcpu *vcpu, int ecode)
794794
{
795-
if (kvm_own_lsx(vcpu))
795+
if (!kvm_guest_has_lsx(&vcpu->arch))
796796
kvm_queue_exception(vcpu, EXCCODE_INE, 0);
797+
else
798+
kvm_own_lsx(vcpu);
797799

798800
return RESUME_GUEST;
799801
}

arch/loongarch/kvm/vcpu.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,9 +1376,6 @@ void kvm_own_fpu(struct kvm_vcpu *vcpu)
13761376
/* Enable LSX and restore context */
13771377
int kvm_own_lsx(struct kvm_vcpu *vcpu)
13781378
{
1379-
if (!kvm_guest_has_fpu(&vcpu->arch) || !kvm_guest_has_lsx(&vcpu->arch))
1380-
return -EINVAL;
1381-
13821379
preempt_disable();
13831380

13841381
/* Enable LSX for guest */

0 commit comments

Comments
 (0)