From 0c5956beb104a8ff3a6bb5edabde1bca4f039115 Mon Sep 17 00:00:00 2001 From: lijinxia Date: Wed, 9 May 2018 10:28:17 +0000 Subject: [PATCH] Revert "HV: adjust the base address of guest initial page tables" This reverts commit 4aab1ea80d1cbf66007a2d9e7c33cebf4451fca8. --- hypervisor/arch/x86/guest/guest.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/hypervisor/arch/x86/guest/guest.c b/hypervisor/arch/x86/guest/guest.c index 6a265a8cc..59bc93d87 100644 --- a/hypervisor/arch/x86/guest/guest.c +++ b/hypervisor/arch/x86/guest/guest.c @@ -420,28 +420,24 @@ uint64_t e820_alloc_low_memory(uint32_t size) * after guest realmode/32bit no paging mode got supported. ******************************************************************/ #define GUEST_INIT_PAGE_TABLE_SKIP_SIZE 0x8000UL +#define GUEST_INIT_PAGE_TABLE_START (CONFIG_LOW_RAM_START + \ + GUEST_INIT_PAGE_TABLE_SKIP_SIZE) #define GUEST_INIT_PT_PAGE_NUM 7 #define RSDP_F_ADDR 0xE0000 -extern uint64_t trampoline_code_paddr; uint64_t create_guest_initial_paging(struct vm *vm) { uint64_t i = 0; uint64_t entry = 0; uint64_t entry_num = 0; - uint64_t base_paddr; uint64_t pdpt_base_paddr = 0; uint64_t pd_base_paddr = 0; uint64_t table_present = 0; uint64_t table_offset = 0; void *addr = NULL; - void *pml4_addr; + void *pml4_addr = GPA2HVA(vm, GUEST_INIT_PAGE_TABLE_START); - base_paddr = trampoline_code_paddr + GUEST_INIT_PAGE_TABLE_SKIP_SIZE; - pml4_addr = GPA2HVA(vm, base_paddr); - - if ((base_paddr + 7 * PAGE_SIZE_4K) > RSDP_F_ADDR) { - pr_fatal("RSDP fix segment could be override by guest page tables: %llx", base_paddr); - } + _Static_assert((GUEST_INIT_PAGE_TABLE_START + 7 * PAGE_SIZE_4K) < + RSDP_F_ADDR, "RSDP fix segment could be override"); if (GUEST_INIT_PAGE_TABLE_SKIP_SIZE < (unsigned long)&_ld_cpu_secondary_reset_size) { @@ -457,7 +453,7 @@ uint64_t create_guest_initial_paging(struct vm *vm) /* Write PML4E */ table_present = (IA32E_COMM_P_BIT | IA32E_COMM_RW_BIT); /* PML4 used 1 page, skip it to fetch PDPT */ - pdpt_base_paddr = base_paddr + PAGE_SIZE_4K; + pdpt_base_paddr = GUEST_INIT_PAGE_TABLE_START + PAGE_SIZE_4K; entry = pdpt_base_paddr | table_present; MEM_WRITE64(pml4_addr, entry); @@ -495,7 +491,8 @@ uint64_t create_guest_initial_paging(struct vm *vm) memset(pml4_addr + 6 * PAGE_SIZE_4K, 0, PAGE_SIZE_4K); /* Write PDPTE for trusy memory, PD will use 7th page */ - pd_base_paddr = base_paddr + (6 * PAGE_SIZE_4K); + pd_base_paddr = GUEST_INIT_PAGE_TABLE_START + + (6 * PAGE_SIZE_4K); table_offset = IA32E_PDPTE_INDEX_CALC(TRUSTY_EPT_REBASE_GPA); addr = (pml4_addr + PAGE_SIZE_4K + table_offset); @@ -518,5 +515,5 @@ uint64_t create_guest_initial_paging(struct vm *vm) } } - return base_paddr; + return GUEST_INIT_PAGE_TABLE_START; }