arch/x86/kernel/signal.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/signal.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/signal.c- Extension
.c- Size
- 12387 bytes
- Lines
- 440
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: implementation source
- Status
- source 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 uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/sched.hlinux/sched/task_stack.hlinux/mm.hlinux/smp.hlinux/kernel.hlinux/kstrtox.hlinux/errno.hlinux/wait.hlinux/unistd.hlinux/stddef.hlinux/personality.hlinux/uaccess.hlinux/user-return-notifier.hlinux/uprobes.hlinux/context_tracking.hlinux/entry-common.hlinux/syscalls.hlinux/rseq.hasm/processor.hasm/ucontext.hasm/fpu/signal.hasm/fpu/xstate.hasm/vdso.hasm/mce.hasm/sighandling.hasm/vm86.hasm/syscall.hasm/sigframe.hasm/signal.hasm/shstk.h
Detected Declarations
function Copyrightfunction is_ia32_framefunction is_x32_framefunction fpu__clear_user_statesfunction get_sigframefunction sas_ss_flagsfunction init_sigframe_sizefunction get_sigframe_sizefunction setup_rt_framefunction handle_signalfunction get_nr_restart_syscallfunction arch_do_signal_or_restartfunction signal_faultfunction strict_sas_sizefunction sigaltstack_size_valid
Annotated Snippet
if (sas_ss_flags(sp) == 0) {
sp = current->sas_ss_sp + current->sas_ss_size;
entering_altstack = true;
}
} else if (ia32_frame &&
!nested_altstack &&
regs->ss != __USER_DS &&
!(ka->sa.sa_flags & SA_RESTORER) &&
ka->sa.sa_restorer) {
/* This is the legacy signal stack switching. */
sp = (unsigned long) ka->sa.sa_restorer;
entering_altstack = true;
}
sp = fpu__alloc_mathframe(sp, ia32_frame, &buf_fx, &math_size);
*fpstate = (void __user *)sp;
sp -= frame_size;
if (ia32_frame)
/*
* Align the stack pointer according to the i386 ABI,
* i.e. so that on function entry ((sp + 4) & 15) == 0.
*/
sp = ((sp + 4) & -FRAME_ALIGNMENT) - 4;
else
sp = round_down(sp, FRAME_ALIGNMENT) - 8;
/*
* If we are on the alternate signal stack and would overflow it, don't.
* Return an always-bogus address instead so we will die with SIGSEGV.
*/
if (unlikely((nested_altstack || entering_altstack) &&
!__on_sig_stack(sp))) {
if (show_unhandled_signals && printk_ratelimit())
pr_info("%s[%d] overflowed sigaltstack\n",
current->comm, task_pid_nr(current));
return (void __user *)-1L;
}
/* Update PKRU to enable access to the alternate signal stack. */
pkru = sig_prepare_pkru();
/* save i387 and extended state */
if (!copy_fpstate_to_sigframe(*fpstate, (void __user *)buf_fx, math_size, pkru)) {
/*
* Restore PKRU to the original, user-defined value; disable
* extra pkeys enabled for the alternate signal stack, if any.
*/
write_pkru(pkru);
return (void __user *)-1L;
}
return (void __user *)sp;
}
/*
* There are four different struct types for signal frame: sigframe_ia32,
* rt_sigframe_ia32, rt_sigframe_x32, and rt_sigframe. Use the worst case
* -- the largest size. It means the size for 64-bit apps is a bit more
* than needed, but this keeps the code simple.
*/
#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
# define MAX_FRAME_SIGINFO_UCTXT_SIZE sizeof(struct sigframe_ia32)
#else
# define MAX_FRAME_SIGINFO_UCTXT_SIZE sizeof(struct rt_sigframe)
#endif
/*
* The FP state frame contains an XSAVE buffer which must be 64-byte aligned.
* If a signal frame starts at an unaligned address, extra space is required.
* This is the max alignment padding, conservatively.
*/
#define MAX_XSAVE_PADDING 63UL
/*
* The frame data is composed of the following areas and laid out as:
*
* -------------------------
* | alignment padding |
* -------------------------
* | (f)xsave frame |
* -------------------------
* | fsave header |
* -------------------------
* | alignment padding |
* -------------------------
* | siginfo + ucontext |
* -------------------------
Annotation
- Immediate include surface: `linux/sched.h`, `linux/sched/task_stack.h`, `linux/mm.h`, `linux/smp.h`, `linux/kernel.h`, `linux/kstrtox.h`, `linux/errno.h`, `linux/wait.h`.
- Detected declarations: `function Copyright`, `function is_ia32_frame`, `function is_x32_frame`, `function fpu__clear_user_states`, `function get_sigframe`, `function sas_ss_flags`, `function init_sigframe_size`, `function get_sigframe_size`, `function setup_rt_frame`, `function handle_signal`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: source implementation candidate.
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.