diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c index 12145874c02b8c8a3f82b4dac954e73521085dd7..af7fdd95f378f833517100a311b745e12ec5efbb 100644 --- a/arch/arm64/mm/kasan_init.c +++ b/arch/arm64/mm/kasan_init.c @@ -40,7 +40,7 @@ static phys_addr_t __init kasan_alloc_zeroed_page(int node) { void *p = memblock_virt_alloc_try_nid(PAGE_SIZE, PAGE_SIZE, __pa(MAX_DMA_ADDRESS), - MEMBLOCK_ALLOC_ACCESSIBLE, node); + MEMBLOCK_ALLOC_KASAN, node); return __pa(p); } diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 51692054937823162678d14b553c1e8d92d17730..a154655ca4f32861eb4e417b599186a8e79eb3d6 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -342,6 +342,7 @@ static inline bool memblock_bottom_up(void) /* Flags for memblock_alloc_base() amd __memblock_alloc_base() */ #define MEMBLOCK_ALLOC_ANYWHERE (~(phys_addr_t)0) #define MEMBLOCK_ALLOC_ACCESSIBLE 0 +#define MEMBLOCK_ALLOC_KASAN 1 phys_addr_t __init memblock_alloc_range(phys_addr_t size, phys_addr_t align, phys_addr_t start, phys_addr_t end, diff --git a/mm/memblock.c b/mm/memblock.c index 237944479d25a81483a7d6969cfab05c6f0a4c25..c6e84cf6efd1ab8f44ff304050a39c390953d0c9 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -253,7 +253,8 @@ phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t size, phys_addr_t kernel_end, ret; /* pump up @end */ - if (end == MEMBLOCK_ALLOC_ACCESSIBLE) + if (end == MEMBLOCK_ALLOC_ACCESSIBLE || + end == MEMBLOCK_ALLOC_KASAN) end = memblock.current_limit; /* avoid allocating the first page */ @@ -1401,13 +1402,15 @@ static void * __init memblock_virt_alloc_internal( done: ptr = phys_to_virt(alloc); - /* - * The min_count is set to 0 so that bootmem allocated blocks - * are never reported as leaks. This is because many of these blocks - * are only referred via the physical address which is not - * looked up by kmemleak. - */ - kmemleak_alloc(ptr, size, 0, 0); + /* Skip kmemleak for kasan_init() due to high volume. */ + if (max_addr != MEMBLOCK_ALLOC_KASAN) + /* + * The min_count is set to 0 so that bootmem allocated + * blocks are never reported as leaks. This is because many + * of these blocks are only referred via the physical + * address which is not looked up by kmemleak. + */ + kmemleak_alloc(ptr, size, 0, 0); return ptr; }