linux-stable/arch/loongarch/lib
Qing Zhang 5aa4ac64e6 LoongArch: Add KASAN (Kernel Address Sanitizer) support
1/8 of kernel addresses reserved for shadow memory. But for LoongArch,
There are a lot of holes between different segments and valid address
space (256T available) is insufficient to map all these segments to kasan
shadow memory with the common formula provided by kasan core, saying
(addr >> KASAN_SHADOW_SCALE_SHIFT) + KASAN_SHADOW_OFFSET

So LoongArch has a arch-specific mapping formula, different segments are
mapped individually, and only limited space lengths of these specific
segments are mapped to shadow.

At early boot stage the whole shadow region populated with just one
physical page (kasan_early_shadow_page). Later, this page is reused as
readonly zero shadow for some memory that kasan currently don't track.
After mapping the physical memory, pages for shadow memory are allocated
and mapped.

Functions like memset()/memcpy()/memmove() do a lot of memory accesses.
If bad pointer passed to one of these function it is important to be
caught. Compiler's instrumentation cannot do this since these functions
are written in assembly.

KASan replaces memory functions with manually instrumented variants.
Original functions declared as weak symbols so strong definitions in
mm/kasan/kasan.c could replace them. Original functions have aliases
with '__' prefix in names, so we could call non-instrumented variant
if needed.

Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
2023-09-06 22:54:16 +08:00
..
Makefile LoongArch: Add SIMD-optimized XOR routines 2023-09-06 22:53:55 +08:00
clear_user.S LoongArch: Adjust {copy, clear}_user exception handler behavior 2023-09-06 22:53:10 +08:00
copy_user.S LoongArch: Adjust {copy, clear}_user exception handler behavior 2023-09-06 22:53:10 +08:00
csum.c LoongArch: Add checksum optimization for 64-bit system 2023-05-01 17:19:43 +08:00
delay.c LoongArch: Remove useless header compiler.h 2022-07-29 18:22:32 +08:00
dump_tlb.c LoongArch: Make the CPUCFG&CSR ops simple aliases of compiler built-ins 2023-06-29 20:58:43 +08:00
error-inject.c LoongArch: Add support for function error injection 2023-05-01 17:19:52 +08:00
memcpy.S LoongArch: Add KASAN (Kernel Address Sanitizer) support 2023-09-06 22:54:16 +08:00
memmove.S LoongArch: Add KASAN (Kernel Address Sanitizer) support 2023-09-06 22:54:16 +08:00
memset.S LoongArch: Add KASAN (Kernel Address Sanitizer) support 2023-09-06 22:54:16 +08:00
unaligned.S LoongArch: Remove unneeded #include <asm/export.h> 2023-08-25 23:40:26 +08:00
xor_simd.c LoongArch: Add SIMD-optimized XOR routines 2023-09-06 22:53:55 +08:00
xor_simd.h LoongArch: Add SIMD-optimized XOR routines 2023-09-06 22:53:55 +08:00
xor_simd_glue.c LoongArch: Add SIMD-optimized XOR routines 2023-09-06 22:53:55 +08:00
xor_template.c LoongArch: Add SIMD-optimized XOR routines 2023-09-06 22:53:55 +08:00