summaryrefslogtreecommitdiff
path: root/arch/loongarch/kvm/switch.S
diff options
context:
space:
mode:
authorTianrui Zhao <zhaotianrui@loongson.cn>2023-12-19 05:48:28 +0300
committerHuacai Chen <chenhuacai@loongson.cn>2023-12-19 05:48:28 +0300
commitdb1ecca22edf27c5a3dd66af406c88b5b5ac7cc1 (patch)
tree41c21e4c7fe4ed5f984834f148397e10cca7ae65 /arch/loongarch/kvm/switch.S
parent5b3d524993ff1fb36089be850ccb121ac3296bcf (diff)
downloadlinux-db1ecca22edf27c5a3dd66af406c88b5b5ac7cc1.tar.xz
LoongArch: KVM: Add LSX (128bit SIMD) support
This patch adds LSX (128bit SIMD) support for LoongArch KVM. There will be LSX exception in KVM when guest use the LSX instructions. KVM will enable LSX and restore the vector registers for guest and then return to guest to continue running. Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'arch/loongarch/kvm/switch.S')
-rw-r--r--arch/loongarch/kvm/switch.S16
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/loongarch/kvm/switch.S b/arch/loongarch/kvm/switch.S
index 0ed9040307b7..00fbf772d16f 100644
--- a/arch/loongarch/kvm/switch.S
+++ b/arch/loongarch/kvm/switch.S
@@ -245,6 +245,22 @@ SYM_FUNC_START(kvm_restore_fpu)
jr ra
SYM_FUNC_END(kvm_restore_fpu)
+#ifdef CONFIG_CPU_HAS_LSX
+SYM_FUNC_START(kvm_save_lsx)
+ fpu_save_csr a0 t1
+ fpu_save_cc a0 t1 t2
+ lsx_save_data a0 t1
+ jr ra
+SYM_FUNC_END(kvm_save_lsx)
+
+SYM_FUNC_START(kvm_restore_lsx)
+ lsx_restore_data a0 t1
+ fpu_restore_cc a0 t1 t2
+ fpu_restore_csr a0 t1 t2
+ jr ra
+SYM_FUNC_END(kvm_restore_lsx)
+#endif
+
.section ".rodata"
SYM_DATA(kvm_exception_size, .quad kvm_exc_entry_end - kvm_exc_entry)
SYM_DATA(kvm_enter_guest_size, .quad kvm_enter_guest_end - kvm_enter_guest)