arch/um/os-Linux/skas/process.c
Source file repositories/reference/linux-study-clean/arch/um/os-Linux/skas/process.c
File Facts
- System
- Linux kernel
- Corpus path
arch/um/os-Linux/skas/process.c- Extension
.c- Size
- 22067 bytes
- Lines
- 909
- Domain
- Architecture Layer
- Bucket
- arch/um
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdlib.hstdbool.hunistd.hsched.herrno.hstring.hfcntl.hmem_user.hsys/mman.hsys/wait.hsys/stat.hsys/socket.hasm/unistd.has-layout.hinit.hkern_util.hmem.hos.hptrace_user.hregisters.hskas.hsysdep/stub.hsysdep/mcontext.hlinux/futex.hlinux/threads.htimetravel.hasm-generic/rwonce.h../internal.h
Detected Declarations
struct tramp_datafunction Copyrightfunction ptrace_dump_regsfunction wait_stub_donefunction wait_stub_done_seccompfunction get_skas_faultinfofunction handle_trapfunction userspace_trampfunction init_stub_exe_fdfunction start_userspacefunction userspacefunction bookkeepingfunction new_threadfunction switch_threadsfunction start_idle_threadfunction initial_thread_cb_skasfunction halt_skasfunction noreboot_cmd_paramfunction reboot_skas
Annotated Snippet
struct tramp_data {
struct stub_data *stub_data;
/* 0 is inherited, 1 is the kernel side */
int sockpair[2];
};
#ifndef CLOSE_RANGE_CLOEXEC
#define CLOSE_RANGE_CLOEXEC (1U << 2)
#endif
static int userspace_tramp(void *data)
{
struct tramp_data *tramp_data = data;
char *const argv[] = { "uml-userspace", NULL };
unsigned long long offset;
struct stub_init_data init_data = {
.seccomp = using_seccomp,
.stub_start = STUB_START,
};
int ret;
if (using_seccomp) {
init_data.signal_handler = STUB_CODE +
(unsigned long) stub_signal_interrupt -
(unsigned long) __syscall_stub_start;
init_data.signal_restorer = STUB_CODE +
(unsigned long) stub_signal_restorer -
(unsigned long) __syscall_stub_start;
} else {
init_data.signal_handler = STUB_CODE +
(unsigned long) stub_segv_handler -
(unsigned long) __syscall_stub_start;
init_data.signal_restorer = 0;
}
init_data.stub_code_fd = phys_mapping(uml_to_phys(__syscall_stub_start),
&offset);
init_data.stub_code_offset = MMAP_OFFSET(offset);
init_data.stub_data_fd = phys_mapping(uml_to_phys(tramp_data->stub_data),
&offset);
init_data.stub_data_offset = MMAP_OFFSET(offset);
/*
* Avoid leaking unneeded FDs to the stub by setting CLOEXEC on all FDs
* and then unsetting it on all memory related FDs.
* This is not strictly necessary from a safety perspective.
*/
syscall(__NR_close_range, 0, ~0U, CLOSE_RANGE_CLOEXEC);
fcntl(init_data.stub_data_fd, F_SETFD, 0);
/* dup2 signaling FD/socket to STDIN */
if (dup2(tramp_data->sockpair[0], 0) < 0)
exit(3);
close(tramp_data->sockpair[0]);
/* Write init_data and close write side */
ret = write(tramp_data->sockpair[1], &init_data, sizeof(init_data));
close(tramp_data->sockpair[1]);
if (ret != sizeof(init_data))
exit(4);
/* Raw execveat for compatibility with older libc versions */
syscall(__NR_execveat, stub_exe_fd, (unsigned long)"",
(unsigned long)argv, NULL, AT_EMPTY_PATH);
exit(5);
}
extern char stub_exe_start[];
extern char stub_exe_end[];
extern char *tempdir;
#define STUB_EXE_NAME_TEMPLATE "/uml-userspace-XXXXXX"
#ifndef MFD_EXEC
#define MFD_EXEC 0x0010U
#endif
static int __init init_stub_exe_fd(void)
{
size_t written = 0;
char *tmpfile = NULL;
stub_exe_fd = memfd_create("uml-userspace",
MFD_EXEC | MFD_CLOEXEC | MFD_ALLOW_SEALING);
Annotation
- Immediate include surface: `stdlib.h`, `stdbool.h`, `unistd.h`, `sched.h`, `errno.h`, `string.h`, `fcntl.h`, `mem_user.h`.
- Detected declarations: `struct tramp_data`, `function Copyright`, `function ptrace_dump_regs`, `function wait_stub_done`, `function wait_stub_done_seccomp`, `function get_skas_faultinfo`, `function handle_trap`, `function userspace_tramp`, `function init_stub_exe_fd`, `function start_userspace`.
- Atlas domain: Architecture Layer / arch/um.
- 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.