ipipe: Introduce and use ipipe_root_nr_syscalls
Subsystems (2)
PATCH 1/2 ipipe: Introduce and use ipipe_root_nr_syscalls
From: Jan Kiszka <[email protected]>
At least one arch, infamous x86, has a difference of NR_syscalls depending on compat vs. native ABI. Account for that by introducing a function that can deliver the currently valid syscall number if an arch implements such a service. In all other cases, this change is functionally no difference.
Signed-off-by Jan Kiszka <[email protected]>
---
Not sure if this should rather go into linux/ipipe.h.
include/linux/ipipe_base.h | 4 ++++ kernel/ipipe/core.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-)
include/linux/ipipe_base.h +4 -0
@@ -194,6 +194,10 @@ int __ipipe_notify_user_intreturn(void); #define __ipipe_serial_debug(__fmt, __args...) raw_printk(__fmt, ##__args) +#ifndef ipipe_root_nr_syscalls +#define ipipe_root_nr_syscalls (ti) NR_syscalls +#endif +#else /* !CONFIG_IPIPE */ struct task_struct ;
kernel/ipipe/core.c +3 -2
@@ -1018,6 +1018,7 @@ int ipipe_handle_syscall(struct thread_info *ti, unsigned long nr, struct pt_regs *regs) { unsigned long local_flags = READ_ONCE(ti->ipipe_flags); +unsigned int nr_syscalls =ipipe_root_nr_syscalls (ti);int ret;/*
@@ -1051,7 +1052,7 @@ int ipipe_handle_syscall(struct thread_info *ti,* system call handler. */ -if (nr >= NR_syscalls && (local_flags & _TIP_HEAD)) { +if (nr >= nr_syscalls && (local_flags & _TIP_HEAD)) {ipipe_fastcall_hook (regs); local_flags =READ_ONCE (ti->ipipe_flags);if (local_flags & _TIP_HEAD) {
@@ -1064,7 +1065,7 @@ int ipipe_handle_syscall(struct thread_info *ti, } } -if ((local_flags & _TIP_NOTIFY) || nr >= NR_syscalls) { +if ((local_flags & _TIP_NOTIFY) || nr >= nr_syscalls) { ret =__ipipe_notify_syscall (regs); local_flags =READ_ONCE (ti->ipipe_flags);if (local_flags & _TIP_HEAD)
Signature · 1 line
2.16.4
PATCH 2/2 x86/ipipe: Define and use ipipe_root_nr_syscalls
From: Jan Kiszka <[email protected]>
If we support compat mode, we need to account for IA32_NR_syscalls being different than NR_syscalls.
Signed-off-by Jan Kiszka <[email protected]>
--- arch/x86/entry/common.c | 3 ++- arch/x86/include/asm/ipipe_base.h | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-)
arch/x86/entry/common.c +2 -1
@@ -290,7 +290,8 @@ __visible inline void syscall_return_slowpath(struct pt_regs *regs)* want to run them exactly once per syscall exit with IRQs on. */ if (unlikely ((!IS_ENABLED (CONFIG_IPIPE ) || -syscall_get_nr (current, regs) < NR_syscalls) && +syscall_get_nr (current, regs) < +ipipe_root_nr_syscalls (ti)) && (cached_flags &SYSCALL_EXIT_WORK_FLAGS )))syscall_slow_exit_work (regs, cached_flags);
arch/x86/include/asm/ipipe_base.h +5 -0
@@ -115,6 +115,11 @@ static inline unsigned long __ipipe_ffnz(unsigned long ul) return ul; } +#ifdef CONFIG_IA32_EMULATION +#define ipipe_root_nr_syscalls (ti) \ + ((ti->status & TS_COMPAT) ? IA32_NR_syscalls : NR_syscalls) +#endif /* CONFIG_IA32_EMULATION */ +#endif /* X86_64 */ struct pt_regs ;
Signature · 1 line
2.16.4