From: Vasily Gorbik Date: Tue, 10 Dec 2024 10:18:32 +0000 (+0100) Subject: s390/boot: Allow KASAN mapping to fallback to small pages X-Git-Tag: v6.14-rc1~36^2~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=490a5e99ead57b16045a8e968fd8bc5fdcbfc90c;p=thirdparty%2Fkernel%2Flinux.git s390/boot: Allow KASAN mapping to fallback to small pages For KASAN shadow mappings, switch from physmem_alloc_or_die() to physmem_alloc() and return INVALID_PHYS_ADDR on allocation failure. This allows gracefully falling back from large pages to smaller pages (1MB or 4KB) if the allocation of 2GB size/aligned pages cannot be fulfilled. Reviewed-by: Alexander Gordeev Signed-off-by: Vasily Gorbik Signed-off-by: Alexander Gordeev --- diff --git a/arch/s390/boot/vmem.c b/arch/s390/boot/vmem.c index 3e69e4405d70b..47011b5a9e3d2 100644 --- a/arch/s390/boot/vmem.c +++ b/arch/s390/boot/vmem.c @@ -247,9 +247,13 @@ static unsigned long resolve_pa_may_alloc(unsigned long addr, unsigned long size return __identity_pa(addr); #ifdef CONFIG_KASAN case POPULATE_KASAN_MAP_SHADOW: - addr = physmem_alloc_or_die(RR_VMEM, size, size); - memset((void *)addr, 0, size); - return addr; + /* Allow to fail large page allocations, this will fall back to 1mb/4k pages */ + addr = physmem_alloc(RR_VMEM, size, size, size == PAGE_SIZE); + if (addr) { + memset((void *)addr, 0, size); + return addr; + } + return INVALID_PHYS_ADDR; #endif default: return INVALID_PHYS_ADDR;