Re: [PATCH] s390/uv: Rework page allocation for guest variable storage area

From: Christian Borntraeger

Date: Tue Sep 22 2026 - 07:07:41 EST


Am 15.09.26 um 16:43 schrieb Heiko Carstens:
Alexander Gordeev reported that the allocation of pages of the
guest variable storage area via the uv_alloc_range_cb() callback
of apply_to_page_range() will cause problems as soon as s390 fully
supports lazy mmu mode.

Problem is that uv_alloc_range_cb() allocates pages with GFP_KERNEL while
preemption would be disabled. This would result in reports like this:

BUG: sleeping function called from invalid context at ./include/linux/sched/mm.h:322
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 6092, name: qemu-kvm
preempt_count: 1, expected: 0
...
Call Trace:
dump_stack_lvl+0xae/0x108
__might_resched+0x1de/0x2f0
prepare_alloc_pages+0x1ba/0x220
__alloc_frozen_pages_noprof+0xc6/0x390
alloc_pages_mpol+0xe6/0x220
alloc_frozen_pages_noprof+0x5c/0x80
alloc_pages_noprof+0x22/0x80
uv_alloc_range_cb+0x30/0x300
apply_to_pte_range+0x11a/0x3b0
apply_to_pmd_range+0x13a/0x250
__apply_to_page_range+0x232/0x4d0
apply_to_page_range+0x28/0x40
uv_alloc_stor_var+0x5e/0x90
kvm_s390_pv_alloc_vm+0x118/0x1e0 [kvm]
kvm_s390_pv_init_vm+0x84/0x2e0 [kvm]
kvm_s390_handle_pv+0x502/0xf70 [kvm]
kvm_arch_vm_ioctl+0x234/0xdd0 [kvm]
kvm_vm_ioctl+0x33a/0x890 [kvm]
__s390x_sys_ioctl+0xfa/0x130
__do_syscall+0x1fc/0x700
system_call+0x72/0x90

Preallocate the pages and make use of vm_area_map_pages() to address this
potential future bug.

Reported-by: Alexander Gordeev <agordeev@xxxxxxxxxxxxx>
Closes: https://lore.kernel.org/all/e9449c63-b8d2-4ed9-a184-7dcab3e8dfce-agordeev@xxxxxxxxxxxxx
Signed-off-by: Heiko Carstens <hca@xxxxxxxxxxxxx>


Thanks applied. Will queue for the kvms390 tree after some CI runs.