File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ impl UsedLevel4Entries {
137137 /// Marks all p4 entries in the range `[address..address+size)` as used.
138138 fn mark_range_as_used ( & mut self , address : u64 , size : u64 ) {
139139 let start = VirtAddr :: new ( address) ;
140- let end_inclusive = ( start + size) - 1 ;
140+ let end_inclusive = start + ( size - 1 ) ;
141141 let start_page = Page :: < Size4KiB > :: containing_address ( start) ;
142142 let end_page_inclusive = Page :: < Size4KiB > :: containing_address ( end_inclusive) ;
143143
Original file line number Diff line number Diff line change @@ -504,12 +504,15 @@ where
504504 fn remove_copied_flags ( & mut self , elf_file : & ElfFile ) -> Result < ( ) , & ' static str > {
505505 for program_header in elf_file. program_iter ( ) {
506506 if let Type :: Load = program_header. get_type ( ) ? {
507+ if program_header. mem_size ( ) == 0 {
508+ continue ;
509+ }
507510 let start = self . virtual_address_offset + program_header. virtual_addr ( ) ;
508- let end = start + program_header. mem_size ( ) ;
511+ let end = start + ( program_header. mem_size ( ) - 1 ) ;
509512 let start = VirtAddr :: new ( start) ;
510513 let end = VirtAddr :: new ( end) ;
511514 let start_page = Page :: containing_address ( start) ;
512- let end_page = Page :: containing_address ( end - 1u64 ) ;
515+ let end_page = Page :: containing_address ( end) ;
513516 for page in Page :: < Size4KiB > :: range_inclusive ( start_page, end_page) {
514517 // Translate the page and get the flags.
515518 let res = self . page_table . translate ( page. start_address ( ) ) ;
You can’t perform that action at this time.
0 commit comments