Re: [PATCH v4 3/9] x86/entry: Convert ret_from_fork to C

From: Thomas Gleixner
Date: Fri Mar 19 2021 - 12:06:29 EST


On Wed, Mar 17 2021 at 11:12, Andy Lutomirski wrote:

> ret_from_fork is written in asm, slightly differently, for x86_32 and
> x86_64. Convert it to C.
> +__visible void noinstr ret_from_fork(struct task_struct *prev,
> + int (*kernel_thread_fn)(void *),
> + void *kernel_thread_arg,
> + struct pt_regs *user_regs)
> +{
> + instrumentation_begin();
> +
> + schedule_tail(prev);
> +
> + if (kernel_thread_fn) {
> + kernel_thread_fn(kernel_thread_arg);
> + user_regs->ax = 0;

If you replace this with:

syscall_set_return_value(current, user_regs, 0, 0);

then it's architecture agnostic and can move to kernel/entry, no?

Thanks,

tglx