D Danish Khateeb #
Message details and related content
kmap_atomic() is deprecated in favour of kmap_local_page(), as described in Documentation/mm/highmem.rst. The generic uprobes code and arch_uprobe_copy_ixol() on arm, arm64, mips and riscv were converted in v7.0, see commit a491c02c2770 ("uprobes: use kmap_local_page() for temporary page mappings") and the arch patches that came with it. sparc64 was not part of that series: its arch_uprobe_copy_ixol() writes the XOL slot through a copy_to_page() helper, which still uses kmap_atomic(). The mapping only covers a memcpy() of one instruction into the XOL page, so it needs neither the pagefault_disable() nor the preempt_disable() implied by kmap_atomic(). Uprobes is only built for sparc64, which has no HIGHMEM, so kmap_local_page() is just page_address() here and the only effect is that the copy no longer runs with page faults and preemption disabled. Tested under QEMU (sun4u) with CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, lockdep and CONFIG_DEBUG_ATOMIC_SLEEP: a test program put a uprobe and a uretprobe on one of its own functions, then called it 1000 times in one child process and 100 times in another. Every call returned the right value, all 1100 returns went through the uretprobe trampoline, and a kprobe counted 1102 calls to arch_uprobe_copy_ixol(): one per hit, plus the trampoline for each of the two XOL areas. No kernel warnings while it ran. Assisted-by: LLM sparse Signed-off-by: Danish Khateeb <redacted> --- arch/sparc/kernel/uprobes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/sparc/kernel/uprobes.c b/arch/sparc/kernel/uprobes.c
index c8cac64e9988..1b54f9e72e8c 100644
--- a/arch/sparc/kernel/uprobes.c
+++ b/arch/sparc/kernel/uprobes.c@@ -33,10 +33,10 @@ unsigned long uprobe_get_swbp_addr(struct pt_regs *regs) static void copy_to_page(struct page *page, unsigned long vaddr, const void *src, int len) { - void *kaddr = kmap_atomic(page); + void *kaddr = kmap_local_page(page); memcpy(kaddr + (vaddr & ~PAGE_MASK), src, len); - kunmap_atomic(kaddr); + kunmap_local(kaddr); } /* Fill in the xol area with the probed instruction followed by the
base-commit: 93f51579e7df248780214094418f205253383cc5 -- 2.55.0