tools/testing/selftests/kexec/test_kexec_jump.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kexec/test_kexec_jump.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kexec/test_kexec_jump.c- Extension
.c- Size
- 1475 bytes
- Lines
- 73
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
unistd.herrno.hstdio.hstdlib.hlinux/kexec.hlinux/reboot.hsys/reboot.hsys/syscall.h
Detected Declarations
function main
Annotated Snippet
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <linux/kexec.h>
#include <linux/reboot.h>
#include <sys/reboot.h>
#include <sys/syscall.h>
asm(
" .code64\n"
" .data\n"
"purgatory_start:\n"
// Trigger kexec debug exception handling
" int3\n"
// Set load address for next time
" leaq purgatory_start_b(%rip), %r11\n"
" movq %r11, 8(%rsp)\n"
// Back to Linux
" ret\n"
// Same again
"purgatory_start_b:\n"
// Trigger kexec debug exception handling
" int3\n"
// Set load address for next time
" leaq purgatory_start(%rip), %r11\n"
" movq %r11, 8(%rsp)\n"
// Back to Linux
" ret\n"
"purgatory_end:\n"
".previous"
);
extern char purgatory_start[], purgatory_end[];
int main (void)
{
struct kexec_segment segment = {};
int ret;
segment.buf = purgatory_start;
segment.bufsz = purgatory_end - purgatory_start;
segment.mem = (void *)0x400000;
segment.memsz = 0x1000;
ret = syscall(__NR_kexec_load, 0x400000, 1, &segment, KEXEC_PRESERVE_CONTEXT);
if (ret) {
perror("kexec_load");
exit(1);
}
ret = syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_KEXEC);
if (ret) {
perror("kexec reboot");
exit(1);
}
ret = syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_KEXEC);
if (ret) {
perror("kexec reboot");
exit(1);
}
printf("Success\n");
return 0;
}
Annotation
- Immediate include surface: `unistd.h`, `errno.h`, `stdio.h`, `stdlib.h`, `linux/kexec.h`, `linux/reboot.h`, `sys/reboot.h`, `sys/syscall.h`.
- Detected declarations: `function main`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.