Skip to content

Conversation

@kov
Copy link
Owner

@kov kov commented Jan 1, 2026

Implements restart_syscall and kexec_load from Batch 11 (Legacy & Misc).

restart_syscall:

  • Kernel-internal syscall for resuming interrupted syscalls
  • Takes no arguments
  • Returns 0 on success

kexec_load:

  • Load new kernel for execution (kexec mechanism)
  • Arguments: entry point, nr_segments, segments pointer, flags
  • Flags include KEXEC_ON_CRASH, KEXEC_PRESERVE_CONTEXT, and architecture constants (KEXEC_ARCH_X86_64, KEXEC_ARCH_AARCH64, etc.)
  • Added kexec_constants module with all flag definitions from linux/include/uapi/linux/kexec.h
  • Created format_kexec_load_flags() helper for pretty-printing flags
  • Returns 0 on success

Added 4 pretty printing tests covering both syscalls and various flag combinations.

🤖 Generated with Claude Code

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for two system management syscalls: restart_syscall and kexec_load. The restart_syscall is a simple kernel-internal syscall with no arguments, while kexec_load is more complex, handling kernel loading with memory segments and various flags including architecture-specific constants. The implementation includes comprehensive flag formatting with support for multiple architectures, segment parsing in the eBPF handler, and 4 tests covering different scenarios.

Key Changes

  • Added restart_syscall syscall support (no arguments)
  • Added kexec_load syscall with full argument parsing including segments array and flags
  • Created kexec_constants module with KEXEC flags and architecture constants
  • Implemented format_kexec_load_flags() helper for pretty-printing flags

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pinchy/src/tests/system.rs Added 4 tests covering restart_syscall and kexec_load with various flag combinations and segment parsing
pinchy/src/server.rs Registered both syscalls in the SYSTEM_SYSCALLS array for the system handler
pinchy/src/format_helpers.rs Added kexec_constants module and format_kexec_load_flags() function, plus return value formatting
pinchy/src/events.rs Added parsing logic for both syscalls, with detailed segment array formatting for kexec_load
pinchy-ebpf/src/system.rs Added eBPF handlers for both syscalls, including segment reading logic for kexec_load
pinchy-common/src/lib.rs Added RestartSyscallData and KexecLoadData structures to the union
pinchy-common/src/kernel_types.rs Added KexecSegment struct and KEXEC_SEGMENT_ARRAY_CAP constant

Implements restart_syscall and kexec_load

restart_syscall:
- Kernel-internal syscall for resuming interrupted syscalls
- Takes no arguments
- Returns 0 on success

kexec_load:
- Load new kernel for execution (kexec mechanism)
- Arguments: entry point, nr_segments, segments pointer, flags
- Flags include KEXEC_ON_CRASH, KEXEC_PRESERVE_CONTEXT, and architecture
  constants (KEXEC_ARCH_X86_64, KEXEC_ARCH_AARCH64, etc.)
- Added kexec_constants module with all flag definitions from
  linux/include/uapi/linux/kexec.h
- Created format_kexec_load_flags() helper for pretty-printing flags
- Returns 0 on success

Added 4 pretty printing tests covering both syscalls and various flag
combinations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@kov kov merged commit e633b21 into main Jan 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants