From: Jinjie Ruan <ruanjinjie@huawei.com>
To: Kevin Brodsky <kevin.brodsky@arm.com>, <catalin.marinas@arm.com>,
<will@kernel.org>, <oleg@redhat.com>, <tglx@linutronix.de>,
<peterz@infradead.org>, <luto@kernel.org>, <shuah@kernel.org>,
<kees@kernel.org>, <wad@chromium.org>,
<akpm@linux-foundation.org>, <ldv@strace.io>, <macro@orcam.me.uk>,
<deller@gmx.de>, <mark.rutland@arm.com>, <song@kernel.org>,
<mbenes@suse.cz>, <ryan.roberts@arm.com>,
<ada.coupriediaz@arm.com>, <anshuman.khandual@arm.com>,
<broonie@kernel.org>, <pengcan@kylinos.cn>, <dvyukov@google.com>,
<kmal@cock.li>, <lihongbo22@huawei.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linux-kselftest@vger.kernel.org>
Subject: Re: [PATCH v7 10/11] arm64: entry: Convert to generic entry
Date: Tue, 25 Nov 2025 12:00:22 +0800 [thread overview]
Message-ID: <a832b414-8da7-6333-b01e-ffd509f52ab7@huawei.com> (raw)
In-Reply-To: <39243d7f-e72a-4d37-8cd2-fb9c9f53e751@arm.com>
On 2025/11/19 1:14, Kevin Brodsky wrote:
> On 17/11/2025 14:30, Jinjie Ruan wrote:
>> [...]
>>
>> diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h
>> index 6225981fbbdb..c91938718468 100644
>> --- a/arch/arm64/include/asm/syscall.h
>> +++ b/arch/arm64/include/asm/syscall.h
>> @@ -9,6 +9,8 @@
>> #include <linux/compat.h>
>> #include <linux/err.h>
>>
>> +#include <asm/vdso.h>
>> +
>> typedef long (*syscall_fn_t)(const struct pt_regs *regs);
>>
>> extern const syscall_fn_t sys_call_table[];
>> @@ -114,12 +116,30 @@ static inline int syscall_get_arch(struct task_struct *task)
>> return AUDIT_ARCH_AARCH64;
>> }
>>
>> -static inline bool has_syscall_work(unsigned long flags)
>> +static inline bool arch_syscall_is_vdso_sigreturn(struct pt_regs *regs)
>> {
>> - return unlikely(flags & _TIF_SYSCALL_WORK);
>> -}
>> + unsigned long vdso = (unsigned long)current->mm->context.vdso;
>> + unsigned long vdso_pages, vdso_text_len;
>> + unsigned long pc = regs->pc - 4;
>
> On AArch32 (i.e. COMPAT), instructions may be 16-bit (in T32/Thumb), so
> we shouldn't blindly use PC - 4.
>
>>
>> -int syscall_trace_enter(struct pt_regs *regs, long syscall, unsigned long flags);
>> -void syscall_exit_to_user_mode_prepare(struct pt_regs *regs);
>> +#ifdef CONFIG_COMPAT
>> + if (is_compat_task()) {
>> + vdso = (unsigned long)current->mm->context.sigpage;
>> + if (pc >= vdso && pc < vdso + PAGE_SIZE)
>
> Just return that expression (instead of true/false).
>
> I think the approach is reasonable, as we have 4 possible trampolines in
> COMPAT and they all live in a dedicated page. I don't think we need to
> worry about offsetting PC, because even if it points after the last
> trampoline, it will still fall within the page. IOW, just use the
> unmodified value of regs->pc.
>
>> + return true;
>> +
>> + return false;
>> + }
>> +#endif
>> + if (regs->syscallno != __NR_rt_sigreturn)
>> + return false;
>> +
>> + vdso_pages = (vdso_end - vdso_start) >> PAGE_SHIFT;
>> + vdso_text_len = vdso_pages << PAGE_SHIFT;
>> + if (pc < vdso || pc >= vdso + vdso_text_len)
>> + return false;
>
> Why not use the same approach as x86 and simply check that regs->pc
> points after the trampoline? We already have a way to get the address of
> the vDSO's sigreturn trampoline on arm64:
> VDSO_SYMBOL(current->mm->context.vdso, sigtramp) (see signal.c). The
> trampoline consists of two instructions that cannot be changed (pretty
> much part of the ABI), so we could compare regs->pc with sigtramp + 8.
Will update it.
>
>> +
>> + return true;
>> +}
>> #endif /* __ASM_SYSCALL_H */
>> diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
>> index f241b8601ebd..0c083be23018 100644
>> --- a/arch/arm64/include/asm/thread_info.h
>> +++ b/arch/arm64/include/asm/thread_info.h
>> @@ -43,6 +43,7 @@ struct thread_info {
>> void *scs_sp;
>> #endif
>> u32 cpu;
>> + unsigned long syscall_work; /* SYSCALL_WORK_ flags */
>> };
>>
>> #define thread_saved_pc(tsk) \
>> @@ -65,11 +66,6 @@ void arch_setup_new_exec(void);
>> #define TIF_UPROBE 5 /* uprobe breakpoint or singlestep */
>> #define TIF_MTE_ASYNC_FAULT 6 /* MTE Asynchronous Tag Check Fault */
>> #define TIF_NOTIFY_SIGNAL 7 /* signal notifications exist */
>> -#define TIF_SYSCALL_TRACE 8 /* syscall trace active */
>> -#define TIF_SYSCALL_AUDIT 9 /* syscall auditing */
>> -#define TIF_SYSCALL_TRACEPOINT 10 /* syscall tracepoint for ftrace */
>> -#define TIF_SECCOMP 11 /* syscall secure computing */
>> -#define TIF_SYSCALL_EMU 12 /* syscall emulation active */
>> #define TIF_PATCH_PENDING 13 /* pending live patching update */
>> #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
>> #define TIF_FREEZE 19
>> @@ -92,30 +88,14 @@ void arch_setup_new_exec(void);
>> #define _TIF_NEED_RESCHED_LAZY (1 << TIF_NEED_RESCHED_LAZY)
>> #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
>> #define _TIF_FOREIGN_FPSTATE (1 << TIF_FOREIGN_FPSTATE)
>> -#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
>> -#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
>> -#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
>> -#define _TIF_SECCOMP (1 << TIF_SECCOMP)
>> -#define _TIF_SYSCALL_EMU (1 << TIF_SYSCALL_EMU)
>> #define _TIF_PATCH_PENDING (1 << TIF_PATCH_PENDING)
>> #define _TIF_UPROBE (1 << TIF_UPROBE)
>> -#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
>> #define _TIF_32BIT (1 << TIF_32BIT)
>> #define _TIF_SVE (1 << TIF_SVE)
>> #define _TIF_MTE_ASYNC_FAULT (1 << TIF_MTE_ASYNC_FAULT)
>> #define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL)
>> #define _TIF_TSC_SIGSEGV (1 << TIF_TSC_SIGSEGV)
>>
>> -#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY | \
>> - _TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \
>> - _TIF_UPROBE | _TIF_MTE_ASYNC_FAULT | \
>> - _TIF_NOTIFY_SIGNAL | _TIF_SIGPENDING | \
>> - _TIF_PATCH_PENDING)
>
> AFAICT this was already unused before this series, since commit
> b3cf07851b6c ("arm64: entry: Switch to generic IRQ entry"). It should be
> removed in a separate commit.
Yes, it was already unused before this series
>
>> [...]
>>
>> -void syscall_exit_to_user_mode_prepare(struct pt_regs *regs)
>> -{
>> - unsigned long flags = read_thread_flags();
>> -
>> - rseq_syscall(regs);
>> -
>> - if (has_syscall_work(flags) || flags & _TIF_SINGLESTEP)
>
> I believe switching to the generic function introduces a change here:
> syscall_exit_work() is only called if a flag in SYSCALL_WORK_EXIT is
> set, and this set does not include SYSCALL_EMU and SECCOMP. Practically
> this means that audit_syscall_exit() will no longer be called if only
> SECCOMP and/or SYSCALL_EMU is set.
>
> It doesn't feel like a major behaviour change, but it should be pointed out.
We can add "ARCH_SYSCALL_WORK_EXIT" to be defined as "SECCOMP
||SYSCALL_EMU" to keep the behaviour unchanged.
>
> - Kevin
>
>> - syscall_trace_exit(regs, flags);
>> -}
>>
>> [...]
>
next prev parent reply other threads:[~2025-11-25 4:00 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 13:30 [PATCH v7 00/11] arm64: entry: Convert to Generic Entry Jinjie Ruan
2025-11-17 13:30 ` [PATCH v7 01/11] arm64/ptrace: Split report_syscall() Jinjie Ruan
2025-11-18 17:09 ` Kevin Brodsky
2025-11-19 9:49 ` Jinjie Ruan
2025-11-25 13:06 ` Kevin Brodsky
2025-11-17 13:30 ` [PATCH v7 02/11] arm64/ptrace: Refactor syscall_trace_enter/exit() Jinjie Ruan
2025-11-18 17:09 ` Kevin Brodsky
2025-11-20 11:05 ` Jinjie Ruan
2025-11-17 13:30 ` [PATCH v7 03/11] arm64/ptrace: Refator el0_svc_common() Jinjie Ruan
2025-11-18 17:10 ` Kevin Brodsky
2025-11-20 12:03 ` Jinjie Ruan
2025-11-17 13:30 ` [PATCH v7 04/11] entry: Add syscall_exit_to_user_mode_prepare() helper Jinjie Ruan
2025-11-17 13:43 ` Thomas Gleixner
2025-11-18 17:11 ` Kevin Brodsky
2025-11-17 13:30 ` [PATCH v7 05/11] arm64/ptrace: Handle ptrace_report_syscall_entry() error Jinjie Ruan
2025-11-18 17:12 ` Kevin Brodsky
2025-11-21 4:15 ` Jinjie Ruan
2025-11-24 9:16 ` Kevin Brodsky
2025-11-17 13:30 ` [PATCH v7 06/11] arm64/ptrace: Expand secure_computing() in place Jinjie Ruan
2025-11-18 17:12 ` Kevin Brodsky
2025-11-21 7:29 ` Jinjie Ruan
2025-11-17 13:30 ` [PATCH v7 07/11] arm64/ptrace: Use syscall_get_arguments() heleper Jinjie Ruan
2025-11-18 17:12 ` Kevin Brodsky
2025-11-17 13:30 ` [PATCH v7 08/11] entry: Add arch_ptrace_report_syscall_entry/exit() Jinjie Ruan
2025-11-18 17:13 ` Kevin Brodsky
2025-11-24 9:34 ` Jinjie Ruan
2025-11-24 15:23 ` Kevin Brodsky
2025-11-25 2:43 ` Jinjie Ruan
2025-11-25 13:10 ` Kevin Brodsky
2025-11-17 13:30 ` [PATCH v7 09/11] entry: Add has_syscall_work() helper Jinjie Ruan
2025-11-18 17:13 ` Kevin Brodsky
2025-11-25 3:23 ` Jinjie Ruan
2025-11-17 13:30 ` [PATCH v7 10/11] arm64: entry: Convert to generic entry Jinjie Ruan
2025-11-18 17:14 ` Kevin Brodsky
2025-11-25 4:00 ` Jinjie Ruan [this message]
2025-11-17 13:30 ` [PATCH v7 11/11] selftests: sud_test: Support aarch64 Jinjie Ruan
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=a832b414-8da7-6333-b01e-ffd509f52ab7@huawei.com \
--to=ruanjinjie@huawei.com \
--cc=ada.coupriediaz@arm.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=deller@gmx.de \
--cc=dvyukov@google.com \
--cc=kees@kernel.org \
--cc=kevin.brodsky@arm.com \
--cc=kmal@cock.li \
--cc=ldv@strace.io \
--cc=lihongbo22@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=luto@kernel.org \
--cc=macro@orcam.me.uk \
--cc=mark.rutland@arm.com \
--cc=mbenes@suse.cz \
--cc=oleg@redhat.com \
--cc=pengcan@kylinos.cn \
--cc=peterz@infradead.org \
--cc=ryan.roberts@arm.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=tglx@linutronix.de \
--cc=wad@chromium.org \
--cc=will@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