diff --git a/hypervisor/arch/x86/Kconfig b/hypervisor/arch/x86/Kconfig index 292754a4f..0cbdff92a 100644 --- a/hypervisor/arch/x86/Kconfig +++ b/hypervisor/arch/x86/Kconfig @@ -74,15 +74,9 @@ config MEM_LOGLEVEL_DEFAULT int "Default loglevel in memory" default 4 -config LOW_RAM_START - hex "Address of the beginning of low RAM region" - default 0x00001000 if PLATFORM_SBL - default 0x00008000 if PLATFORM_UEFI - config LOW_RAM_SIZE hex "Size of the low RAM region" - default 0x000cf000 if PLATFORM_SBL - default 0x00010000 if PLATFORM_UEFI + default 0x00010000 config RAM_START hex "Address of the RAM region assigned to the hypervisor" diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index d61d439ae..9bfe54948 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -26,6 +26,8 @@ volatile uint32_t up_count = 0; /* physical cpu active bitmap, support up to 64 cpus */ uint64_t pcpu_active_bitmap = 0; +uint64_t trampline_start16_paddr; + /* TODO: add more capability per requirement */ /*APICv features*/ #define VAPIC_FEATURE_VIRT_ACCESS (1 << 0) diff --git a/hypervisor/arch/x86/guest/guest.c b/hypervisor/arch/x86/guest/guest.c index 8329d5f55..998eacde8 100644 --- a/hypervisor/arch/x86/guest/guest.c +++ b/hypervisor/arch/x86/guest/guest.c @@ -674,9 +674,8 @@ uint64_t e820_alloc_low_memory(uint32_t size) * This API assume that the trusty memory is remapped to guest physical address * of 511G to 511G + 16MB * - * FIXME: here using hard code GUEST_INIT_PAGE_TABLE_START as guest init page - * table gpa start, and it will occupy at most GUEST_INIT_PT_PAGE_NUM pages. - * Some check here: + * FIXME: here the guest init page table will occupy at most + * GUEST_INIT_PT_PAGE_NUM pages. Some check here: * - guest page table space should not override trampline code area * (it's a little tricky here, as under current identical mapping, HV & SOS * share same memory under 1M; under uefi boot mode, the defered AP startup @@ -688,7 +687,7 @@ 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 + \ +#define GUEST_INIT_PAGE_TABLE_START (trampline_start16_paddr + \ GUEST_INIT_PAGE_TABLE_SKIP_SIZE) #define GUEST_INIT_PT_PAGE_NUM 7 #define RSDP_F_ADDR 0xE0000 @@ -794,7 +793,7 @@ uint64_t create_guest_initial_paging(struct vm *vm) ******************************************************************/ #define GUEST_INIT_GDT_SKIP_SIZE 0x8000UL -#define GUEST_INIT_GDT_START (CONFIG_LOW_RAM_START + \ +#define GUEST_INIT_GDT_START (trampline_start16_paddr + \ GUEST_INIT_GDT_SKIP_SIZE) /* The GDT defined below compatible with linux kernel */ diff --git a/hypervisor/bsp/sbl/include/bsp/bsp_cfg.h b/hypervisor/bsp/sbl/include/bsp/bsp_cfg.h index c9399415c..d7cc67c18 100644 --- a/hypervisor/bsp/sbl/include/bsp/bsp_cfg.h +++ b/hypervisor/bsp/sbl/include/bsp/bsp_cfg.h @@ -17,8 +17,7 @@ #define HEAP_SIZE 0x100000 #define CONSOLE_LOGLEVEL_DEFAULT 3 #define MEM_LOGLEVEL_DEFAULT 5 -#define CONFIG_LOW_RAM_START 0x00001000 -#define CONFIG_LOW_RAM_SIZE 0x000CF000 +#define CONFIG_LOW_RAM_SIZE 0x00010000 #define CONFIG_RAM_START 0x6E000000 #define CONFIG_RAM_SIZE 0x02000000 /* 32M */ #define CONFIG_MTRR_ENABLED 1 diff --git a/hypervisor/bsp/uefi/efi/boot.c b/hypervisor/bsp/uefi/efi/boot.c index e4ffe3f3c..b9ffd93b4 100644 --- a/hypervisor/bsp/uefi/efi/boot.c +++ b/hypervisor/bsp/uefi/efi/boot.c @@ -190,12 +190,6 @@ again: mmap[j].mm_type = E820_RAM; j++; - /* reserve secondary memory region(0x1000 ~ 0x10000) for hv */ - err = __emalloc(CONFIG_LOW_RAM_SIZE, CONFIG_LOW_RAM_START, - &addr, EfiReservedMemoryType); - if (err != EFI_SUCCESS) - goto out; - mbi->mi_flags |= MULTIBOOT_INFO_HAS_MMAP | MULTIBOOT_INFO_HAS_CMDLINE; mbi->mi_mmap_length = j*sizeof(struct multiboot_mmap); @@ -227,6 +221,13 @@ switch_to_guest_mode(EFI_HANDLE image) efi_ctx = (struct efi_ctx *)(UINTN)addr; + /* reserve secondary memory region for hv */ + err = emalloc_for_low_mem(&addr, CONFIG_LOW_RAM_SIZE); + if (err != EFI_SUCCESS) + goto out; + + efi_ctx->ap_trampline_buf = (void *)addr; + config_table = sys_table->ConfigurationTable; for (i = 0; i < sys_table->NumberOfTableEntries; i++) { diff --git a/hypervisor/bsp/uefi/efi/boot.h b/hypervisor/bsp/uefi/efi/boot.h index abd307a59..e223ee3f9 100644 --- a/hypervisor/bsp/uefi/efi/boot.h +++ b/hypervisor/bsp/uefi/efi/boot.h @@ -95,6 +95,7 @@ struct e820_entry { struct efi_ctx { uint64_t rip; VOID *rsdp; + VOID *ap_trampline_buf; dt_addr_t gdt; dt_addr_t idt; uint16_t tr_sel; diff --git a/hypervisor/bsp/uefi/include/bsp/bsp_cfg.h b/hypervisor/bsp/uefi/include/bsp/bsp_cfg.h index a882f32bd..d9e926e42 100644 --- a/hypervisor/bsp/uefi/include/bsp/bsp_cfg.h +++ b/hypervisor/bsp/uefi/include/bsp/bsp_cfg.h @@ -17,7 +17,6 @@ #define HEAP_SIZE 0x100000 #define CONSOLE_LOGLEVEL_DEFAULT 3 #define MEM_LOGLEVEL_DEFAULT 5 -#define CONFIG_LOW_RAM_START 0x00008000 #define CONFIG_LOW_RAM_SIZE 0x00010000 #define CONFIG_RAM_START 0x20000000 #define CONFIG_RAM_SIZE 0x02000000 /* 32M */ diff --git a/hypervisor/bsp/uefi/uefi.c b/hypervisor/bsp/uefi/uefi.c index 1a4a3ccb2..fd27845c2 100644 --- a/hypervisor/bsp/uefi/uefi.c +++ b/hypervisor/bsp/uefi/uefi.c @@ -97,6 +97,11 @@ void *get_rsdp_from_uefi(void) return HPA2HVA(efi_ctx->rsdp); } +void *get_ap_trampline_buf(void) +{ + return efi_ctx->ap_trampline_buf; +} + static void efi_init(void) { struct multiboot_info *mbi = NULL; diff --git a/hypervisor/include/arch/x86/cpu.h b/hypervisor/include/arch/x86/cpu.h index a3943c6fe..501050f0c 100644 --- a/hypervisor/include/arch/x86/cpu.h +++ b/hypervisor/include/arch/x86/cpu.h @@ -169,6 +169,7 @@ extern uint8_t trampline_pdpt_addr[]; extern uint8_t trampline_gdt_ptr[]; extern uint8_t trampline_start64_fixup[]; +extern uint64_t trampline_start16_paddr; extern int ibrs_type; /* diff --git a/hypervisor/include/common/acrn_efi.h b/hypervisor/include/common/acrn_efi.h index 86abf0377..21ebd1630 100644 --- a/hypervisor/include/common/acrn_efi.h +++ b/hypervisor/include/common/acrn_efi.h @@ -15,6 +15,7 @@ typedef struct { struct efi_ctx { uint64_t rip; void *rsdp; + void *ap_trampline_buf; dt_addr_t gdt; dt_addr_t idt; uint16_t tr_sel; @@ -50,5 +51,6 @@ struct efi_ctx { }__attribute__((packed)); void *get_rsdp_from_uefi(void); +void *get_ap_trampline_buf(void); #endif /* UEFI_H*/