alpha: enable GENERIC_ENTRY
Subsystems (2)
Magnus Lindholm
maintainerv5 cover alpha: enable GENERIC_ENTRY
Hi,
This is v5 of the Alpha generic-entry series. The five preparatory patches from the previous posting have now been merged, so this posting contains only the remaining GENERIC_ENTRY conversion.
The patch moves Alpha's syscall entry, syscall exit, and return-to-user handling to the generic entry infrastructure. Alpha-specific syscall dispatch and the r0/r19 return-value encoding remain architecture code, as do the low-level PALcode return paths.
This version is rebased onto v7.3-rc1 and adapted to Thomas Gleixner's syscall-entry API changes. It uses syscall_enter_from_user_mode_randomize_stack() and the new Boolean syscall-permission result while preserving Alpha's ptrace, seccomp, restart, and invalid-syscall handling.
This is tested on an UP2000+ SMP. Normal workload, FPU work, strace testsuit and seccomp kernel testsuit.
Changes since v4:
- Dropped the five preparatory patches that have been merged.
- Rebased the remaining GENERIC_ENTRY patch onto v7.3-rc1.
- Adapted syscall entry to the new Boolean permission API.
- Use the combined syscall-entry and kernel-stack randomization helper.
The previous posting is available here:
Thanks,
Magnus
Magnus Lindholm (1):
alpha: enable GENERIC_ENTRY
arch/alpha/Kconfig | 2 + arch/alpha/include/asm/entry-common.h | 14 ++ arch/alpha/include/asm/ptrace.h | 14 +- arch/alpha/include/asm/stacktrace.h | 20 ++ arch/alpha/include/asm/syscall.h | 11 +- arch/alpha/include/asm/thread_info.h | 30 +-- arch/alpha/kernel/asm-offsets.c | 5 + arch/alpha/kernel/entry.S | 322 +++++++------------------- arch/alpha/kernel/irq_alpha.c | 14 +- arch/alpha/kernel/proto.h | 9 +- arch/alpha/kernel/ptrace.c | 130 +++++------ arch/alpha/kernel/signal.c | 164 ++++++++++--- 12 files changed, 370 insertions(+), 365 deletions(-) create mode 100644 arch/alpha/include/asm/entry-common.h create mode 100644 arch/alpha/include/asm/stacktrace.h
Signature · 1 line
2.53.0
Magnus Lindholm
maintainerPATCH v5 1/1 alpha: enable GENERIC_ENTRY
Wire Alpha into the generic entry code for syscall entry/exit and return-to-user handling, while keeping the low-level PALcode return paths Alpha-specific.
Move most of the syscall entry/exit logic out of entSys and into C helpers built around the generic entry API. Syscall entry now uses syscall_enter_from_user_mode(), records Alpha-local syscall metadata in thread_info, handles the ptrace/seccomp skip decision, and selects the syscall table target in C. The final target call remains in entry.S so Alpha can preserve its existing syscall ABI and assembly syscall-table wrappers.
On return from syscalls, finish Alpha's r0/r19 result encoding and skipped-syscall restart handling in C before calling syscall_exit_to_user_mode(). Non-syscall returns to user mode use a separate alpha_exit_to_user_mode() helper, which disables interrupts, runs irqentry_exit_to_user_mode_prepare(), and then enters the common exit_to_user_mode() path.
Keep the remaining PALcode restore handling in assembly. In particular, kernel-mode returns still need Alpha-specific lockdep IRQ-state annotation based on the saved processor status, while user-mode returns are handed to the generic exit-to-user code.
Add the generic-entry support bits needed by common code, including thread_info.syscall_work, syscall trace support, ptrace sysemu request numbers, and arch_syscall_is_vdso_sigreturn().
This has been tested by booting Alpha with GENERIC_ENTRY enabled, checking lockdep IRQ-state accounting, running fork/clone-heavy package builds, and running the seccomp as well as strace test suites.
--- arch/alpha/Kconfig | 2 + arch/alpha/include/asm/entry-common.h | 14 ++ arch/alpha/include/asm/ptrace.h | 14 +- arch/alpha/include/asm/stacktrace.h | 20 ++ arch/alpha/include/asm/syscall.h | 11 +- arch/alpha/include/asm/thread_info.h | 30 +-- arch/alpha/kernel/asm-offsets.c | 5 + arch/alpha/kernel/entry.S | 322 +++++++------------------- arch/alpha/kernel/irq_alpha.c | 14 +- arch/alpha/kernel/proto.h | 9 +- arch/alpha/kernel/ptrace.c | 130 +++++------ arch/alpha/kernel/signal.c | 164 ++++++++++--- 12 files changed, 370 insertions(+), 365 deletions(-) create mode 100644 arch/alpha/include/asm/entry-common.h create mode 100644 arch/alpha/include/asm/stacktrace.h
arch/alpha/Kconfig +2 -0
@@ -2,6 +2,8 @@ config ALPHA bool default y + select GENERIC_ENTRY + select HAVE_SYSCALL_TRACEPOINTS select ARCH_32BIT_USTAT_F_TINODE select ARCH_HAS_CURRENT_STACK_POINTER select ARCH_HAS_DMA_OPS if PCI
arch/alpha/include/asm/entry-common.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef ARCH_ALPHA_ENTRY_COMMON_H +#define ARCH_ALPHA_ENTRY_COMMON_H + +#include <asm/stacktrace.h> /* For on_thread_stack() */ +#include <asm/syscall.h> + +#define arch_exit_to_user_mode_work arch_exit_to_user_mode_work + +static __always_inline void arch_exit_to_user_mode_work(struct pt_regs *regs, +unsigned long ti_work) +{ +} +#endif
arch/alpha/include/asm/ptrace.h +12 -2
@@ -3,7 +3,7 @@#define _ASMAXP_PTRACE_H#include <uapi/asm/ptrace.h> - +#include <asm/irqflags.h> #define arch_has_single_step () (1)#define user_mode (regs) (((regs)->ps & 8) != 0)
@@ -17,7 +17,9 @@#define current_pt_regs () \ ((struct pt_regs *) ((char *)current_thread_info() + 2*PAGE_SIZE) - 1) -#define force_successful_syscall_return () (current_pt_regs()->r0 = 0) +#define force_successful_syscall_return () \ + (current_thread_info()->syscall_meta \ + |= ALPHA_SYSCALL_META_FORCE_SUCCESS)static inline unsigned long regs_return_value (struct pt_regs *regs) {
@@ -31,4 +33,12 @@ static inline unsigned long user_stack_pointer(struct pt_regs *regs)return regs->usp; } +static __always_inline bool regs_irqs_disabled(struct pt_regs *regs) +{ +return arch_irqs_disabled_flags (regs->ps); +} + +/* Syscall emulation defines */ +#define PTRACE_SYSEMU 0x1d +#define PTRACE_SYSEMU_SINGLESTEP 0x1e#endif
arch/alpha/include/asm/stacktrace.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_ALPHA_STACKTRACE_H +#define _ASM_ALPHA_STACKTRACE_H + +#include <linux/compiler_attributes.h> +#include <linux/types.h> + +#include <asm/current.h> +#include <asm/processor.h> +#include <asm/thread_info.h> + +static __always_inline bool on_thread_stack(void) +{ +unsigned long base = (unsigned long )current->stack; +unsigned long sp = (unsigned long )current_stack_pointer; + +return !((base ^ sp) & ~(THREAD_SIZE -1 )); +} + +#endif /* _ASM_ALPHA_STACKTRACE_H */
arch/alpha/include/asm/syscall.h +10 -1
@@ -8,6 +8,8 @@#include <linux/types.h> #include <asm/ptrace.h> +extern void *sys_call_table[]; +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_ALPHA ;
@@ -104,10 +106,17 @@ static inline void syscall_set_return_value(struct task_struct *task, }/* Restore the original syscall nr after seccomp/ptrace modified regs->r1. */ +static inline void syscall_rollback (struct task_struct *task,struct pt_regs *regs) { - regs->r1 = regs->r2; +unsigned long nr =task_thread_info (task)->syscall_saved_nr; + + regs->r1 = nr; } +static inline bool arch_syscall_is_vdso_sigreturn (struct pt_regs *regs) +{ +return false; +}#endif /* _ASM_ALPHA_SYSCALL_H */
arch/alpha/include/asm/thread_info.h +12 -18
@@ -12,16 +12,21 @@#endif #ifndef __ASSEMBLER__ + struct thread_info { struct pcb_struct pcb; /* palcode state */ struct task_struct *task; /* main task structure */ - unsigned int flags; /* low level flags */ + unsigned long flags; /* low level flags */ + unsigned long syscall_work; /* SYSCALL_WORK_* flags */ unsigned int ieee_state; /* see fpu.h */ unsigned cpu; /* current CPU */ - int preempt_count; /* 0 => preemptable, <0 => BUG */ + int preempt_count; /* 0 => preemptable, <0 => BUG */ unsigned int status; /* thread-synchronous flags */ + unsigned long syscall_saved_r19; + unsigned long syscall_meta; + unsigned long syscall_saved_nr; int bpt_nsaved; unsigned long bpt_addr[2]; /* breakpoint handling */
@@ -50,6 +55,9 @@ register unsigned long *current_stack_pointer __asm__ ("$30");#define THREAD_SIZE_ORDER 1#define THREAD_SIZE (2*PAGE_SIZE) +#define ALPHA_SYSCALL_META_SKIP 0x2 +#define ALPHA_SYSCALL_META_FORCE_SUCCESS 0x4 +/* * Thread information flags: * - these are process state flags and used from assembly
@@ -68,6 +76,7 @@ register unsigned long *current_stack_pointer __asm__ ("$30");#define TIF_SECCOMP 6/* seccomp syscall filtering active */ #define TIF_SYSCALL_TRACEPOINT 7/* syscall tracepoint instrumentation */ #define TIF_DIE_IF_KERNEL 9/* dik recursion lock */ +#define TIF_UPROBE 10/* uprobe breakpoint or singlestep */ #define TIF_MEMDIE 13/* is terminating due to OOM killer */ #define TIF_POLLING_NRFLAG 14/* idle is polling for TIF_NEED_RESCHED */
@@ -80,22 +89,7 @@ register unsigned long *current_stack_pointer __asm__ ("$30");#define _TIF_SECCOMP (1<<TIF_SECCOMP)#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)#define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT) - -/* -* Work to do on syscall entry (in entry.S). -* If you want this to exactly mirror what entry.S checks, keep it aligned -* with the mask used before branching to syscall_trace_enter(). -*/ -#ifdef CONFIG_AUDITSYSCALL -# define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP \ - | _TIF_SYSCALL_TRACEPOINT) -#else -# define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT) -#endif - -/* Work to do on interrupt/exception return. */ -#define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \ - _TIF_NOTIFY_RESUME | _TIF_NOTIFY_SIGNAL) +#define _TIF_UPROBE (1 << TIF_UPROBE)#define TS_UAC_NOPRINT 0x0001/* ! Preserve the following three */ #define TS_UAC_NOFIX 0x0002/* ! flags as they match */
arch/alpha/kernel/asm-offsets.c +5 -0
@@ -22,6 +22,7 @@ static void __used foo(void)DEFINE (SP_OFF , offsetof(struct pt_regs , ps));DEFINE (SIZEOF_PT_REGS ,sizeof (struct pt_regs )); +DEFINE (TI_SYSCALL_META , offsetof(struct thread_info , syscall_meta));BLANK ();DEFINE (SWITCH_STACK_SIZE ,sizeof (struct switch_stack ));
@@ -30,4 +31,8 @@ static void __used foo(void)DEFINE (HAE_CACHE , offsetof(struct alpha_machine_vector , hae_cache));DEFINE (HAE_REG , offsetof(struct alpha_machine_vector , hae_register));DEFINE (PT_REGS_USP , offsetof(struct pt_regs , usp)); + +DEFINE (TI_FLAGS , offsetof(struct thread_info , flags)); +DEFINE (TI_SYSCALL_WORK , offsetof(struct thread_info , syscall_work)); +DEFINE (TI_STATUS , offsetof(struct thread_info , status)); }
arch/alpha/kernel/entry.S +87 -235
451 lines not on this page · raw message
arch/alpha/kernel/irq_alpha.c +9 -5
@@ -116,20 +116,24 @@ void notrace lockdep_on_restore(unsigned long ps, unsigned long ip) {#ifdef CONFIG_PROVE_LOCKING -/* Restoring IPL==7 means interrupts remain disabled. */ +/* +* If PAL_rti will restore IPL == 7, IRQs remain disabled. +* There is no hardirqs-on transition to annotate. +*/ if ((ps &7 ) ==7 )return ;/* -* If hardware IRQs are already enabled here, then emitting a -* hardirqs-on transition is redundant. +* This helper is meant to run before PAL_rti, after entry.S has +* forced IPL to 7. If IRQs are already enabled, do not emit a +* fake transition. */ if (!irqs_disabled ())return ;/* -* Only emit the transition if lockdep currently believes -* hardirqs are off. +* Only emit an ON transition if lockdep currently tracks hardirqs +* as off. */ if (lockdep_hardirqs_enabled ())return ;
arch/alpha/kernel/proto.h +6 -3
@@ -2,6 +2,7 @@#include <linux/interrupt.h> #include <linux/screen_info.h> #include <linux/io.h> +#include <asm/ptrace.h> /* Prototypes of functions used across modules here in this directory. */
@@ -164,16 +165,18 @@ extern void pcibios_claim_one_bus(struct pci_bus *);/* ptrace.c */ extern int ptrace_set_bpt (struct task_struct *child);extern int ptrace_cancel_bpt (struct task_struct *child); -extern void syscall_trace_leave (void ); -extern unsigned long syscall_trace_enter (void );/* signal.c */ struct sigcontext ;extern void do_sigreturn (struct sigcontext __user *);struct rt_sigframe ;extern void do_rt_sigreturn (struct rt_sigframe __user *); -extern void do_work_pending (struct pt_regs *,unsigned long ,unsigned long ,unsigned long );extern void alpha_schedule_user_work (void ); +extern void do_signal (struct pt_regs *regs,unsigned long r0,unsigned long r19); +extern void alpha_syscall_exit_to_user_mode (struct pt_regs *regs); +extern void alpha_exit_to_user_mode (struct pt_regs *regs); +extern void alpha_finish_syscall_to_user_mode (struct pt_regs *regs,long ret); +extern unsigned long alpha_syscall_enter_select (struct pt_regs *regs,long syscall);/* traps.c */ extern void dik_show_regs (struct pt_regs *regs,unsigned long *r9_15);
arch/alpha/kernel/ptrace.c +61 -69
196 lines not on this page · raw message
arch/alpha/kernel/signal.c +132 -32
208 lines not on this page · raw message
Signature · 1 line
2.53.0