On Tue, Mar 17, 2026 at 9:20 AM Jinjie Ruan <[email protected]> wrote:

> Refactor the system call exit path to align with the generic entry
> framework. This consolidates thread flag checking, rseq handling, and
> syscall tracing into a structure that mirrors the generic
> syscall_exit_to_user_mode_work() implementation.
>
> [Rationale]
> The generic entry code employs a hierarchical approach for
> syscall exit work:
>
> 1. syscall_exit_to_user_mode_work(): The entry point that handles
>    rseq and checks if further exit work (tracing/audit) is required.
>
> 2. syscall_exit_work(): Performs the actual tracing, auditing, and
>    ptrace reporting.
>
> [Changes]
> - Rename and Encapsulate: Rename syscall_trace_exit() to
>   syscall_exit_work() and make it static, as it is now an internal
>   helper for the exit path.
>
> - New Entry Point: Implement syscall_exit_to_user_mode_work() to
>   replace the manual flag-reading logic in el0_svc_common(). This
>   function now encapsulates the rseq_syscall() call and the
>   conditional execution of syscall_exit_work().
>
> - Simplify el0_svc_common(): Remove the complex conditional checks
>   for tracing and CONFIG_DEBUG_RSEQ at the end of the syscall path,
>   delegating this responsibility to the new helper.
>
> - Helper Migration: Move has_syscall_work() to asm/syscall.h
>   to allow its reuse across ptrace.c and syscall.c.
>
> - Clean up RSEQ: Remove the explicit IS_ENABLED(CONFIG_DEBUG_RSEQ)
>   check in the caller, as rseq_syscall() is already a no-op when the
>   config is disabled.
>
> Cc: Will Deacon <[email protected]>
> Cc: Catalin Marinas <[email protected]>
> Reviewed-by: Kevin Brodsky <[email protected]>
> Signed-off-by: Jinjie Ruan <[email protected]>

Reviewed-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

Reply via email to