* [PATCH] sparc64: uprobes: use kmap_local_page() in copy_to_page()
@ 2026-09-22 2:31 Danish Khateeb
2026-09-22 7:28 ` Oleg Nesterov
0 siblings, 1 reply; 2+ messages in thread
From: Danish Khateeb @ 2026-09-22 2:31 UTC (permalink / raw)
To: Andreas Larsson, David S. Miller, Peter Zijlstra, Oleg Nesterov,
Masami Hiramatsu
Cc: sparclinux, linux-trace-kernel, linux-kernel, Danish Khateeb
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 <danishkhateeb03@gmail.com>
---
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] sparc64: uprobes: use kmap_local_page() in copy_to_page()
2026-09-22 2:31 [PATCH] sparc64: uprobes: use kmap_local_page() in copy_to_page() Danish Khateeb
@ 2026-09-22 7:28 ` Oleg Nesterov
0 siblings, 0 replies; 2+ messages in thread
From: Oleg Nesterov @ 2026-09-22 7:28 UTC (permalink / raw)
To: Danish Khateeb
Cc: Andreas Larsson, David S. Miller, Peter Zijlstra,
Masami Hiramatsu, sparclinux, linux-trace-kernel, linux-kernel
On 09/21, Danish Khateeb wrote:
>
> --- 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);
> }
Acked-by: Oleg Nesterov <oleg@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-22 7:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-22 2:31 [PATCH] sparc64: uprobes: use kmap_local_page() in copy_to_page() Danish Khateeb
2026-09-22 7:28 ` Oleg Nesterov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®