Commit 490a5e99 authored by Vasily Gorbik's avatar Vasily Gorbik Committed by Alexander Gordeev
Browse files

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: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
parent aeb4358a
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -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);
		/* 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;