Skip to content

Commit 2ce079e

Browse files
hcahcasmb49
authored andcommitted
s390/pageattr: Implement missing kernel_page_present()
BugLink: https://bugs.launchpad.net/bugs/2101915 [ Upstream commit 2835f8bf5530750c3381166005934f996a83ad05 ] kernel_page_present() was intentionally not implemented when adding ARCH_HAS_SET_DIRECT_MAP support, since it was only used for suspend/resume which is not supported anymore on s390. A new bpf use case led to a compile error specific to s390. Even though this specific use case went away implement kernel_page_present(), so that the API is complete and potential future users won't run into this problem. Reported-by: Daniel Borkmann <daniel@iogearbox.net> Closes: https://lore.kernel.org/all/045de961-ac69-40cc-b141-ab70ec9377ec@iogearbox.net Fixes: 0490d6d ("s390/mm: enable ARCH_HAS_SET_DIRECT_MAP") Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent df2382e commit 2ce079e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

arch/s390/include/asm/set_memory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,6 @@ __SET_MEMORY_FUNC(set_memory_4k, SET_MEMORY_4K)
6262

6363
int set_direct_map_invalid_noflush(struct page *page);
6464
int set_direct_map_default_noflush(struct page *page);
65+
bool kernel_page_present(struct page *page);
6566

6667
#endif

arch/s390/mm/pageattr.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,21 @@ int set_direct_map_default_noflush(struct page *page)
406406
return __set_memory((unsigned long)page_to_virt(page), 1, SET_MEMORY_DEF);
407407
}
408408

409+
bool kernel_page_present(struct page *page)
410+
{
411+
unsigned long addr;
412+
unsigned int cc;
413+
414+
addr = (unsigned long)page_address(page);
415+
asm volatile(
416+
" lra %[addr],0(%[addr])\n"
417+
" ipm %[cc]\n"
418+
: [cc] "=d" (cc), [addr] "+a" (addr)
419+
:
420+
: "cc");
421+
return (cc >> 28) == 0;
422+
}
423+
409424
#if defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_KFENCE)
410425

411426
static void ipte_range(pte_t *pte, unsigned long address, int nr)

0 commit comments

Comments
 (0)