summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBibo Mao <maobibo@loongson.cn>2026-02-06 09:27:47 +0800
committerHuacai Chen <chenhuacai@loongson.cn>2026-02-06 09:27:47 +0800
commit37da26e0e8396def86ff4ca70ece0a5f5619dbd4 (patch)
tree0cdfce962a38f7922c808b4c554397f29ff76d01
parent89b5dc53971328934fcb6a68bf75e4b76fc59ef0 (diff)
downloadlinux-37da26e0e8396def86ff4ca70ece0a5f5619dbd4.tar.gz
linux-37da26e0e8396def86ff4ca70ece0a5f5619dbd4.zip
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>
-rw-r--r--arch/loongarch/kvm/exit.c4
-rw-r--r--arch/loongarch/kvm/vcpu.c3
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 0fa3981ec7ed..53d720a15617 100644
--- a/arch/loongarch/kvm/vcpu.c
+++ b/arch/loongarch/kvm/vcpu.c
@@ -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);