Add support for non-contiguous physical page mapping#666
Add support for non-contiguous physical page mapping#666
Conversation
debb8fe to
2ed4daf
Compare
wdcui
left a comment
There was a problem hiding this comment.
Over the code looks good to me. I left some comments below.
| &mut inner, | ||
| Page::range_inclusive( | ||
| start_page, | ||
| start_page + (mapped_count as u64 - 1), |
There was a problem hiding this comment.
rollback_mapped_pages internally calls x86_64 crate's clean_up_addr_range which expects an inclusive range. we can use an exclusive range for rollback_mapped_pages if that is intuitive.
| && FLUSH_TLB | ||
| { | ||
| fl.flush(); | ||
| } |
There was a problem hiding this comment.
Should we log the error at least?
There was a problem hiding this comment.
You mean whether we rollbacked mappings? We can log the error, but rollback_mapped_pages is already within an error path.
| /// | ||
| /// Returns `Some(VirtAddr)` with the starting virtual address on success, | ||
| /// or `None` if insufficient virtual address space is available. | ||
| fn allocate_va_range(&mut self, num_pages: usize) -> Option<VirtAddr> { |
There was a problem hiding this comment.
Do we need to support address alignment?
There was a problem hiding this comment.
Functions in this module are called through vmap which has type-based strict alignment requirement.
litebox_platform_lvbs/src/mm/vmap.rs
Outdated
|
|
||
| // Try to find a suitable range in the free set (first-fit) | ||
| for range in self.free_set.iter() { | ||
| if range.end - range.start >= size { |
There was a problem hiding this comment.
Here the range's size is measured by bytes, and other places a va range is measured by pages. It's a little confusing.
There was a problem hiding this comment.
make sense. let me see whether I can change it.
| } | ||
| } | ||
|
|
||
| if ALIGN != PAGE_SIZE { |
There was a problem hiding this comment.
Nit: check alignment before the more expensive loop?
litebox_platform_lvbs/src/mm/vmap.rs
Outdated
| /// Start of the vmap virtual address region. | ||
| /// This address is chosen to be within the 4-level paging canonical address space | ||
| /// and not conflict with VTL1's direct-mapped physical memory. | ||
| const VMAP_START: u64 = 0x6000_0000_0000; |
There was a problem hiding this comment.
How do we prevent the page table code from using this va range?
There was a problem hiding this comment.
By default, we do use a global offset when we map physical page frames. Unless our target machine has an extreme amount of memory, there are no overlap. We can add extra check to the normal map function if needed.
ad76dac to
4d06a28
Compare
2e1da17 to
5ccdbae
Compare
5ccdbae to
5407404
Compare
5407404 to
c4e288d
Compare
|
🤖 SemverChecks 🤖 Click for details |
This PR introduces a vmap subsystem to the LVBS platform to map non-contiguous physical page frames into virtually contiguous addresses.
Changes
map_non_contiguous_phys_frameswhich is similar to existingmap_phys_frame_rangeexcept that this new function is for non-contiguous physical page frames.mm/vmap.rs)