diff options
author | Huacai Chen <chenhuacai@loongson.cn> | 2023-06-29 20:58:43 +0800 |
---|---|---|
committer | Huacai Chen <chenhuacai@loongson.cn> | 2023-06-29 20:58:43 +0800 |
commit | 616500232e632dba8b03981eeccadacf2fbf1c30 (patch) | |
tree | 2994f0c9b8343a236a375b4992079c0d203df37f /arch/loongarch/kernel/process.c | |
parent | aa5e65dc0818bbf676bf06927368ec46867778fd (diff) | |
download | linux-stable-616500232e632dba8b03981eeccadacf2fbf1c30.tar.gz linux-stable-616500232e632dba8b03981eeccadacf2fbf1c30.tar.bz2 linux-stable-616500232e632dba8b03981eeccadacf2fbf1c30.zip |
LoongArch: Add vector extensions support
Add LoongArch's vector extensions support, which including 128bit LSX
(i.e., Loongson SIMD eXtension) and 256bit LASX (i.e., Loongson Advanced
SIMD eXtension).
Linux kernel doesn't use vector itself, it only handle exceptions and
context save/restore. So it only needs a subset of these instructions:
* Vector load/store: vld vst vldx vstx xvld xvst xvldx xvstx
* 8bit-elements move: vpickve2gr.b xvpickve2gr.b vinsgr2vr.b xvinsgr2vr.b
* 16bit-elements move: vpickve2gr.h xvpickve2gr.h vinsgr2vr.h xvinsgr2vr.h
* 32bit-elements move: vpickve2gr.w xvpickve2gr.w vinsgr2vr.w xvinsgr2vr.w
* 64bit-elements move: vpickve2gr.d xvpickve2gr.d vinsgr2vr.d xvinsgr2vr.d
* Elements permute: vpermi.w vpermi.d xvpermi.w xvpermi.d xvpermi.q
Introduce AS_HAS_LSX_EXTENSION and AS_HAS_LASX_EXTENSION to avoid non-
vector toolchains complains unsupported instructions.
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'arch/loongarch/kernel/process.c')
-rw-r--r-- | arch/loongarch/kernel/process.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/arch/loongarch/kernel/process.c b/arch/loongarch/kernel/process.c index 9535a0662480..2e04eb07abb6 100644 --- a/arch/loongarch/kernel/process.c +++ b/arch/loongarch/kernel/process.c @@ -117,8 +117,14 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) */ preempt_disable(); - if (is_fpu_owner()) - save_fp(current); + if (is_fpu_owner()) { + if (is_lasx_enabled()) + save_lasx(current); + else if (is_lsx_enabled()) + save_lsx(current); + else + save_fp(current); + } preempt_enable(); |