arch/arm64/kernel/signal.c
Source file repositories/reference/linux-study-clean/arch/arm64/kernel/signal.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/kernel/signal.c- Extension
.c- Size
- 44022 bytes
- Lines
- 1761
- Domain
- Architecture Layer
- Bucket
- arch/arm64
- 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/cache.hlinux/compat.hlinux/errno.hlinux/irq-entry-common.hlinux/kernel.hlinux/signal.hlinux/freezer.hlinux/stddef.hlinux/uaccess.hlinux/sizes.hlinux/string.hlinux/ratelimit.hlinux/rseq.hlinux/syscalls.hlinux/pkeys.hasm/daifflags.hasm/debug-monitors.hasm/elf.hasm/exception.hasm/cacheflush.hasm/gcs.hasm/ucontext.hasm/unistd.hasm/fpsimd.hasm/ptrace.hasm/syscall.hasm/signal32.hasm/traps.hasm/vdso.h
Detected Declarations
syscall rt_sigreturnstruct rt_sigframestruct rt_sigframe_user_layoutstruct user_access_statestruct user_ctxsfunction set_ua_state_por_el0function get_ua_state_por_el0function save_reset_user_access_statefunction set_handler_user_access_statefunction restore_user_access_statefunction init_user_layoutfunction sigframe_sizefunction __sigframe_allocfunction sigframe_allocfunction sigframe_alloc_endfunction preserve_fpsimd_contextfunction read_fpsimd_contextfunction restore_fpsimd_contextfunction preserve_fpmr_contextfunction restore_fpmr_contextfunction preserve_poe_contextfunction restore_poe_contextfunction preserve_sve_contextfunction restore_sve_fpsimd_contextfunction restore_sve_fpsimd_contextfunction preserve_tpidr2_contextfunction restore_tpidr2_contextfunction preserve_za_contextfunction restore_za_contextfunction preserve_zt_contextfunction restore_zt_contextfunction preserve_gcs_contextfunction restore_gcs_contextfunction parse_user_sigframefunction restore_sigframefunction gcs_restore_signalfunction gcs_restore_signalfunction setup_sigframe_layoutfunction setup_sigframefunction get_sigframefunction gcs_signal_entryfunction gcs_signal_entryfunction setup_returnfunction afunction setup_rt_framefunction setup_restart_syscallfunction handle_signalfunction arch_do_signal_or_restart
Annotated Snippet
SYSCALL_DEFINE0(rt_sigreturn)
{
struct pt_regs *regs = current_pt_regs();
struct rt_sigframe __user *frame;
struct user_access_state ua_state = {};
/* Always make any pending restarted system calls return -EINTR */
current->restart_block.fn = do_no_restart_syscall;
/*
* Since we stacked the signal on a 128-bit boundary, then 'sp' should
* be word aligned here.
*/
if (regs->sp & 15)
goto badframe;
frame = (struct rt_sigframe __user *)regs->sp;
if (!access_ok(frame, sizeof (*frame)))
goto badframe;
if (restore_sigframe(regs, frame, &ua_state))
goto badframe;
if (gcs_restore_signal())
goto badframe;
if (restore_altstack(&frame->uc.uc_stack))
goto badframe;
restore_user_access_state(&ua_state);
return regs->regs[0];
badframe:
arm64_notify_segfault(regs->sp);
return 0;
}
/*
* Determine the layout of optional records in the signal frame
*
* add_all: if true, lays out the biggest possible signal frame for
* this task; otherwise, generates a layout for the current state
* of the task.
*/
static int setup_sigframe_layout(struct rt_sigframe_user_layout *user,
bool add_all)
{
int err;
if (system_supports_fpsimd()) {
err = sigframe_alloc(user, &user->fpsimd_offset,
sizeof(struct fpsimd_context));
if (err)
return err;
}
/* fault information, if valid */
if (add_all || current->thread.fault_code) {
err = sigframe_alloc(user, &user->esr_offset,
sizeof(struct esr_context));
if (err)
return err;
}
#ifdef CONFIG_ARM64_GCS
if (system_supports_gcs() && (add_all || current->thread.gcspr_el0)) {
err = sigframe_alloc(user, &user->gcs_offset,
sizeof(struct gcs_context));
if (err)
return err;
}
#endif
if (system_supports_sve() || system_supports_sme()) {
unsigned int vq = 0;
if (add_all || current->thread.fp_type == FP_STATE_SVE ||
thread_sm_enabled(¤t->thread)) {
int vl = max(sve_max_vl(), sme_max_vl());
if (!add_all)
vl = thread_get_cur_vl(¤t->thread);
vq = sve_vq_from_vl(vl);
}
err = sigframe_alloc(user, &user->sve_offset,
SVE_SIG_CONTEXT_SIZE(vq));
Annotation
- Immediate include surface: `linux/cache.h`, `linux/compat.h`, `linux/errno.h`, `linux/irq-entry-common.h`, `linux/kernel.h`, `linux/signal.h`, `linux/freezer.h`, `linux/stddef.h`.
- Detected declarations: `syscall rt_sigreturn`, `struct rt_sigframe`, `struct rt_sigframe_user_layout`, `struct user_access_state`, `struct user_ctxs`, `function set_ua_state_por_el0`, `function get_ua_state_por_el0`, `function save_reset_user_access_state`, `function set_handler_user_access_state`, `function restore_user_access_state`.
- Atlas domain: Architecture Layer / arch/arm64.
- 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.