Skip to contentSkip to conversation

xtensa: use MEMBLOCK_ALLOC_ANYWHERE for KASAN shadow map

PATCH In review Max Filippov 2 participants 2 messages Nov 14, 2019

Subsystems (3)
lore
Share & tools
lore

Max Filippov

author maintainer
#0 lore raw

PATCH 1/1 xtensa: use MEMBLOCK_ALLOC_ANYWHERE for KASAN shadow map

KASAN shadow map doesn't need to be accessible through the linear kernel mapping, allocate its pages with MEMBLOCK_ALLOC_ANYWHERE so that high memory can be used. This frees up to ~100MB of low memory on xtensa configurations with KASAN and high memory.

Fixes f240ec09bb8a ("memblock: replace memblock_alloc_base(ANYWHERE)

with memblock_phys_alloc")

---
 arch/xtensa/mm/kasan_init.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/xtensa/mm/kasan_init.c +3 -1
index 9c957791bb33..e3baa21ff24c 100644
@@ -60,7 +60,9 @@ static void __init populate(void *start, void *end)
 
 		for (k = 0; k < PTRS_PER_PTE; ++k, ++j) {
 			phys_addr_t phys =
-				memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE);
+				memblock_phys_alloc_range(PAGE_SIZE, PAGE_SIZE,
+							  0,
+							  MEMBLOCK_ALLOC_ANYWHERE);
 
 			if (!phys)
 				panic("Failed to allocate page table page\n");
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Max Filippov

KASAN shadow map doesn't need to be accessible through the linear kernel mapping, allocate its pages with MEMBLOCK_ALLOC_ANYWHERE so that high memory can be used. This frees up to ~100MB of low memory on xtensa configurations with KASAN and high memory.

Fixes f240ec09bb8a ("memblock: replace memblock_alloc_base(ANYWHERE)

with memblock_phys_alloc")

Quoted 22 lines
---
 arch/xtensa/mm/kasan_init.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/xtensa/mm/kasan_init.c +3 -1
index 9c957791bb33..e3baa21ff24c 100644
@@ -60,7 +60,9 @@ static void __init populate(void *start, void *end)
 
 		for (k = 0; k < PTRS_PER_PTE; ++k, ++j) {
 			phys_addr_t phys =
-				memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE);
+				memblock_phys_alloc_range(PAGE_SIZE, PAGE_SIZE,
+							  0,
+							  MEMBLOCK_ALLOC_ANYWHERE);
 
 			if (!phys)
 				panic("Failed to allocate page table page\n");
Signature · 1 line
2.20.1
Signature · 2 lines
Sincerely yours,
Mike.