arch/s390/kernel/signal.c
Source file repositories/reference/linux-study-clean/arch/s390/kernel/signal.c
File Facts
- System
- Linux kernel
- Corpus path
arch/s390/kernel/signal.c- Extension
.c- Size
- 15045 bytes
- Lines
- 513
- Domain
- Architecture Layer
- Bucket
- arch/s390
- Inferred role
- Architecture Layer: syscall or user/kernel boundary
- Status
- core implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or participates in a user/kernel boundary; inspect argument validation, copy_from_user/copy_to_user, credentials, and dispatch target.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/sched.hlinux/sched/task_stack.hlinux/rseq.hlinux/mm.hlinux/smp.hlinux/kernel.hlinux/signal.hlinux/entry-common.hlinux/errno.hlinux/wait.hlinux/ptrace.hlinux/unistd.hlinux/stddef.hlinux/tty.hlinux/personality.hlinux/binfmts.hlinux/syscalls.hasm/ucontext.hlinux/uaccess.hasm/vdso-symbols.hasm/access-regs.hasm/lowcore.hentry.h
Detected Declarations
syscall sigreturnsyscall rt_sigreturnstruct sigframestruct rt_sigframefunction store_sigregsfunction load_sigregsfunction save_sigregsfunction restore_sigregsfunction save_sigregs_extfunction restore_sigregs_extfunction get_sigframefunction setup_framefunction setup_rt_framefunction handle_signalfunction arch_do_signal_or_restart
Annotated Snippet
SYSCALL_DEFINE0(sigreturn)
{
struct pt_regs *regs = task_pt_regs(current);
struct sigframe __user *frame =
(struct sigframe __user *) regs->gprs[15];
sigset_t set;
if (__copy_from_user(&set.sig, &frame->sc.oldmask, _SIGMASK_COPY_SIZE))
goto badframe;
set_current_blocked(&set);
save_user_fpu_regs();
if (restore_sigregs(regs, &frame->sregs))
goto badframe;
if (restore_sigregs_ext(regs, &frame->sregs_ext))
goto badframe;
load_sigregs();
return regs->gprs[2];
badframe:
force_sig(SIGSEGV);
return 0;
}
SYSCALL_DEFINE0(rt_sigreturn)
{
struct pt_regs *regs = task_pt_regs(current);
struct rt_sigframe __user *frame =
(struct rt_sigframe __user *)regs->gprs[15];
sigset_t set;
if (__copy_from_user(&set.sig, &frame->uc.uc_sigmask, sizeof(set)))
goto badframe;
set_current_blocked(&set);
if (restore_altstack(&frame->uc.uc_stack))
goto badframe;
save_user_fpu_regs();
if (restore_sigregs(regs, &frame->uc.uc_mcontext))
goto badframe;
if (restore_sigregs_ext(regs, &frame->uc.uc_mcontext_ext))
goto badframe;
load_sigregs();
return regs->gprs[2];
badframe:
force_sig(SIGSEGV);
return 0;
}
/*
* Determine which stack to use..
*/
static inline void __user *
get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size)
{
unsigned long sp;
/* Default to using normal stack */
sp = regs->gprs[15];
/* Overflow on alternate signal stack gives SIGSEGV. */
if (on_sig_stack(sp) && !on_sig_stack((sp - frame_size) & -8UL))
return (void __user *) -1UL;
/* This is the X/Open sanctioned signal stack switching. */
if (ka->sa.sa_flags & SA_ONSTACK) {
if (! sas_ss_flags(sp))
sp = current->sas_ss_sp + current->sas_ss_size;
}
return (void __user *)((sp - frame_size) & -8ul);
}
static int setup_frame(int sig, struct k_sigaction *ka,
sigset_t *set, struct pt_regs * regs)
{
struct sigframe __user *frame;
struct sigcontext sc;
unsigned long restorer;
size_t frame_size;
frame_size = sizeof(*frame) - sizeof(frame->sregs_ext);
if (cpu_has_vx())
frame_size += sizeof(frame->sregs_ext);
frame = get_sigframe(ka, regs, frame_size);
if (frame == (void __user *) -1UL)
return -EFAULT;
/* Set up backchain. */
if (__put_user(regs->gprs[15], (addr_t __user *) frame))
return -EFAULT;
/* Create struct sigcontext on the signal stack */
Annotation
- Immediate include surface: `linux/sched.h`, `linux/sched/task_stack.h`, `linux/rseq.h`, `linux/mm.h`, `linux/smp.h`, `linux/kernel.h`, `linux/signal.h`, `linux/entry-common.h`.
- Detected declarations: `syscall sigreturn`, `syscall rt_sigreturn`, `struct sigframe`, `struct rt_sigframe`, `function store_sigregs`, `function load_sigregs`, `function save_sigregs`, `function restore_sigregs`, `function save_sigregs_ext`, `function restore_sigregs_ext`.
- Atlas domain: Architecture Layer / arch/s390.
- Implementation status: core implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.