arch/xtensa/kernel/signal.c
Source file repositories/reference/linux-study-clean/arch/xtensa/kernel/signal.c
File Facts
- System
- Linux kernel
- Corpus path
arch/xtensa/kernel/signal.c- Extension
.c- Size
- 13156 bytes
- Lines
- 536
- Domain
- Architecture Layer
- Bucket
- arch/xtensa
- 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/signal.hlinux/errno.hlinux/ptrace.hlinux/personality.hlinux/resume_user_mode.hlinux/sched/task_stack.hasm/ucontext.hlinux/uaccess.hasm/cacheflush.hasm/coprocessor.hasm/processor.hasm/syscall.hasm/unistd.h
Detected Declarations
struct rt_sigframefunction flush_window_regs_userfunction flush_window_regs_userfunction setup_sigcontextfunction restore_sigcontextfunction xtensa_rt_sigreturnfunction gen_return_codefunction setup_framefunction do_signalfunction do_notify_resume
Annotated Snippet
if (m & 2) { /* call4 */
inc = 1;
} else if (m & 4) { /* call8 */
if (copy_to_user(&SPILL_SLOT_CALL8(sp, 4),
®s->areg[(base + 1) * 4], 16))
goto errout;
inc = 2;
} else if (m & 8) { /* call12 */
if (copy_to_user(&SPILL_SLOT_CALL12(sp, 4),
®s->areg[(base + 1) * 4], 32))
goto errout;
inc = 3;
}
/* Save current frame a0..a3 under next SP */
sp = regs->areg[((base + inc) * 4 + 1) % XCHAL_NUM_AREGS];
if (copy_to_user(&SPILL_SLOT(sp, 0), ®s->areg[base * 4], 16))
goto errout;
/* Get current stack pointer for next loop iteration. */
sp = regs->areg[base * 4 + 1];
base += inc;
}
regs->wmask = 1;
regs->windowstart = 1 << wb;
return 0;
errout:
return err;
}
#else
static int
flush_window_regs_user(struct pt_regs *regs)
{
return 0;
}
#endif
/*
* Note: We don't copy double exception 'regs', we have to finish double exc.
* first before we return to signal handler! This dbl.exc.handler might cause
* another double exception, but I think we are fine as the situation is the
* same as if we had returned to the signal handerl and got an interrupt
* immediately...
*/
static int
setup_sigcontext(struct rt_sigframe __user *frame, struct pt_regs *regs)
{
struct sigcontext __user *sc = &frame->uc.uc_mcontext;
struct thread_info *ti = current_thread_info();
int err = 0;
#define COPY(x) err |= __put_user(regs->x, &sc->sc_##x)
COPY(pc);
COPY(ps);
COPY(lbeg);
COPY(lend);
COPY(lcount);
COPY(sar);
#undef COPY
err |= flush_window_regs_user(regs);
err |= __copy_to_user (sc->sc_a, regs->areg, 16 * 4);
err |= __put_user(0, &sc->sc_xtregs);
if (err)
return err;
#if XTENSA_HAVE_COPROCESSORS
coprocessor_flush_release_all(ti);
err |= __copy_to_user(&frame->xtregs.cp, &ti->xtregs_cp,
sizeof (frame->xtregs.cp));
#endif
err |= __copy_to_user(&frame->xtregs.opt, ®s->xtregs_opt,
sizeof (xtregs_opt_t));
err |= __copy_to_user(&frame->xtregs.user, &ti->xtregs_user,
sizeof (xtregs_user_t));
err |= __put_user(err ? NULL : &frame->xtregs, &sc->sc_xtregs);
return err;
}
Annotation
- Immediate include surface: `linux/signal.h`, `linux/errno.h`, `linux/ptrace.h`, `linux/personality.h`, `linux/resume_user_mode.h`, `linux/sched/task_stack.h`, `asm/ucontext.h`, `linux/uaccess.h`.
- Detected declarations: `struct rt_sigframe`, `function flush_window_regs_user`, `function flush_window_regs_user`, `function setup_sigcontext`, `function restore_sigcontext`, `function xtensa_rt_sigreturn`, `function gen_return_code`, `function setup_frame`, `function do_signal`, `function do_notify_resume`.
- Atlas domain: Architecture Layer / arch/xtensa.
- 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.