aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/arch/riscv/kernel/process.c
diff options
context:
space:
mode:
authorCharlie Jenkins <charlie@rivosinc.com>2025-03-20 10:29:21 -0700
committerThomas Gleixner <tglx@linutronix.de>2025-04-29 08:27:10 +0200
commitf955aa8723a65759e920d4de8e5d076cef412afc (patch)
tree8652c041afb2a8c40afee862160adffc178033d1 /arch/riscv/kernel/process.c
parentLinux 6.15-rc4 (diff)
downloadwireguard-linux-f955aa8723a65759e920d4de8e5d076cef412afc.tar.xz
wireguard-linux-f955aa8723a65759e920d4de8e5d076cef412afc.zip
riscv: entry: Convert ret_from_fork() to C
Move the main section of ret_from_fork() to C to allow inlining of syscall_exit_to_user_mode(). Signed-off-by: Charlie Jenkins <charlie@rivosinc.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Link: https://lore.kernel.org/all/20250320-riscv_optimize_entry-v6-1-63e187e26041@rivosinc.com
Diffstat (limited to '')
-rw-r--r--arch/riscv/kernel/process.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
index 7c244de77180..7b0a0bfe29ae 100644
--- a/arch/riscv/kernel/process.c
+++ b/arch/riscv/kernel/process.c
@@ -17,7 +17,9 @@
#include <linux/ptrace.h>
#include <linux/uaccess.h>
#include <linux/personality.h>
+#include <linux/entry-common.h>
+#include <asm/asm-prototypes.h>
#include <asm/unistd.h>
#include <asm/processor.h>
#include <asm/csr.h>
@@ -36,7 +38,7 @@ unsigned long __stack_chk_guard __read_mostly;
EXPORT_SYMBOL(__stack_chk_guard);
#endif
-extern asmlinkage void ret_from_fork(void);
+extern asmlinkage void ret_from_fork_asm(void);
void noinstr arch_cpu_idle(void)
{
@@ -206,6 +208,14 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
return 0;
}
+asmlinkage void ret_from_fork(void *fn_arg, int (*fn)(void *), struct pt_regs *regs)
+{
+ if (unlikely(fn))
+ fn(fn_arg);
+
+ syscall_exit_to_user_mode(regs);
+}
+
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
{
unsigned long clone_flags = args->flags;
@@ -242,7 +252,7 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
p->thread.riscv_v_flags = 0;
if (has_vector() || has_xtheadvector())
riscv_v_thread_alloc(p);
- p->thread.ra = (unsigned long)ret_from_fork;
+ p->thread.ra = (unsigned long)ret_from_fork_asm;
p->thread.sp = (unsigned long)childregs; /* kernel sp */
return 0;
}