Skip to content

Conversation

@ZR233
Copy link
Contributor

@ZR233 ZR233 commented Nov 13, 2025

This pull request introduces support for both 3-level and 4-level nested page tables, refactors type aliases and architecture-specific logic, and improves error handling and flexibility for address space management. The changes affect core page table abstractions, type definitions, and API signatures to enable multi-level paging across different architectures.

Multi-level Nested Page Table Support

  • Added NestedPageTable enum to src/npt/mod.rs to support both 3-level and 4-level page tables, with new type aliases (NestedPageTableL3, NestedPageTableL4) for architecture-specific configurations. The enum provides a unified API for creation, mapping, unmapping, region operations, protection, and queries.
  • Refactored AArch64 paging metadata in src/npt/arch/aarch64.rs to split into A64HVPagingMetaDataL3 and A64HVPagingMetaDataL4, each with appropriate constants for levels and address space bits.
  • Updated RISC-V paging exports in src/npt/arch/riscv.rs to provide both Sv39 and Sv48 metadata for multi-level support.

API Changes and Error Handling

  • Changed the AddrSpace::new_empty signature in src/address_space/mod.rs to accept a page table level parameter, and updated internal logic to use the new NestedPageTable API. Test setup and root page table accessor were updated accordingly. [1] [2] [3]
  • Improved error handling and result types by updating imports and exports of AxError, AxResult, and related error conversion logic in src/address_space/mod.rs and src/lib.rs. [1] [2] [3]

Minor Code Cleanups

  • Adjusted method signatures and tuple unpacking to match new APIs in mapping and unmapping logic (e.g., removed unused return values in unmap and streamlined frame allocation and remapping in src/address_space/backend/alloc.rs). [1] [2]
  • Updated the crate version in Cargo.toml to 0.2.0 to reflect these breaking and feature enhancements.

These changes collectively modernize the paging infrastructure, making it more flexible for future extension and supporting a wider range of guest address space configurations.

@ZR233 ZR233 requested a review from ZCShou November 13, 2025 08:32
@ZR233 ZR233 merged commit 21ab84b into master Nov 13, 2025
10 checks passed
@ZR233 ZR233 deleted the rewrite branch November 13, 2025 08:35
@ZR233 ZR233 linked an issue Nov 13, 2025 that may be closed by this pull request
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