Skip to content

feat(x86_64): upgrade dependencies, simplify initialization#26

Open
AsakuraMizu wants to merge 7 commits intomainfrom
pr/x86_64-cleanup
Open

feat(x86_64): upgrade dependencies, simplify initialization#26
AsakuraMizu wants to merge 7 commits intomainfrom
pr/x86_64-cleanup

Conversation

@AsakuraMizu
Copy link
Copy Markdown
Contributor

@AsakuraMizu AsakuraMizu commented Mar 15, 2026

Tracking issue: #25

Description

All changes are related to x86_64:

  1. Remove static_assertions
  2. Upgrade percpu to version 0.3
  3. Replace lazyinit with spin
  4. Simplify initialization code (GDT, IDT)
  5. Remove PROTECTION_VIOLATION from page fault reserved error code
  6. Fix in trap.s that exceptions #CP(21)/#VC(29)/#SX(30) should have error code pushed on stack

Copy link
Copy Markdown
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

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 lazyinit usage with x86_64::{GlobalDescriptorTable, InterruptDescriptorTable} plus spin::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_VIOLATION bit 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, and TaskStateSegment. Since these were public exports, removing them is a breaking API change for external users that may have depended on axcpu::x86_64::{GdtStruct, IdtStruct, TaskStateSegment}. If the intent is to make these internal-only, consider providing a migration path (re-export replacements like gdt::{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.

Comment on lines +29 to +33
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);
@equation314
Copy link
Copy Markdown
Member

I think we should merge #16 and release v0.3.0 first, and then consider this PR.

@AsakuraMizu
Copy link
Copy Markdown
Contributor Author

I think we should merge #16 and release v0.3.0 first, and then consider this PR.

OK, so shall we set #25 as the "milestone" of 0.4.0?

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.

3 participants