@@ -420,28 +420,24 @@ uint64_t e820_alloc_low_memory(uint32_t size)
420
420
* after guest realmode/32bit no paging mode got supported.
421
421
******************************************************************/
422
422
#define GUEST_INIT_PAGE_TABLE_SKIP_SIZE 0x8000UL
423
+ #define GUEST_INIT_PAGE_TABLE_START (CONFIG_LOW_RAM_START + \
424
+ GUEST_INIT_PAGE_TABLE_SKIP_SIZE)
423
425
#define GUEST_INIT_PT_PAGE_NUM 7
424
426
#define RSDP_F_ADDR 0xE0000
425
- extern uint64_t trampoline_code_paddr ;
426
427
uint64_t create_guest_initial_paging (struct vm * vm )
427
428
{
428
429
uint64_t i = 0 ;
429
430
uint64_t entry = 0 ;
430
431
uint64_t entry_num = 0 ;
431
- uint64_t base_paddr ;
432
432
uint64_t pdpt_base_paddr = 0 ;
433
433
uint64_t pd_base_paddr = 0 ;
434
434
uint64_t table_present = 0 ;
435
435
uint64_t table_offset = 0 ;
436
436
void * addr = NULL ;
437
- void * pml4_addr ;
437
+ void * pml4_addr = GPA2HVA ( vm , GUEST_INIT_PAGE_TABLE_START ) ;
438
438
439
- base_paddr = trampoline_code_paddr + GUEST_INIT_PAGE_TABLE_SKIP_SIZE ;
440
- pml4_addr = GPA2HVA (vm , base_paddr );
441
-
442
- if ((base_paddr + 7 * PAGE_SIZE_4K ) > RSDP_F_ADDR ) {
443
- pr_fatal ("RSDP fix segment could be override by guest page tables: %llx" , base_paddr );
444
- }
439
+ _Static_assert ((GUEST_INIT_PAGE_TABLE_START + 7 * PAGE_SIZE_4K ) <
440
+ RSDP_F_ADDR , "RSDP fix segment could be override" );
445
441
446
442
if (GUEST_INIT_PAGE_TABLE_SKIP_SIZE <
447
443
(unsigned long )& _ld_cpu_secondary_reset_size ) {
@@ -457,7 +453,7 @@ uint64_t create_guest_initial_paging(struct vm *vm)
457
453
/* Write PML4E */
458
454
table_present = (IA32E_COMM_P_BIT | IA32E_COMM_RW_BIT );
459
455
/* PML4 used 1 page, skip it to fetch PDPT */
460
- pdpt_base_paddr = base_paddr + PAGE_SIZE_4K ;
456
+ pdpt_base_paddr = GUEST_INIT_PAGE_TABLE_START + PAGE_SIZE_4K ;
461
457
entry = pdpt_base_paddr | table_present ;
462
458
MEM_WRITE64 (pml4_addr , entry );
463
459
@@ -495,7 +491,8 @@ uint64_t create_guest_initial_paging(struct vm *vm)
495
491
memset (pml4_addr + 6 * PAGE_SIZE_4K , 0 , PAGE_SIZE_4K );
496
492
497
493
/* Write PDPTE for trusy memory, PD will use 7th page */
498
- pd_base_paddr = base_paddr + (6 * PAGE_SIZE_4K );
494
+ pd_base_paddr = GUEST_INIT_PAGE_TABLE_START +
495
+ (6 * PAGE_SIZE_4K );
499
496
table_offset =
500
497
IA32E_PDPTE_INDEX_CALC (TRUSTY_EPT_REBASE_GPA );
501
498
addr = (pml4_addr + PAGE_SIZE_4K + table_offset );
@@ -518,5 +515,5 @@ uint64_t create_guest_initial_paging(struct vm *vm)
518
515
}
519
516
}
520
517
521
- return base_paddr ;
518
+ return GUEST_INIT_PAGE_TABLE_START ;
522
519
}
0 commit comments