feat(x86_64): upgrade dependencies, simplify initialization#26
feat(x86_64): upgrade dependencies, simplify initialization#26AsakuraMizu wants to merge 7 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the x86_64 CPU initialization and trap-handling plumbing by replacing custom GDT/IDT wrappers with x86_64 crate primitives, updating segment selector usage across user entry/syscall paths, and adjusting low-level trap metadata (error-code vectors and #PF flag parsing). Also updates dependencies to align with the new implementation choices.
Changes:
- Replace custom GDT/IDT structs and
lazyinitusage withx86_64::{GlobalDescriptorTable, InterruptDescriptorTable}plusspin::Lazy. - Update user-space context setup and syscall MSR configuration to use new
gdt::*selector constants. - Fix trap handling details (additional error-code vectors; allow
PROTECTION_VIOLATIONbit in #PF error code parsing) and adjust crate dependencies accordingly.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/x86_64/uspace.rs | Switch user CS/SS selectors to gdt::* constants. |
| src/x86_64/syscall.rs | Use gdt::* selectors when configuring STAR. |
| src/x86_64/trap.S | Treat additional exception vectors as having CPU-pushed error codes. |
| src/x86_64/trap.rs | Update reserved-bit filtering for page-fault error codes. |
| src/x86_64/gdt.rs | Replace custom GDT with GlobalDescriptorTable and define selector constants. |
| src/x86_64/idt.rs | Replace custom IDT with InterruptDescriptorTable initialized via spin::Lazy. |
| src/x86_64/init.rs | Simplify trap init flow; remove helper exports/functions. |
| src/x86_64/mod.rs | Stop re-exporting removed/now-internal x86_64 structs/types. |
| src/x86_64/context.rs | Replace static_assertions size check with a const assert!. |
| Cargo.toml | Update x86_64-target deps (percpu/spin) and adjust x86_64 features; remove static_assertions/lazyinit. |
| Cargo.lock | Reflect dependency upgrades/removals (percpu/spin; remove lazyinit/static_assertions). |
Comments suppressed due to low confidence (1)
src/x86_64/mod.rs:18
- The module no longer re-exports
GdtStruct,IdtStruct, andTaskStateSegment. Since these were public exports, removing them is a breaking API change for external users that may have depended onaxcpu::x86_64::{GdtStruct, IdtStruct, TaskStateSegment}. If the intent is to make these internal-only, consider providing a migration path (re-export replacements likegdt::{KCODE64,...}), or bumping the crate version to reflect the breaking change.
pub mod uspace;
pub use self::context::{ExtendedState, FxsaveArea, TaskContext, TrapFrame};
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| pub(super) fn init() { | ||
| let gdt = unsafe { GDT.current_ref_mut_raw() }; | ||
| assert_eq!(gdt.append(Descriptor::kernel_code_segment()), KCODE64); | ||
| assert_eq!(gdt.append(Descriptor::kernel_data_segment()), KDATA); | ||
| assert_eq!(gdt.append(Descriptor::user_data_segment()), UDATA); |
|
I think we should merge #16 and release v0.3.0 first, and then consider this PR. |
Tracking issue: #25
Description
All changes are related to x86_64:
static_assertionspercputo version 0.3lazyinitwithspintrap.sthat exceptions#CP(21)/#VC(29)/#SX(30) should have error code pushed on stack