diff options
author | Vasily Gorbik <gor@linux.ibm.com> | 2020-09-10 22:54:58 +0200 |
---|---|---|
committer | Vasily Gorbik <gor@linux.ibm.com> | 2020-09-16 14:08:47 +0200 |
commit | 8f78657c291f9e5ec26a2a9187938b374629d176 (patch) | |
tree | ee1f1c81279019c7b7f852459317517ef0d2a97a /arch/s390/kernel/setup.c | |
parent | ee4b2ce6d1e3baa412148a7b0889f6643749c665 (diff) |
s390/kasan: avoid unnecessary moving of vmemmap
Currently vmemmap area is unconditionally moved beyond Kasan shadow
memory. When Kasan is not enabled vmemmap area position is calculated
in setup_memory_end() and depends on limiting factors like ultravisor
secure storage limit. Try to follow the same logic with Kasan enabled
as well and avoid unnecessary vmemmap area position changes unless it
really intersects with Kasan shadow.
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Diffstat (limited to 'arch/s390/kernel/setup.c')
-rw-r--r-- | arch/s390/kernel/setup.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index 047793902ce6..d63b08bacdf9 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c @@ -586,11 +586,15 @@ static void __init setup_memory_end(void) /* Take care that memory_end is set and <= vmemmap */ memory_end = min(memory_end ?: max_physmem_end, (unsigned long)vmemmap); #ifdef CONFIG_KASAN - /* fit in kasan shadow memory region between 1:1 and vmemmap */ memory_end = min(memory_end, KASAN_SHADOW_START); - vmemmap = max(vmemmap, (struct page *)KASAN_SHADOW_END); #endif vmemmap_size = SECTION_ALIGN_UP(memory_end / PAGE_SIZE) * sizeof(struct page); +#ifdef CONFIG_KASAN + /* move vmemmap above kasan shadow only if stands in a way */ + if (KASAN_SHADOW_END > (unsigned long)vmemmap && + (unsigned long)vmemmap + vmemmap_size > KASAN_SHADOW_START) + vmemmap = max(vmemmap, (struct page *)KASAN_SHADOW_END); +#endif max_pfn = max_low_pfn = PFN_DOWN(memory_end); memblock_remove(memory_end, ULONG_MAX); |