riscv: Add KASAN support
authorNick Hu <nickhu@andestech.com>
Mon, 6 Jan 2020 18:38:32 +0000 (10:38 -0800)
committerPalmer Dabbelt <palmerdabbelt@google.com>
Wed, 22 Jan 2020 21:09:58 +0000 (13:09 -0800)
commit8ad8b72721d0f07fa02dbe71f901743f9c71c8e6
treef7e4dfb5c72ced986c1183e9d0c830de608ea2fc
parent57ee58e39321ab4ac3f2949b90117786726cb216
riscv: Add KASAN support

This patch ports the feature Kernel Address SANitizer (KASAN).

Note: The start address of shadow memory is at the beginning of kernel
space, which is 2^64 - (2^39 / 2) in SV39. The size of the kernel space is
2^38 bytes so the size of shadow memory should be 2^38 / 8. Thus, the
shadow memory would not overlap with the fixmap area.

There are currently two limitations in this port,

1. RV64 only: KASAN need large address space for extra shadow memory
region.

2. KASAN can't debug the modules since the modules are allocated in VMALLOC
area. We mapped the shadow memory, which corresponding to VMALLOC area, to
the kasan_early_shadow_page because we don't have enough physical space for
all the shadow memory corresponding to VMALLOC area.

Signed-off-by: Nick Hu <nickhu@andestech.com>
Reported-by: Greentime Hu <green.hu@gmail.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
12 files changed:
arch/riscv/Kconfig
arch/riscv/include/asm/kasan.h [new file with mode: 0644]
arch/riscv/include/asm/pgtable-64.h
arch/riscv/include/asm/string.h
arch/riscv/kernel/head.S
arch/riscv/kernel/riscv_ksyms.c
arch/riscv/kernel/setup.c
arch/riscv/kernel/vmlinux.lds.S
arch/riscv/lib/memcpy.S
arch/riscv/lib/memset.S
arch/riscv/mm/Makefile
arch/riscv/mm/kasan_init.c [new file with mode: 0644]