From: "tip-bot2 for Andrzej Hajda" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Andrzej Hajda <andrzej.hajda@intel.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Andi Shyti <andi.shyti@linux.intel.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: locking/core] arch/*/uprobes: simplify arch_uretprobe_hijack_return_addr
Date: Sun, 12 Mar 2023 14:41:14 -0000 [thread overview]
Message-ID: <167863207454.5837.3204445359425962539.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20230118154450.73842-3-andrzej.hajda@intel.com>
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 26ace5d28d3645efe735c3c2ff0b80dd17c85cb2
Gitweb: https://git.kernel.org/tip/26ace5d28d3645efe735c3c2ff0b80dd17c85cb2
Author: Andrzej Hajda <andrzej.hajda@intel.com>
AuthorDate: Wed, 18 Jan 2023 16:44:46 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Sat, 11 Mar 2023 14:03:59 +01:00
arch/*/uprobes: simplify arch_uretprobe_hijack_return_addr
In all architectures, except x86, arch_uretprobe_hijack_return_addr
is just __xchg.
Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://lore.kernel.org/r/20230118154450.73842-3-andrzej.hajda@intel.com
---
arch/arm/probes/uprobes/core.c | 8 ++------
arch/arm64/kernel/probes/uprobes.c | 9 ++-------
arch/csky/kernel/probes/uprobes.c | 9 ++-------
arch/mips/kernel/uprobes.c | 10 ++--------
arch/powerpc/kernel/uprobes.c | 10 ++--------
arch/riscv/kernel/probes/uprobes.c | 9 ++-------
arch/s390/kernel/uprobes.c | 7 ++-----
arch/sparc/kernel/uprobes.c | 7 ++-----
8 files changed, 16 insertions(+), 53 deletions(-)
diff --git a/arch/arm/probes/uprobes/core.c b/arch/arm/probes/uprobes/core.c
index f5f790c..77ce8ae 100644
--- a/arch/arm/probes/uprobes/core.c
+++ b/arch/arm/probes/uprobes/core.c
@@ -9,6 +9,7 @@
#include <linux/highmem.h>
#include <linux/sched.h>
#include <linux/uprobes.h>
+#include <linux/non-atomic/xchg.h>
#include <linux/notifier.h>
#include <asm/opcodes.h>
@@ -61,12 +62,7 @@ unsigned long
arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr,
struct pt_regs *regs)
{
- unsigned long orig_ret_vaddr;
-
- orig_ret_vaddr = regs->ARM_lr;
- /* Replace the return addr with trampoline addr */
- regs->ARM_lr = trampoline_vaddr;
- return orig_ret_vaddr;
+ return __xchg(®s->ARM_lr, trampoline_vaddr);
}
int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm,
diff --git a/arch/arm64/kernel/probes/uprobes.c b/arch/arm64/kernel/probes/uprobes.c
index d49aef2..d7171d3 100644
--- a/arch/arm64/kernel/probes/uprobes.c
+++ b/arch/arm64/kernel/probes/uprobes.c
@@ -3,6 +3,7 @@
* Copyright (C) 2014-2016 Pratyush Anand <panand@redhat.com>
*/
#include <linux/highmem.h>
+#include <linux/non-atomic/xchg.h>
#include <linux/ptrace.h>
#include <linux/uprobes.h>
#include <asm/cacheflush.h>
@@ -150,13 +151,7 @@ unsigned long
arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr,
struct pt_regs *regs)
{
- unsigned long orig_ret_vaddr;
-
- orig_ret_vaddr = procedure_link_pointer(regs);
- /* Replace the return addr with trampoline addr */
- procedure_link_pointer_set(regs, trampoline_vaddr);
-
- return orig_ret_vaddr;
+ return __xchg(&procedure_link_pointer(regs), trampoline_vaddr);
}
int arch_uprobe_exception_notify(struct notifier_block *self,
diff --git a/arch/csky/kernel/probes/uprobes.c b/arch/csky/kernel/probes/uprobes.c
index 2d31a12..775fe88 100644
--- a/arch/csky/kernel/probes/uprobes.c
+++ b/arch/csky/kernel/probes/uprobes.c
@@ -3,6 +3,7 @@
* Copyright (C) 2014-2016 Pratyush Anand <panand@redhat.com>
*/
#include <linux/highmem.h>
+#include <linux/non-atomic/xchg.h>
#include <linux/ptrace.h>
#include <linux/uprobes.h>
#include <asm/cacheflush.h>
@@ -123,13 +124,7 @@ unsigned long
arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr,
struct pt_regs *regs)
{
- unsigned long ra;
-
- ra = regs->lr;
-
- regs->lr = trampoline_vaddr;
-
- return ra;
+ return __xchg(®s->lr, trampoline_vaddr);
}
int arch_uprobe_exception_notify(struct notifier_block *self,
diff --git a/arch/mips/kernel/uprobes.c b/arch/mips/kernel/uprobes.c
index 6c063aa..2b1f375 100644
--- a/arch/mips/kernel/uprobes.c
+++ b/arch/mips/kernel/uprobes.c
@@ -2,6 +2,7 @@
#include <linux/highmem.h>
#include <linux/kdebug.h>
#include <linux/types.h>
+#include <linux/non-atomic/xchg.h>
#include <linux/notifier.h>
#include <linux/sched.h>
#include <linux/uprobes.h>
@@ -197,14 +198,7 @@ void arch_uprobe_abort_xol(struct arch_uprobe *aup,
unsigned long arch_uretprobe_hijack_return_addr(
unsigned long trampoline_vaddr, struct pt_regs *regs)
{
- unsigned long ra;
-
- ra = regs->regs[31];
-
- /* Replace the return address with the trampoline address */
- regs->regs[31] = trampoline_vaddr;
-
- return ra;
+ return __xchg(®s->regs[31], trampoline_vaddr);
}
/**
diff --git a/arch/powerpc/kernel/uprobes.c b/arch/powerpc/kernel/uprobes.c
index 95a41ae..3c15c32 100644
--- a/arch/powerpc/kernel/uprobes.c
+++ b/arch/powerpc/kernel/uprobes.c
@@ -7,6 +7,7 @@
* Adapted from the x86 port by Ananth N Mavinakayanahalli <ananth@in.ibm.com>
*/
#include <linux/kernel.h>
+#include <linux/non-atomic/xchg.h>
#include <linux/sched.h>
#include <linux/ptrace.h>
#include <linux/uprobes.h>
@@ -197,14 +198,7 @@ bool arch_uprobe_skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs)
unsigned long
arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs *regs)
{
- unsigned long orig_ret_vaddr;
-
- orig_ret_vaddr = regs->link;
-
- /* Replace the return addr with trampoline addr */
- regs->link = trampoline_vaddr;
-
- return orig_ret_vaddr;
+ return __xchg(®s->link, trampoline_vaddr);
}
bool arch_uretprobe_is_alive(struct return_instance *ret, enum rp_check ctx,
diff --git a/arch/riscv/kernel/probes/uprobes.c b/arch/riscv/kernel/probes/uprobes.c
index c976a21..5c8415e 100644
--- a/arch/riscv/kernel/probes/uprobes.c
+++ b/arch/riscv/kernel/probes/uprobes.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/highmem.h>
+#include <linux/non-atomic/xchg.h>
#include <linux/ptrace.h>
#include <linux/uprobes.h>
@@ -122,13 +123,7 @@ unsigned long
arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr,
struct pt_regs *regs)
{
- unsigned long ra;
-
- ra = regs->ra;
-
- regs->ra = trampoline_vaddr;
-
- return ra;
+ return __xchg(®s->ra, trampoline_vaddr);
}
int arch_uprobe_exception_notify(struct notifier_block *self,
diff --git a/arch/s390/kernel/uprobes.c b/arch/s390/kernel/uprobes.c
index b88345e..18591ca 100644
--- a/arch/s390/kernel/uprobes.c
+++ b/arch/s390/kernel/uprobes.c
@@ -11,6 +11,7 @@
#include <linux/compat.h>
#include <linux/kdebug.h>
#include <linux/sched/task_stack.h>
+#include <linux/non-atomic/xchg.h>
#include <asm/switch_to.h>
#include <asm/facility.h>
@@ -144,11 +145,7 @@ void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
unsigned long arch_uretprobe_hijack_return_addr(unsigned long trampoline,
struct pt_regs *regs)
{
- unsigned long orig;
-
- orig = regs->gprs[14];
- regs->gprs[14] = trampoline;
- return orig;
+ return __xchg(®s->gprs[14], trampoline);
}
bool arch_uretprobe_is_alive(struct return_instance *ret, enum rp_check ctx,
diff --git a/arch/sparc/kernel/uprobes.c b/arch/sparc/kernel/uprobes.c
index 1a06002..1c02653 100644
--- a/arch/sparc/kernel/uprobes.c
+++ b/arch/sparc/kernel/uprobes.c
@@ -11,6 +11,7 @@
#include <linux/kernel.h>
#include <linux/highmem.h>
+#include <linux/non-atomic/xchg.h>
#include <linux/uprobes.h>
#include <linux/uaccess.h>
#include <linux/sched.h> /* For struct task_struct */
@@ -310,9 +311,5 @@ unsigned long
arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr,
struct pt_regs *regs)
{
- unsigned long orig_ret_vaddr = regs->u_regs[UREG_I7];
-
- regs->u_regs[UREG_I7] = trampoline_vaddr-8;
-
- return orig_ret_vaddr + 8;
+ return __xchg(®s->u_regs[UREG_I7], trampoline_vaddr - 8) + 8;
}
next prev parent reply other threads:[~2023-03-12 14:41 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-18 15:35 [PATCH v5 0/7] Introduce __xchg, non-atomic xchg Andrzej Hajda
2023-01-18 15:44 ` [PATCH v5 1/7] arch: rename all internal names __xchg to __arch_xchg Andrzej Hajda
2023-01-18 15:44 ` [PATCH v5 2/7] linux/include: add non-atomic version of xchg Andrzej Hajda
2023-02-27 9:53 ` [Intel-gfx] " Andi Shyti
2023-03-12 14:41 ` [tip: locking/core] " tip-bot2 for Andrzej Hajda
2023-01-18 15:44 ` [PATCH v5 3/7] arch/*/uprobes: simplify arch_uretprobe_hijack_return_addr Andrzej Hajda
2023-02-27 9:54 ` [Intel-gfx] " Andi Shyti
2023-03-12 14:41 ` tip-bot2 for Andrzej Hajda [this message]
2023-01-18 15:44 ` [PATCH v5 4/7] llist: simplify __llist_del_all Andrzej Hajda
2023-02-27 9:55 ` [Intel-gfx] " Andi Shyti
2023-03-12 14:41 ` [tip: locking/core] " tip-bot2 for Andrzej Hajda
2023-01-18 15:44 ` [PATCH v5 5/7] io_uring: use __xchg if possible Andrzej Hajda
2023-02-27 9:59 ` [Intel-gfx] " Andi Shyti
2023-03-12 14:41 ` [tip: locking/core] " tip-bot2 for Andrzej Hajda
2023-01-18 15:44 ` [PATCH v5 6/7] qed: " Andrzej Hajda
2023-02-27 9:56 ` [Intel-gfx] " Andi Shyti
2023-03-12 14:41 ` [tip: locking/core] " tip-bot2 for Andrzej Hajda
2023-01-18 15:44 ` [PATCH v5 7/7] drm/i915/gt: use __xchg instead of internal helper Andrzej Hajda
2023-02-27 9:58 ` [Intel-gfx] " Andi Shyti
2023-03-12 14:41 ` [tip: locking/core] " tip-bot2 for Andrzej Hajda
2023-03-14 9:58 ` tip-bot2 for Andrzej Hajda
2023-02-27 9:53 ` [Intel-gfx] [PATCH v5 1/7] arch: rename all internal names __xchg to __arch_xchg Andi Shyti
2023-03-12 14:41 ` [tip: locking/core] " tip-bot2 for Andrzej Hajda
2023-04-29 7:03 ` [tip: locking/core] locking/arch: Rename all internal __xchg() names to __arch_xchg() tip-bot2 for Andrzej Hajda
2023-04-29 7:18 ` tip-bot2 for Andrzej Hajda
2023-02-22 10:36 ` [Intel-gfx] [PATCH v5 0/7] Introduce __xchg, non-atomic xchg Andrzej Hajda
2023-02-22 17:04 ` Peter Zijlstra
2023-02-23 21:24 ` [Intel-gfx] " Andrzej Hajda
2023-02-27 13:49 ` Peter Zijlstra
2024-04-05 14:47 ` Jani Nikula
2024-04-05 16:20 ` Andrzej Hajda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=167863207454.5837.3204445359425962539.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=andi.shyti@linux.intel.com \
--cc=andrzej.hajda@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).