Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5287,7 +5287,6 @@ name = "page_table"
version = "0.0.0"
dependencies = [
"bitfield-struct 0.11.0",
"tracing",
"zerocopy 0.8.25",
]

Expand Down
2 changes: 1 addition & 1 deletion vm/loader/manifests/openhcl-x64-cvm-dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@
}
}
]
}
}
1 change: 0 additions & 1 deletion vm/loader/page_table/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ rust-version.workspace = true

[dependencies]
bitfield-struct.workspace = true
tracing.workspace = true
zerocopy.workspace = true
[lints]
workspace = true
23 changes: 5 additions & 18 deletions vm/loader/page_table/src/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,6 @@ impl<'a> Arm64PageTableSpace<'a> {
debug_assert!(aligned(phys_table_start, Arm64PageSize::Small));
debug_assert!(index < PAGE_SIZE_4K as usize / size_of::<Arm64PageTableEntry>());

tracing::debug!(
"Writing page table entry {entry:#016x}, index {index:#x}, table {phys_table_start:#x}"
);

let pos = phys_table_start as usize - self.phys_page_table_root
+ index * size_of::<Arm64PageTableEntry>();
self.space[pos..pos + 8].copy_from_slice(&entry.to_le_bytes());
Expand Down Expand Up @@ -677,13 +673,13 @@ impl<'a> Arm64PageTableSpace<'a> {
}

/// Build a set of Aarch64 page tables identity mapping the given region.
pub fn build_identity_page_tables_aarch64(
pub fn build_identity_page_tables_aarch64<'a>(
page_table_gpa: u64,
start_gpa: u64,
size: u64,
memory_attribute_indirection: MemoryAttributeIndirectionEl1,
page_table_region_size: usize,
) -> Vec<u8> {
page_table_space: &'a mut [u8],
) -> &'a [u8] {
// start_gpa and size must be 2MB aligned.
if !aligned(start_gpa, Arm64PageSize::Large) {
panic!("start_gpa not 2mb aligned");
Expand All @@ -693,13 +689,8 @@ pub fn build_identity_page_tables_aarch64(
panic!("size not 2mb aligned");
}

tracing::debug!(
"Creating Aarch64 page tables at {page_table_gpa:#x} mapping starting at {start_gpa:#x} of size {size} bytes"
);

let mut page_table_space = vec![0; page_table_region_size];
let mut page_tables =
Arm64PageTableSpace::new(page_table_gpa as usize, &mut page_table_space).unwrap();
Arm64PageTableSpace::new(page_table_gpa as usize, page_table_space).unwrap();
page_tables
.map_range(
start_gpa,
Expand All @@ -713,12 +704,8 @@ pub fn build_identity_page_tables_aarch64(
.unwrap();

let used_space = page_tables.used_space();
tracing::debug!("Page tables use {used_space} bytes");
tracing::debug!("Page tables stats by level: {:?}", page_tables.lvl_stats());

page_table_space.truncate(used_space);

page_table_space
&page_table_space[0..used_space]
}

#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions vm/loader/page_table/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

//! Methods to construct page tables.

#![no_std]
#![expect(missing_docs)]
#![forbid(unsafe_code)]

Expand Down
Loading