From b6f686f2014ae2b104909bec7b8ed73a2d77c8fd Mon Sep 17 00:00:00 2001 From: Tao Zeng Date: Thu, 16 May 2019 17:28:29 +0800 Subject: [PATCH] kasan: change address layout [3/3] PD#SWPL-8572 Problem: In change http://scgit.amlogic.com:8080/#/c/73995/ we have changed memory layout of vmalloc. Which caused kasan can't be used Solution: change kasan address layout Verify: x301 Change-Id: I28aee4b1d9b622dd884e6c2d6b621aa870cd8586 Signed-off-by: Tao Zeng --- arch/arm/Kconfig | 1 - arch/arm/Makefile | 2 +- arch/arm/include/asm/kasan.h | 19 +++++++++++-------- arch/arm/include/asm/memory.h | 8 ++++---- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index a55b22a..da92f87 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1433,7 +1433,6 @@ choice bool "3G/1G user/kernel split" config VMSPLIT_3G_OPT bool "3G/1G user/kernel split (for full 1G low memory)" - depends on !AMLOGIC_KASAN32 config VMSPLIT_2G bool "2G/2G user/kernel split" config VMSPLIT_1G diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 4a1ada2..62732af 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -53,7 +53,7 @@ LD += -EL endif ifeq ($(CONFIG_KASAN),y) -KASAN_SHADOW_OFFSET := 0x99000000 +KASAN_SHADOW_OFFSET := 0xA0000000 endif # diff --git a/arch/arm/include/asm/kasan.h b/arch/arm/include/asm/kasan.h index 1bff547..af3d4da 100644 --- a/arch/arm/include/asm/kasan.h +++ b/arch/arm/include/asm/kasan.h @@ -20,16 +20,18 @@ * 0x00000000 +--------+ * | | * | | - * | | User space memory, 2816MB + * | | User space memory, 2944MB * | | * | | - * 0xb0000000 +--------+ - * | | Kasan shaddow memory, 144MB - * 0xb9000000 +--------+ - * | | Vmalloc address, 356MB + * 0xb8000000 +--------+ + * | | Kasan shaddow memory, 128MB + * 0xc0000000 +--------+ + * | | + * | | Vmalloc address, 240MB + * | | * 0xCF400000 +--------+ * 0xCF600000 +--------+ PKmap, for kmap 2MB - * 0xD0000000 +--------+ Modul 10MB + * 0xD0000000 +--------+ Module and pkmap, 10MB * | | * | | Kernel linear mapped space, 762MB * | | @@ -39,7 +41,8 @@ * 0xFFFF0000 +--------+ High vector, 4KB * */ -#define KASAN_SHADOW_SIZE (0x09000000) +#define KADDR_SIZE (SZ_1G) +#define KASAN_SHADOW_SIZE (KADDR_SIZE >> 3) #define KASAN_SHADOW_START (TASK_SIZE) #define KASAN_SHADOW_END (KASAN_SHADOW_START + KASAN_SHADOW_SIZE) @@ -49,7 +52,7 @@ * shadow_addr = (address >> 3) + KASAN_SHADOW_OFFSET; * */ -#define KASAN_SHADOW_OFFSET 0x99000000UL +#define KASAN_SHADOW_OFFSET (KASAN_SHADOW_START - (VMALLOC_START >> 3)) struct map_desc; void kasan_init(void); void kasan_copy_shadow(pgd_t *pgdir); diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h index 1e81f57..60c66ab 100644 --- a/arch/arm/include/asm/memory.h +++ b/arch/arm/include/asm/memory.h @@ -41,11 +41,11 @@ #ifdef CONFIG_AMLOGIC_KASAN32 /* * if open AMLOGIC_KASAN32, PAGE_OFFSET is set to 0xD0000000 - * we config 0xB0000000 as shadow memory start. so vmalloc - * can be 0xb9000000 and total 368mb space for vmalloc + * we config 0xB8000000 as shadow memory start. so vmalloc + * can be 0xC0000000 and total 256mb space for vmalloc */ -#define VMALLOC_START (UL(0xB9000000)) -#define TASK_SIZE (UL(0xB0000000)) +#define VMALLOC_START (UL(CONFIG_PAGE_OFFSET) - UL(SZ_256M)) +#define TASK_SIZE (VMALLOC_START - UL(SZ_128M)) #define KMEM_END (0xffa00000UL) #else /* CONFIG_AMLOGIC_KASAN32 */ #define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(SZ_64M)) -- 2.7.4