From patchwork Wed Dec 11 13:33:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 13903488 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1BB622B598; Wed, 11 Dec 2024 13:34:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733924071; cv=none; b=JeOwi4oAUVNl8p3Du9LvTYQWmG1pycxqCGQCpS5fLBl5UrNzVbIYpwsuu6eQOOuE3YQsD+iGq7dQpDv/oRIQiGb6LaZXtEfBuZBU40VDmn2/JhZIglOz+i/zyDf2S8RTlwQHs3ncESlMdeGeZ6JbEfpZD0pLnHExttRp3Gpjw4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733924071; c=relaxed/simple; bh=XwvKn2JFR+eGxw1oc/+JL9gG50JFxNqYNkVyrcynD94=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FZwmq02+1dEm4q1GQec1CXZFasguzYsSS9MCfTup3FdpbnTDaY++uY5iiYNLppBZ0742+56upHUD55yGlCN0vycSIdMCekR0Ehm6W1ayxN7RJdauQBYGiABee7taZoV/tx+R3rA03vG3+9yYLStEvPR+rB+xNwRD63YbP/K5mJQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sf/Z1ow7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sf/Z1ow7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08B5CC4CED2; Wed, 11 Dec 2024 13:34:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733924071; bh=XwvKn2JFR+eGxw1oc/+JL9gG50JFxNqYNkVyrcynD94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sf/Z1ow7e05oJ0nWRVHerNcefybnvDi5tQyCZ0A/d2ecGKoLClnKJAWeAvTHBYFC9 4fNkaLbIVXua9XJ6RPn8aJPeQda64DYoLHkSiYDU5BT3fck39YmLfqpPDMc+uXA5Tv Q3kCs9ttB/Q8p8dnNMYka/2GBcB+HDAX2q9FdeyIb8QJ6VszmusOPbzWdanObwSYXg KRkm/z4kQ1dWjYJUcdYQPasGCo/4p/0TQRhvWTnnIxUvP/Db+sPU3u75usIM0+OP0K 5BjkyzykBq2XjudgCrl6Lt1FZkYDig7eI1OlH8PatbbqbRWub3YX9HfpH55jrhsplD Pu+GYnpNGs+Bg== From: Jiri Olsa To: Oleg Nesterov , Peter Zijlstra , Andrii Nakryiko Cc: bpf@vger.kernel.org, Song Liu , Yonghong Song , John Fastabend , Hao Luo , Steven Rostedt , Masami Hiramatsu , Alan Maguire , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH bpf-next 02/13] uprobes: Make copy_from_page global Date: Wed, 11 Dec 2024 14:33:51 +0100 Message-ID: <20241211133403.208920-3-jolsa@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241211133403.208920-1-jolsa@kernel.org> References: <20241211133403.208920-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Making copy_from_page global and adding uprobe prefix. Adding the uprobe prefix to copy_to_page as well for symmetry. Signed-off-by: Jiri Olsa Acked-by: Andrii Nakryiko --- include/linux/uprobes.h | 1 + kernel/events/uprobes.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h index 09a298e416a8..e24fbe496efb 100644 --- a/include/linux/uprobes.h +++ b/include/linux/uprobes.h @@ -213,6 +213,7 @@ extern void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr, extern void uprobe_handle_trampoline(struct pt_regs *regs); extern void *arch_uretprobe_trampoline(unsigned long *psize); extern unsigned long uprobe_get_trampoline_vaddr(void); +extern void uprobe_copy_from_page(struct page *page, unsigned long vaddr, void *dst, int len); #else /* !CONFIG_UPROBES */ struct uprobes_state { }; diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index e0e3ebb4c0a1..61ec91f635dc 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -249,14 +249,14 @@ bool __weak is_trap_insn(uprobe_opcode_t *insn) return is_swbp_insn(insn); } -static void copy_from_page(struct page *page, unsigned long vaddr, void *dst, int len) +void uprobe_copy_from_page(struct page *page, unsigned long vaddr, void *dst, int len) { void *kaddr = kmap_atomic(page); memcpy(dst, kaddr + (vaddr & ~PAGE_MASK), len); kunmap_atomic(kaddr); } -static void copy_to_page(struct page *page, unsigned long vaddr, const void *src, int len) +static void uprobe_copy_to_page(struct page *page, unsigned long vaddr, const void *src, int len) { void *kaddr = kmap_atomic(page); memcpy(kaddr + (vaddr & ~PAGE_MASK), src, len); @@ -277,7 +277,7 @@ static int verify_opcode(struct page *page, unsigned long vaddr, uprobe_opcode_t * is a trap variant; uprobes always wins over any other (gdb) * breakpoint. */ - copy_from_page(page, vaddr, &old_opcode, UPROBE_SWBP_INSN_SIZE); + uprobe_copy_from_page(page, vaddr, &old_opcode, UPROBE_SWBP_INSN_SIZE); is_swbp = is_swbp_insn(&old_opcode); if (is_swbp_insn(new_opcode)) { @@ -524,7 +524,7 @@ int uprobe_write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm, __SetPageUptodate(new_page); copy_highpage(new_page, old_page); - copy_to_page(new_page, vaddr, &opcode, UPROBE_SWBP_INSN_SIZE); + uprobe_copy_to_page(new_page, vaddr, &opcode, UPROBE_SWBP_INSN_SIZE); if (!is_register) { struct page *orig_page; @@ -1026,7 +1026,7 @@ static int __copy_insn(struct address_space *mapping, struct file *filp, if (IS_ERR(page)) return PTR_ERR(page); - copy_from_page(page, offset, insn, nbytes); + uprobe_copy_from_page(page, offset, insn, nbytes); put_page(page); return 0; @@ -1367,7 +1367,7 @@ struct uprobe *uprobe_register(struct inode *inode, return ERR_PTR(-EINVAL); /* - * This ensures that copy_from_page(), copy_to_page() and + * This ensures that uprobe_copy_from_page(), uprobe_copy_to_page() and * __update_ref_ctr() can't cross page boundary. */ if (!IS_ALIGNED(offset, UPROBE_SWBP_INSN_SIZE)) @@ -1856,7 +1856,7 @@ void __weak arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr, void *src, unsigned long len) { /* Initialize the slot */ - copy_to_page(page, vaddr, src, len); + uprobe_copy_to_page(page, vaddr, src, len); /* * We probably need flush_icache_user_page() but it needs vma. @@ -2287,7 +2287,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr) if (result < 0) return result; - copy_from_page(page, vaddr, &opcode, UPROBE_SWBP_INSN_SIZE); + uprobe_copy_from_page(page, vaddr, &opcode, UPROBE_SWBP_INSN_SIZE); put_page(page); out: /* This needs to return true for any variant of the trap insn */