diff options
| author | Bibo Mao <maobibo@loongson.cn> | 2026-02-06 04:27:47 +0300 |
|---|---|---|
| committer | Huacai Chen <chenhuacai@loongson.cn> | 2026-02-06 04:27:47 +0300 |
| commit | 89b5dc53971328934fcb6a68bf75e4b76fc59ef0 (patch) | |
| tree | b829f1d855b82e7b9da4438fdab38e12bb9596f8 | |
| parent | c5cb12b81a0bddbff0f963662f18747b6d633592 (diff) | |
| download | linux-89b5dc53971328934fcb6a68bf75e4b76fc59ef0.tar.xz | |
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>
| -rw-r--r-- | arch/loongarch/kvm/exit.c | 4 | ||||
| -rw-r--r-- | 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 cb493980d874..76eec3f24953 100644 --- a/arch/loongarch/kvm/exit.c +++ b/arch/loongarch/kvm/exit.c @@ -792,8 +792,10 @@ static long kvm_save_notify(struct kvm_vcpu *vcpu) */ static int kvm_handle_lsx_disabled(struct kvm_vcpu *vcpu, int ecode) { - if (kvm_own_lsx(vcpu)) + if (!kvm_guest_has_lsx(&vcpu->arch)) kvm_queue_exception(vcpu, EXCCODE_INE, 0); + else + kvm_own_lsx(vcpu); return RESUME_GUEST; } diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c index fd3a2e60c670..0fa3981ec7ed 100644 --- a/arch/loongarch/kvm/vcpu.c +++ b/arch/loongarch/kvm/vcpu.c @@ -1376,9 +1376,6 @@ void kvm_own_fpu(struct kvm_vcpu *vcpu) /* Enable LSX and restore context */ int kvm_own_lsx(struct kvm_vcpu *vcpu) { - if (!kvm_guest_has_fpu(&vcpu->arch) || !kvm_guest_has_lsx(&vcpu->arch)) - return -EINVAL; - preempt_disable(); /* Enable LSX for guest */ |
