File tree Expand file tree Collapse file tree 4 files changed +16
-7
lines changed Expand file tree Collapse file tree 4 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ pub fn load_x86(
4141 let page_table_base = load_info. next_available_address ;
4242 let mut page_table_work_buffer: Vec < page_table:: x64:: PageTable > =
4343 vec ! [ page_table:: x64:: PageTable :: new_zeroed( ) ; page_table:: x64:: PAGE_TABLE_MAX_COUNT ] ;
44- let mut page_tables: Vec < u8 > = vec ! [ 0 as u8 ; page_table:: x64:: PAGE_TABLE_MAX_BYTES ] ;
44+ let mut page_tables: Vec < u8 > = vec ! [ 0 ; page_table:: x64:: PAGE_TABLE_MAX_BYTES ] ;
4545 let page_table_builder = page_table:: x64:: IdentityMapBuilder :: new (
4646 page_table_base,
4747 page_table:: IdentityMapSize :: Size4Gb ,
@@ -56,7 +56,7 @@ pub fn load_x86(
5656 page_tables. len ( ) as u64 >> 12 ,
5757 "page_tables" ,
5858 loader:: importer:: BootPageAcceptance :: Exclusive ,
59- & page_tables,
59+ page_tables,
6060 )
6161 . context ( "failed to import page tables" ) ?;
6262
Original file line number Diff line number Diff line change @@ -713,6 +713,7 @@ mod tests {
713713 extern crate std;
714714
715715 use super :: * ;
716+ use std:: vec;
716717
717718 const DUMP_PAGE_TABLES : bool = false ;
718719
Original file line number Diff line number Diff line change @@ -15,9 +15,11 @@ use thiserror::Error;
1515/// Errors returned by the Page Table Builder
1616#[ derive( Debug , PartialEq , Eq , Error ) ]
1717pub enum Error {
18- /// The page table [u8] buffer does not match the size of the [PageTable] buffer
19- #[ error( "bad buffer size" ) ]
20- BadBufferSize ,
18+ /// The PageTableBuilder bytes buffer does not match the size of the struct buffer
19+ #[ error(
20+ "PageTableBuilder bytes buffer size [{bytes_buf}] does not match the struct buffer size [{struct_buf}]"
21+ ) ]
22+ BadBufferSize { bytes_buf : usize , struct_buf : usize } ,
2123}
2224
2325/// Size of the initial identity map
Original file line number Diff line number Diff line change @@ -348,7 +348,10 @@ impl PageTableBuilder {
348348 flattened_page_table : & ' a mut [ u8 ] ,
349349 ) -> Result < & ' a [ u8 ] , Error > {
350350 if flattened_page_table. len ( ) != ( page_table. len ( ) * PAGE_TABLE_SIZE ) {
351- return Err ( Error :: BadBufferSize ) ;
351+ return Err ( Error :: BadBufferSize {
352+ bytes_buf : flattened_page_table. len ( ) ,
353+ struct_buf : page_table. len ( ) * PAGE_TABLE_SIZE ,
354+ } ) ;
352355 }
353356
354357 const SIZE_512_GB : u64 = 0x8000000000 ;
@@ -546,7 +549,10 @@ impl IdentityMapBuilder {
546549 flattened_page_table : & ' a mut [ u8 ] ,
547550 ) -> Result < & ' a [ u8 ] , Error > {
548551 if flattened_page_table. len ( ) != ( page_table. len ( ) * PAGE_TABLE_SIZE ) {
549- return Err ( Error :: BadBufferSize ) ;
552+ return Err ( Error :: BadBufferSize {
553+ bytes_buf : flattened_page_table. len ( ) ,
554+ struct_buf : page_table. len ( ) * PAGE_TABLE_SIZE ,
555+ } ) ;
550556 }
551557 // Allocate page tables. There are up to 6 total page tables:
552558 // 1 PML4E (Level 4) (omitted if the address bias is non-zero)
You can’t perform that action at this time.
0 commit comments