@@ -364,7 +364,7 @@ static int get_table_entry(void *addr, void *table_base,
364
364
return 0 ;
365
365
}
366
366
367
- static void * walk_paging_struct (void * addr , void * table_base ,
367
+ static void * walk_paging_struct (void * addr , void * table_base ,
368
368
uint32_t table_level , struct map_params * map_params )
369
369
{
370
370
uint32_t table_offset ;
@@ -373,14 +373,13 @@ static void *walk_paging_struct(void *addr, void *table_base,
373
373
/* if table_level == IA32E_PT Just return the same address
374
374
* can't walk down any further
375
375
*/
376
- void * sub_table_addr = ((table_level == IA32E_PT ) ? table_base :NULL );
377
- int status = 0 ;
376
+ void * sub_table_addr = (table_level == IA32E_PT ) ? table_base : NULL ;
378
377
379
378
if (table_base == NULL || table_level >= IA32E_UNKNOWN
380
379
|| map_params == NULL ) {
381
- status = - EINVAL ;
380
+ ASSERT (0 , "Incorrect Arguments" );
381
+ return NULL ;
382
382
}
383
- ASSERT (status == 0 , "Incorrect Arguments" );
384
383
385
384
table_offset = fetch_page_table_offset (addr , table_level );
386
385
@@ -404,18 +403,16 @@ static void *walk_paging_struct(void *addr, void *table_base,
404
403
/* Determine if a valid entry exists */
405
404
if ((table_entry & table_present ) == 0 ) {
406
405
/* No entry present - need to allocate a new table */
407
- sub_table_addr =
408
- alloc_paging_struct ();
406
+ sub_table_addr = alloc_paging_struct ();
409
407
/* Check to ensure memory available for this structure*/
410
- if (sub_table_addr == 0 ) {
408
+ if (sub_table_addr == NULL ) {
411
409
/* Error: Unable to find table memory necessary
412
410
* to map memory
413
411
*/
414
- ASSERT (sub_table_addr == 0 ,
415
- "Fail to find table memory "
412
+ ASSERT (0 , "Fail to alloc table memory "
416
413
"for map memory" );
417
414
418
- return sub_table_addr ;
415
+ return NULL ;
419
416
}
420
417
421
418
/* Write entry to current table to reference the new
@@ -712,6 +709,8 @@ static uint64_t update_page_table_entry(struct map_params *map_params,
712
709
/* Walk from the PML4 table to the PDPT table */
713
710
table_addr = walk_paging_struct (vaddr , table_addr , IA32E_PML4 ,
714
711
map_params );
712
+ if (table_addr == NULL )
713
+ return 0 ;
715
714
716
715
if ((remaining_size >= MEM_1G )
717
716
&& (MEM_ALIGNED_CHECK (vaddr , MEM_1G ))
@@ -727,6 +726,8 @@ static uint64_t update_page_table_entry(struct map_params *map_params,
727
726
/* Walk from the PDPT table to the PD table */
728
727
table_addr = walk_paging_struct (vaddr , table_addr ,
729
728
IA32E_PDPT , map_params );
729
+ if (table_addr == NULL )
730
+ return 0 ;
730
731
/* Map this 2 MByte memory region */
731
732
adjustment_size = map_mem_region (vaddr , paddr ,
732
733
table_addr , attr , IA32E_PD , table_type ,
@@ -735,17 +736,20 @@ static uint64_t update_page_table_entry(struct map_params *map_params,
735
736
/* Walk from the PDPT table to the PD table */
736
737
table_addr = walk_paging_struct (vaddr ,
737
738
table_addr , IA32E_PDPT , map_params );
739
+ if (table_addr == NULL )
740
+ return 0 ;
738
741
/* Walk from the PD table to the page table */
739
742
table_addr = walk_paging_struct (vaddr ,
740
743
table_addr , IA32E_PD , map_params );
744
+ if (table_addr == NULL )
745
+ return 0 ;
741
746
/* Map this 4 KByte memory region */
742
747
adjustment_size = map_mem_region (vaddr , paddr ,
743
748
table_addr , attr , IA32E_PT ,
744
749
table_type , request_type );
745
750
}
746
751
747
752
return adjustment_size ;
748
-
749
753
}
750
754
751
755
static uint64_t break_page_table (struct map_params * map_params , void * paddr ,
@@ -918,6 +922,8 @@ static int modify_paging(struct map_params *map_params, void *paddr,
918
922
/* The function return the memory size that one entry can map */
919
923
adjust_size = update_page_table_entry (map_params , paddr , vaddr ,
920
924
page_size , attr , request_type , direct );
925
+ if (adjust_size == 0 )
926
+ return - EINVAL ;
921
927
vaddr += adjust_size ;
922
928
paddr += adjust_size ;
923
929
remaining_size -= adjust_size ;
0 commit comments