33
44//! Methods to construct page tables on Aarch64.
55
6+ use crate :: PageTableBuffer ;
67use bitfield_struct:: bitfield;
78
9+ //TODO(babayet2) nonsensical
10+ pub const MAX_PAGE_TABLE_REGION_SIZE : usize = 1024 * 1024 ;
11+
812/// Some memory attributes. Refer to the ARM VMSA
913/// manual for further details and other types.
1014#[ derive( Debug , PartialEq , Eq , Clone , Copy , Default ) ]
@@ -437,10 +441,6 @@ impl<'a> Arm64PageTableSpace<'a> {
437441 debug_assert ! ( aligned( phys_table_start, Arm64PageSize :: Small ) ) ;
438442 debug_assert ! ( index < PAGE_SIZE_4K as usize / size_of:: <Arm64PageTableEntry >( ) ) ;
439443
440- tracing:: debug!(
441- "Writing page table entry {entry:#016x}, index {index:#x}, table {phys_table_start:#x}"
442- ) ;
443-
444444 let pos = phys_table_start as usize - self . phys_page_table_root
445445 + index * size_of :: < Arm64PageTableEntry > ( ) ;
446446 self . space [ pos..pos + 8 ] . copy_from_slice ( & entry. to_le_bytes ( ) ) ;
@@ -677,13 +677,16 @@ impl<'a> Arm64PageTableSpace<'a> {
677677}
678678
679679/// Build a set of Aarch64 page tables identity mapping the given region.
680- pub fn build_identity_page_tables_aarch64 (
680+ pub fn build_identity_page_tables_aarch64 < P > (
681681 page_table_gpa : u64 ,
682682 start_gpa : u64 ,
683683 size : u64 ,
684684 memory_attribute_indirection : MemoryAttributeIndirectionEl1 ,
685685 page_table_region_size : usize ,
686- ) -> Vec < u8 > {
686+ page_table_space : & mut P ,
687+ ) where
688+ P : PageTableBuffer < Element = u8 > ,
689+ {
687690 // start_gpa and size must be 2MB aligned.
688691 if !aligned ( start_gpa, Arm64PageSize :: Large ) {
689692 panic ! ( "start_gpa not 2mb aligned" ) ;
@@ -693,13 +696,12 @@ pub fn build_identity_page_tables_aarch64(
693696 panic ! ( "size not 2mb aligned" ) ;
694697 }
695698
696- tracing :: debug! (
697- "Creating Aarch64 page tables at {page_table_gpa:#x} mapping starting at {start_gpa:#x} of size {size} bytes"
698- ) ;
699+ for _ in 0 ..page_table_region_size {
700+ page_table_space . push ( 0 ) ;
701+ }
699702
700- let mut page_table_space = vec ! [ 0 ; page_table_region_size] ;
701703 let mut page_tables =
702- Arm64PageTableSpace :: new ( page_table_gpa as usize , & mut page_table_space) . unwrap ( ) ;
704+ Arm64PageTableSpace :: new ( page_table_gpa as usize , page_table_space. as_mut_slice ( ) ) . unwrap ( ) ;
703705 page_tables
704706 . map_range (
705707 start_gpa,
@@ -713,12 +715,8 @@ pub fn build_identity_page_tables_aarch64(
713715 . unwrap ( ) ;
714716
715717 let used_space = page_tables. used_space ( ) ;
716- tracing:: debug!( "Page tables use {used_space} bytes" ) ;
717- tracing:: debug!( "Page tables stats by level: {:?}" , page_tables. lvl_stats( ) ) ;
718718
719719 page_table_space. truncate ( used_space) ;
720-
721- page_table_space
722720}
723721
724722#[ cfg( test) ]
0 commit comments