[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260122111434.1737872-3-maobibo@loongson.cn>
Date: Thu, 22 Jan 2026 19:14:32 +0800
From: Bibo Mao <maobibo@...ngson.cn>
To: Huacai Chen <chenhuacai@...nel.org>,
WANG Xuerui <kernel@...0n.name>,
Tianrui Zhao <zhaotianrui@...ngson.cn>
Cc: loongarch@...ts.linux.dev,
linux-kernel@...r.kernel.org,
kvm@...r.kernel.org
Subject: [PATCH 2/3] LoongArch: KVM: Move LASX capability check in LASX exception handler
Like FPU exception handler, check LASX capability in LASX exception
handler rather than function kvm_own_lasx().
Signed-off-by: Bibo Mao <maobibo@...ngson.cn>
---
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
Powered by blists - more mailing lists