Repository navigation
refactor(kernel): decouple process/cpu arch boundary and unify TrapFrame/PerCpu/Context - #13
Merged
Merged
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…:switch_from(from).to(to)
…/park_current_process
…ld VM/stack activation
…d stable PCB address
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.
Summary
PerCpu(%gs) & CleanGDT/TSS:arch::x86_64::percpu::PerCpubound toKernelGsBase(kernel_rsp,user_rsp_scratch,user_cs,user_ss), replacing hardcodedTSSbyte offsets (0x4,0x1c), hardcoded segment selectors (0x1b,0x23), and redundantpush_kernel_stack/pop_kernel_stackTSS scratch-slot shuffling withoffset_of!(PerCpu, ...)andarch::set_kernel_stack.TrapFrame& Pure Callee-SavedContext:arch/x86_64/macros.rs(#[repr(packed)] SyscallStackFrame) and the separateInterruptStackFrameValuebootstrap path with a single#[repr(C)] TrapFrame+trap_returntrampoline (arch/x86_64/trapframe.rs) shared across initial Ring 3 entry andsyscallexit.Context(arch/x86_64/context.rs) down to pure kernel callee-saved registers (rsp, r15, r14, r13, r12, rbp, rbx), delegating address space switching toAddressSpace::activate()/paging::activate_kernel_page_table().KernelStack& Safe User Memory Operations:KernelStack(16 KiB stack + 4 KiB unmapped guard page, recycled onDrop) andAddressSpace::{map_user_range, copy_to_user, write_user_u64}inarch/x86_64/paging.rs.Process/Cpu/SchedulerOwnership & Zero Aliasing&mutUB:x86_64/gdtleaks andsyscall::processreverse dependencies fromprocess.rsandcpu.rs, eliminatedmy_cpu() -> &'static mut Cpu/my_proc() -> &'static mut Processaliasing&mutUB, removed fakeimpl Clone for Processand bootdbg!noise, and wired up a cleanRUN_QUEUEround-robinscheduler(enqueue,run,yield_now,exit_current).Verification
cargo checkpasses cleanly for bothframe-allocator-bitmapandframe-allocator-buddywith zero warnings./initshell (SYS_YIELD,SYS_GETPID,mknod,open,read,write, canonical TTY backspace editing) in QEMU under bothdebugandreleaseprofiles.