[refactor] use enum to support level 3 and level 4 #27
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.
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
NestedPageTableenum tosrc/npt/mod.rsto 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.src/npt/arch/aarch64.rsto split intoA64HVPagingMetaDataL3andA64HVPagingMetaDataL4, each with appropriate constants for levels and address space bits.src/npt/arch/riscv.rsto provide both Sv39 and Sv48 metadata for multi-level support.API Changes and Error Handling
AddrSpace::new_emptysignature insrc/address_space/mod.rsto accept a page table level parameter, and updated internal logic to use the newNestedPageTableAPI. Test setup and root page table accessor were updated accordingly. [1] [2] [3]AxError,AxResult, and related error conversion logic insrc/address_space/mod.rsandsrc/lib.rs. [1] [2] [3]Minor Code Cleanups
unmapand streamlined frame allocation and remapping insrc/address_space/backend/alloc.rs). [1] [2]Cargo.tomlto0.2.0to 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.