]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
s390/mm: Allow large pages for KASAN shadow mapping
authorVasily Gorbik <gor@linux.ibm.com>
Fri, 29 Nov 2024 00:49:26 +0000 (01:49 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 8 Feb 2025 09:02:11 +0000 (10:02 +0100)
commitc198a1140afa4e6044454331571ef9cffe222071
treea2db9851dce987c15dc60e769e4a2f62d48eee7f
parent501d9899e31c902ec5be2d4817d99bba5b749fc4
s390/mm: Allow large pages for KASAN shadow mapping

[ Upstream commit e70452c4ba2ce1e24a3fdc18bd623edb7b56013c ]

Commit c98d2ecae08f ("s390/mm: Uncouple physical vs virtual address
spaces") introduced a large_allowed() helper that restricts which mapping
modes can use large pages. This change unintentionally prevented KASAN
shadow mappings from using large pages, despite there being no reason
to avoid them. In fact, large pages are preferred for performance.

Since commit d8073dc6bc04 ("s390/mm: Allow large pages only for aligned
physical addresses"), both can_large_pud() and can_large_pmd() call _pa()
to check if large page physical addresses are aligned. However, _pa()
has a side effect: it allocates memory in POPULATE_KASAN_MAP_SHADOW
mode.

Rename large_allowed() to large_page_mapping_allowed() and add
POPULATE_KASAN_MAP_SHADOW to the allowed list to restore large page
mappings for KASAN shadows.

While large_page_mapping_allowed() isn't strictly necessary with current
mapping modes since disallowed modes either don't map anything or fail
alignment and size checks, keep it for clarity.

Rename _pa() to resolve_pa_may_alloc() for clarity and to emphasize
existing side effect. Rework can_large_pud()/can_large_pmd() to take
the side effect into consideration and actually return physical address
instead of just checking conditions.

Fixes: c98d2ecae08f ("s390/mm: Uncouple physical vs virtual address spaces")
Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/s390/boot/vmem.c