Add userland syscall resume path and tty input flush on exec - #37
Merged
pradosh-arduino merged 2 commits intoApr 2, 2026
Merged
Conversation
pradosh-arduino
deleted the
codex/fix-os-userland-return-crash-and-tty-buffer-issue
branch
April 2, 2026 12:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
execdoes not inherit stale TTY input by flushing cooked input before launching a new userland program.rsp0to improve isolation of kernel-side syscall handling while userland is running.Description
tty_flush_input()prototype insource/includes/tty.hand implemented it insource/kernel/C/user-input/tty.cto clear the cooked ring buffer and reset the current line buffer length.source/kernel/C/shell/commands/exec.cto includetty.hand calltty_flush_input()before invokinguserland_exec()so the new process starts with a clean input state.source/kernel/C/interrupts/syscalls-x86_64.asmto check theuserland_should_return_kernelflag and, if set, load saved non-volatile registers andrsp/ripfromuserland_resume_*variables and jump to the saved kernel resume address instead of performingiretqback to userland.source/kernel/C/userland.cto add theuserland_should_return_kernelflag,userland_resume_*register save areas, a dedicateduserland_syscall_stack, and logic to save current kernel registers andrspinto the resume slots before entering userland, switchkernel_stack_topandtss.rsp0to the syscall stack while userland is running, and restore them on return;userland_prepare_exit()now signals the kernel resume via the flag rather than mutating a provided frame.Testing
make, which completed successfully.make test/ CI job that covers userlandexecworkflow), and the tests passed successfully and reported expected userland exec/exit behavior.Codex Task