[PATCH v2 0/6] LoongArch: KVM: Set max VM supported FPU type with FPU exception
From: Bibo Mao
Date: Mon Mar 30 2026 - 00:02:45 EST
With FPU save and restore flow, the cost is the same with different
FPU width 8/16/32 bytes, whatever from CPU cycle and cache line impaction.
Here is to enable FPU with max VM supported type, for example if
VM supports LASX instrction, enable FPU with LASX type even with FPU
exeception. So it can avoid possible LSX/LASX exception in future.
With context switch microbench which may touch FPU and LASX, there is 9%
improvement when halt_poll_ns is disabled. The command is
"./context --test=pipe" and source code located at:
https://github.com/bibo-mao/context_switch/blob/main/context.c
Original Wih patch improvement
75232 82440 9%
Signed-off-by: Bibo Mao <maobibo@xxxxxxxxxxx>
---
v1 ... v2:
1. Enable FPU with max VM supported FPU type, rather than max used type.
2. Add new request bit KVM_REQ_LBT_LOAD for LBT restore
3. Rename KVM_REQ_AUX_LOAD with KVM_REQ_FPU_LOAD
3. Remove aux_ldtype and KVM_LARCH_LSX/KVM_LARCH_LSX
4. Remove middle FPU state handling in kvm_own_lsx() and kvm_own_lasx(),
directly enable LSX or LASX from FPU none state.
---
Bibo Mao (6):
LoongArch: KVM: Add separate KVM_REQ_LBT_LOAD request bit
LoongArch: KVM: Enable FPU with max VM supported FPU type
LoongArch: KVM: Rename KVM_REQ_AUX_LOAD with KVM_REQ_FPU_LOAD
LoongArch: KVM: Remove some middle FPU states
LoongArch: KVM: Use vm_guest_has_fpu API in kvm_lose_fpu()
LoongArch: KVM: Remove KVM_LARCH_LASX and KVM_LARCH_LSX
arch/loongarch/include/asm/kvm_host.h | 6 +--
arch/loongarch/kvm/exit.c | 21 +++-----
arch/loongarch/kvm/vcpu.c | 78 ++++++++-------------------
3 files changed, 30 insertions(+), 75 deletions(-)
base-commit: 7aaa8047eafd0bd628065b15757d9b48c5f9c07d
--
2.39.3