Skip to content

Commit

Permalink
Fixed invalid virtual address in kernel_heap_end
Browse files Browse the repository at this point in the history
  • Loading branch information
jounathaen committed Nov 13, 2024
1 parent 990eed4 commit 4a66746
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/arch/x86_64/mm/virtualmem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn init() {
} else {
PageRange::new(
mm::kernel_end_address().as_usize(),
kernel_heap_end().as_usize(),
kernel_heap_end().as_usize() + 1,
)
.unwrap()
};
Expand Down Expand Up @@ -89,8 +89,8 @@ pub fn allocate_aligned(size: usize, align: usize) -> Result<VirtAddr, AllocErro

pub fn deallocate(virtual_address: VirtAddr, size: usize) {
assert!(
virtual_address < kernel_heap_end(),
"Virtual address {virtual_address:p} is not < kernel_heap_end()"
virtual_address <= kernel_heap_end(),
"Virtual address {virtual_address:p} is not <= kernel_heap_end()"
);
assert!(
virtual_address.is_aligned_to(BasePageSize::SIZE),
Expand Down Expand Up @@ -121,8 +121,8 @@ pub fn deallocate(virtual_address: VirtAddr, size: usize) {
virtual_address
);
assert!(
virtual_address < kernel_heap_end(),
"Virtual address {:#X} is not < kernel_heap_end()",
virtual_address <= kernel_heap_end(),
"Virtual address {:#X} is not <= kernel_heap_end()",
virtual_address
);
assert_eq!(
Expand Down Expand Up @@ -161,8 +161,9 @@ pub fn print_information() {
/// This also marks the start of the virtual memory address space reserved for the task heap.
#[cfg(not(feature = "common-os"))]
#[inline]
/// Returns the last valid address for the heap
pub const fn kernel_heap_end() -> VirtAddr {
VirtAddr::new(0x8000_0000_0000u64)
VirtAddr::new(0x7FFF_FFFF_FFFFu64)
}

#[cfg(feature = "common-os")]
Expand Down

0 comments on commit 4a66746

Please sign in to comment.