kasan: Implementation of Kasan based on software tags.

Currently, only aarch64 is supported

Signed-off-by: wangmingrong <wangmingrong@xiaomi.com>
This commit is contained in:
wangmingrong
2024-09-19 03:15:29 +08:00
committed by Xiang Xiao
parent 9c6bed4b00
commit ae3facda53
17 changed files with 394 additions and 51 deletions
+5 -1
View File
@@ -79,7 +79,11 @@ ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
endif
ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address
ifeq ($(CONFIG_MM_KASAN_GENERIC),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address
else ifeq ($(CONFIG_MM_KASAN_SW_TAGS),y)
ARCHOPTIMIZATION += -fsanitize=kernel-hwaddress
endif
endif
ifeq ($(CONFIG_MM_KASAN_GLOBAL),y)
+8 -1
View File
@@ -153,6 +153,12 @@
#define TCR_PS_BITS TCR_PS_BITS_4GB
#endif
#ifdef CONFIG_MM_KASAN_SW_TAGS
#define TCR_KASAN_SW_FLAGS (TCR_TBI0 | TCR_TBI1 | TCR_ASID_8)
#else
#define TCR_KASAN_SW_FLAGS 0
#endif
/****************************************************************************
* Private Data
****************************************************************************/
@@ -254,7 +260,8 @@ static uint64_t get_tcr(int el)
* inner shareable
*/
tcr |= TCR_TG0_4K | TCR_SHARED_INNER | TCR_ORGN_WBWA | TCR_IRGN_WBWA;
tcr |= TCR_TG0_4K | TCR_SHARED_INNER | TCR_ORGN_WBWA |
TCR_IRGN_WBWA | TCR_KASAN_SW_FLAGS;
return tcr;
}
+6
View File
@@ -149,6 +149,12 @@
#define TCR_TG0_16K (2ULL << 14)
#define TCR_EPD1_DISABLE (1ULL << 23)
#define TCR_AS_SHIFT 36U
#define TCR_ASID_8 (0ULL << TCR_AS_SHIFT)
#define TCR_ASID_16 (1ULL << TCR_AS_SHIFT)
#define TCR_TBI0 (1ULL << 37)
#define TCR_TBI1 (1ULL << 38)
#define TCR_PS_BITS_4GB 0x0ULL
#define TCR_PS_BITS_64GB 0x1ULL
#define TCR_PS_BITS_1TB 0x2ULL