Skip to content

Commit 0c5956b

Browse files
lijinxiajren1
authored andcommitted
Revert "HV: adjust the base address of guest initial page tables"
This reverts commit 4aab1ea.
1 parent 6de5b04 commit 0c5956b

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

hypervisor/arch/x86/guest/guest.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -420,28 +420,24 @@ uint64_t e820_alloc_low_memory(uint32_t size)
420420
* after guest realmode/32bit no paging mode got supported.
421421
******************************************************************/
422422
#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)
423425
#define GUEST_INIT_PT_PAGE_NUM 7
424426
#define RSDP_F_ADDR 0xE0000
425-
extern uint64_t trampoline_code_paddr;
426427
uint64_t create_guest_initial_paging(struct vm *vm)
427428
{
428429
uint64_t i = 0;
429430
uint64_t entry = 0;
430431
uint64_t entry_num = 0;
431-
uint64_t base_paddr;
432432
uint64_t pdpt_base_paddr = 0;
433433
uint64_t pd_base_paddr = 0;
434434
uint64_t table_present = 0;
435435
uint64_t table_offset = 0;
436436
void *addr = NULL;
437-
void *pml4_addr;
437+
void *pml4_addr = GPA2HVA(vm, GUEST_INIT_PAGE_TABLE_START);
438438

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");
445441

446442
if (GUEST_INIT_PAGE_TABLE_SKIP_SIZE <
447443
(unsigned long)&_ld_cpu_secondary_reset_size) {
@@ -457,7 +453,7 @@ uint64_t create_guest_initial_paging(struct vm *vm)
457453
/* Write PML4E */
458454
table_present = (IA32E_COMM_P_BIT | IA32E_COMM_RW_BIT);
459455
/* 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;
461457
entry = pdpt_base_paddr | table_present;
462458
MEM_WRITE64(pml4_addr, entry);
463459

@@ -495,7 +491,8 @@ uint64_t create_guest_initial_paging(struct vm *vm)
495491
memset(pml4_addr + 6 * PAGE_SIZE_4K, 0, PAGE_SIZE_4K);
496492

497493
/* 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);
499496
table_offset =
500497
IA32E_PDPTE_INDEX_CALC(TRUSTY_EPT_REBASE_GPA);
501498
addr = (pml4_addr + PAGE_SIZE_4K + table_offset);
@@ -518,5 +515,5 @@ uint64_t create_guest_initial_paging(struct vm *vm)
518515
}
519516
}
520517

521-
return base_paddr;
518+
return GUEST_INIT_PAGE_TABLE_START;
522519
}

0 commit comments

Comments
 (0)