arch/sh/kernel/signal_32.c
Source file repositories/reference/linux-study-clean/arch/sh/kernel/signal_32.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sh/kernel/signal_32.c- Extension
.c- Size
- 13606 bytes
- Lines
- 511
- Domain
- Architecture Layer
- Bucket
- arch/sh
- 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.
- 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/mm.hlinux/smp.hlinux/kernel.hlinux/signal.hlinux/errno.hlinux/wait.hlinux/ptrace.hlinux/unistd.hlinux/stddef.hlinux/tty.hlinux/elf.hlinux/personality.hlinux/binfmts.hlinux/io.hlinux/resume_user_mode.hasm/ucontext.hlinux/uaccess.hasm/cacheflush.hasm/syscalls.hasm/fpu.h
Detected Declarations
struct fdpic_func_descriptorstruct sigframestruct rt_sigframefunction restore_sigcontext_fpufunction save_sigcontext_fpufunction restore_sigcontextfunction sys_sigreturnfunction sys_rt_sigreturnfunction setup_sigcontextfunction get_sigframefunction setup_framefunction setup_rt_framefunction handle_syscall_restartfunction handle_signalfunction do_signalfunction do_notify_resume
Annotated Snippet
struct fdpic_func_descriptor {
unsigned long text;
unsigned long GOT;
};
/*
* The following define adds a 64 byte gap between the signal
* stack frame and previous contents of the stack. This allows
* frame unwinding in a function epilogue but only if a frame
* pointer is used in the function. This is necessary because
* current gcc compilers (<4.3) do not generate unwind info on
* SH for function epilogues.
*/
#define UNWINDGUARD 64
/*
* Do a signal return; undo the signal stack.
*/
#define MOVW(n) (0x9300|((n)-2)) /* Move mem word at PC+n to R3 */
#if defined(CONFIG_CPU_SH2)
#define TRAP_NOARG 0xc320 /* Syscall w/no args (NR in R3) */
#else
#define TRAP_NOARG 0xc310 /* Syscall w/no args (NR in R3) */
#endif
#define OR_R0_R0 0x200b /* or r0,r0 (insert to avoid hardware bug) */
struct sigframe
{
struct sigcontext sc;
unsigned long extramask[_NSIG_WORDS-1];
u16 retcode[8];
};
struct rt_sigframe
{
struct siginfo info;
struct ucontext uc;
u16 retcode[8];
};
#ifdef CONFIG_SH_FPU
static inline int restore_sigcontext_fpu(struct sigcontext __user *sc)
{
struct task_struct *tsk = current;
if (!(boot_cpu_data.flags & CPU_HAS_FPU))
return 0;
set_used_math();
return __copy_from_user(&tsk->thread.xstate->hardfpu, &sc->sc_fpregs[0],
sizeof(long)*(16*2+2));
}
static inline int save_sigcontext_fpu(struct sigcontext __user *sc,
struct pt_regs *regs)
{
struct task_struct *tsk = current;
if (!(boot_cpu_data.flags & CPU_HAS_FPU))
return 0;
if (!used_math())
return __put_user(0, &sc->sc_ownedfp);
if (__put_user(1, &sc->sc_ownedfp))
return -EFAULT;
/* This will cause a "finit" to be triggered by the next
attempted FPU operation by the 'current' process.
*/
clear_used_math();
unlazy_fpu(tsk, regs);
return __copy_to_user(&sc->sc_fpregs[0], &tsk->thread.xstate->hardfpu,
sizeof(long)*(16*2+2));
}
#endif /* CONFIG_SH_FPU */
static int
restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *r0_p)
{
unsigned int err = 0;
unsigned int sr = regs->sr & ~SR_USER_MASK;
#define COPY(x) err |= __get_user(regs->x, &sc->sc_##x)
COPY(regs[1]);
COPY(regs[2]); COPY(regs[3]);
COPY(regs[4]); COPY(regs[5]);
COPY(regs[6]); COPY(regs[7]);
Annotation
- Immediate include surface: `linux/sched.h`, `linux/sched/task_stack.h`, `linux/mm.h`, `linux/smp.h`, `linux/kernel.h`, `linux/signal.h`, `linux/errno.h`, `linux/wait.h`.
- Detected declarations: `struct fdpic_func_descriptor`, `struct sigframe`, `struct rt_sigframe`, `function restore_sigcontext_fpu`, `function save_sigcontext_fpu`, `function restore_sigcontext`, `function sys_sigreturn`, `function sys_rt_sigreturn`, `function setup_sigcontext`, `function get_sigframe`.
- Atlas domain: Architecture Layer / arch/sh.
- Implementation status: source 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.