mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 05:30:24 +00:00
hv: efi_context refine
For SBL platform, struct acrn_vcpu_regs are used as boot context. Now the boot_ctx is only for UEFI platform. Rename struct boot_ctx to efi_context. Tracked-On: #1231 Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
This commit is contained in:
parent
ba1aa40707
commit
adc7913741
@ -7,7 +7,7 @@
|
|||||||
#include <hypervisor.h>
|
#include <hypervisor.h>
|
||||||
#include <vm0_boot.h>
|
#include <vm0_boot.h>
|
||||||
#ifdef CONFIG_EFI_STUB
|
#ifdef CONFIG_EFI_STUB
|
||||||
extern struct boot_ctx* efi_ctx;
|
extern struct efi_context* efi_ctx;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define REAL_MODE_BSP_INIT_CODE_SEL (0xf000U)
|
#define REAL_MODE_BSP_INIT_CODE_SEL (0xf000U)
|
||||||
|
@ -45,11 +45,11 @@ extern const uint64_t guest_entry;
|
|||||||
static UINT64 hv_hpa;
|
static UINT64 hv_hpa;
|
||||||
|
|
||||||
static inline void hv_jump(EFI_PHYSICAL_ADDRESS hv_start,
|
static inline void hv_jump(EFI_PHYSICAL_ADDRESS hv_start,
|
||||||
struct multiboot_info *mbi, struct boot_ctx *efi_ctx)
|
struct multiboot_info *mbi, struct efi_context *efi_ctx)
|
||||||
{
|
{
|
||||||
hv_func hf;
|
hv_func hf;
|
||||||
|
|
||||||
efi_ctx->rip = (uint64_t)&guest_entry;
|
efi_ctx->vcpu_regs.rip = (uint64_t)&guest_entry;
|
||||||
|
|
||||||
/* The 64-bit entry of acrn hypervisor is 0x200 from the start
|
/* The 64-bit entry of acrn hypervisor is 0x200 from the start
|
||||||
* address of hv image. But due to there is multiboot header,
|
* address of hv image. But due to there is multiboot header,
|
||||||
@ -75,7 +75,7 @@ EFI_STATUS construct_mbi(EFI_PHYSICAL_ADDRESS hv_hpa)
|
|||||||
EFI_STATUS err = EFI_SUCCESS;
|
EFI_STATUS err = EFI_SUCCESS;
|
||||||
struct multiboot_info *mbi;
|
struct multiboot_info *mbi;
|
||||||
struct multiboot_mmap *mmap;
|
struct multiboot_mmap *mmap;
|
||||||
struct boot_ctx *efi_ctx;
|
struct efi_context *efi_ctx;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
mbi = MBOOT_INFO_PTR(hv_hpa);
|
mbi = MBOOT_INFO_PTR(hv_hpa);
|
||||||
@ -199,7 +199,7 @@ switch_to_guest_mode(EFI_HANDLE image, EFI_PHYSICAL_ADDRESS hv_hpa)
|
|||||||
EFI_PHYSICAL_ADDRESS addr;
|
EFI_PHYSICAL_ADDRESS addr;
|
||||||
EFI_STATUS err;
|
EFI_STATUS err;
|
||||||
struct multiboot_info *mbi;
|
struct multiboot_info *mbi;
|
||||||
struct boot_ctx *efi_ctx;
|
struct efi_context *efi_ctx;
|
||||||
struct acpi_table_rsdp *rsdp = NULL;
|
struct acpi_table_rsdp *rsdp = NULL;
|
||||||
int i;
|
int i;
|
||||||
EFI_CONFIGURATION_TABLE *config_table;
|
EFI_CONFIGURATION_TABLE *config_table;
|
||||||
@ -250,24 +250,24 @@ switch_to_guest_mode(EFI_HANDLE image, EFI_PHYSICAL_ADDRESS hv_hpa)
|
|||||||
|
|
||||||
asm volatile ("pushf\n\t"
|
asm volatile ("pushf\n\t"
|
||||||
"pop %0\n\t"
|
"pop %0\n\t"
|
||||||
: "=r"(efi_ctx->rflags)
|
: "=r"(efi_ctx->vcpu_regs.rflags)
|
||||||
: );
|
: );
|
||||||
asm volatile ("movq %%rax, %0" : "=r"(efi_ctx->gprs.rax));
|
asm volatile ("movq %%rax, %0" : "=r"(efi_ctx->vcpu_regs.gprs.rax));
|
||||||
asm volatile ("movq %%rbx, %0" : "=r"(efi_ctx->gprs.rbx));
|
asm volatile ("movq %%rbx, %0" : "=r"(efi_ctx->vcpu_regs.gprs.rbx));
|
||||||
asm volatile ("movq %%rcx, %0" : "=r"(efi_ctx->gprs.rcx));
|
asm volatile ("movq %%rcx, %0" : "=r"(efi_ctx->vcpu_regs.gprs.rcx));
|
||||||
asm volatile ("movq %%rdx, %0" : "=r"(efi_ctx->gprs.rdx));
|
asm volatile ("movq %%rdx, %0" : "=r"(efi_ctx->vcpu_regs.gprs.rdx));
|
||||||
asm volatile ("movq %%rdi, %0" : "=r"(efi_ctx->gprs.rdi));
|
asm volatile ("movq %%rdi, %0" : "=r"(efi_ctx->vcpu_regs.gprs.rdi));
|
||||||
asm volatile ("movq %%rsi, %0" : "=r"(efi_ctx->gprs.rsi));
|
asm volatile ("movq %%rsi, %0" : "=r"(efi_ctx->vcpu_regs.gprs.rsi));
|
||||||
asm volatile ("movq %%rsp, %0" : "=r"(efi_ctx->gprs.rsp));
|
asm volatile ("movq %%rsp, %0" : "=r"(efi_ctx->vcpu_regs.gprs.rsp));
|
||||||
asm volatile ("movq %%rbp, %0" : "=r"(efi_ctx->gprs.rbp));
|
asm volatile ("movq %%rbp, %0" : "=r"(efi_ctx->vcpu_regs.gprs.rbp));
|
||||||
asm volatile ("movq %%r8, %0" : "=r"(efi_ctx->gprs.r8));
|
asm volatile ("movq %%r8, %0" : "=r"(efi_ctx->vcpu_regs.gprs.r8));
|
||||||
asm volatile ("movq %%r9, %0" : "=r"(efi_ctx->gprs.r9));
|
asm volatile ("movq %%r9, %0" : "=r"(efi_ctx->vcpu_regs.gprs.r9));
|
||||||
asm volatile ("movq %%r10, %0" : "=r"(efi_ctx->gprs.r10));
|
asm volatile ("movq %%r10, %0" : "=r"(efi_ctx->vcpu_regs.gprs.r10));
|
||||||
asm volatile ("movq %%r11, %0" : "=r"(efi_ctx->gprs.r11));
|
asm volatile ("movq %%r11, %0" : "=r"(efi_ctx->vcpu_regs.gprs.r11));
|
||||||
asm volatile ("movq %%r12, %0" : "=r"(efi_ctx->gprs.r12));
|
asm volatile ("movq %%r12, %0" : "=r"(efi_ctx->vcpu_regs.gprs.r12));
|
||||||
asm volatile ("movq %%r13, %0" : "=r"(efi_ctx->gprs.r13));
|
asm volatile ("movq %%r13, %0" : "=r"(efi_ctx->vcpu_regs.gprs.r13));
|
||||||
asm volatile ("movq %%r14, %0" : "=r"(efi_ctx->gprs.r14));
|
asm volatile ("movq %%r14, %0" : "=r"(efi_ctx->vcpu_regs.gprs.r14));
|
||||||
asm volatile ("movq %%r15, %0" : "=r"(efi_ctx->gprs.r15));
|
asm volatile ("movq %%r15, %0" : "=r"(efi_ctx->vcpu_regs.gprs.r15));
|
||||||
|
|
||||||
hv_jump(hv_hpa, mbi, efi_ctx);
|
hv_jump(hv_hpa, mbi, efi_ctx);
|
||||||
asm volatile (".global guest_entry\n\t"
|
asm volatile (".global guest_entry\n\t"
|
||||||
|
@ -76,14 +76,14 @@ typedef void(*hv_func)(int, struct multiboot_info*);
|
|||||||
#define MBOOT_MMAP_NUMS 128
|
#define MBOOT_MMAP_NUMS 128
|
||||||
#define MBOOT_MMAP_SIZE (sizeof(struct multiboot_mmap) * MBOOT_MMAP_NUMS)
|
#define MBOOT_MMAP_SIZE (sizeof(struct multiboot_mmap) * MBOOT_MMAP_NUMS)
|
||||||
#define MBOOT_INFO_SIZE (sizeof(struct multiboot_info))
|
#define MBOOT_INFO_SIZE (sizeof(struct multiboot_info))
|
||||||
#define BOOT_CTX_SIZE (sizeof(struct boot_ctx))
|
#define BOOT_CTX_SIZE (sizeof(struct efi_context))
|
||||||
#define HV_RUNTIME_MEM_SIZE \
|
#define HV_RUNTIME_MEM_SIZE \
|
||||||
(CONFIG_RAM_SIZE + MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE + BOOT_CTX_SIZE)
|
(CONFIG_RAM_SIZE + MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE + BOOT_CTX_SIZE)
|
||||||
#define MBOOT_MMAP_PTR(addr) \
|
#define MBOOT_MMAP_PTR(addr) \
|
||||||
((struct multiboot_mmap *)((VOID *)addr + CONFIG_RAM_SIZE))
|
((struct multiboot_mmap *)((VOID *)addr + CONFIG_RAM_SIZE))
|
||||||
#define MBOOT_INFO_PTR(addr) ((struct multiboot_info *) \
|
#define MBOOT_INFO_PTR(addr) ((struct multiboot_info *) \
|
||||||
((VOID *)addr + CONFIG_RAM_SIZE + MBOOT_MMAP_SIZE))
|
((VOID *)addr + CONFIG_RAM_SIZE + MBOOT_MMAP_SIZE))
|
||||||
#define BOOT_CTX_PTR(addr) ((struct boot_ctx *) \
|
#define BOOT_CTX_PTR(addr) ((struct efi_context *) \
|
||||||
((VOID *)addr + CONFIG_RAM_SIZE + MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE))
|
((VOID *)addr + CONFIG_RAM_SIZE + MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE))
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#ifdef CONFIG_EFI_STUB
|
#ifdef CONFIG_EFI_STUB
|
||||||
static void efi_init(void);
|
static void efi_init(void);
|
||||||
|
|
||||||
struct boot_ctx* efi_ctx = NULL;
|
struct efi_context* efi_ctx = NULL;
|
||||||
struct lapic_regs uefi_lapic_regs;
|
struct lapic_regs uefi_lapic_regs;
|
||||||
static int efi_initialized;
|
static int efi_initialized;
|
||||||
|
|
||||||
@ -51,9 +51,9 @@ int uefi_sw_loader(struct vm *vm, struct vcpu *vcpu)
|
|||||||
|
|
||||||
vlapic_restore(vcpu_vlapic(vcpu), &uefi_lapic_regs);
|
vlapic_restore(vcpu_vlapic(vcpu), &uefi_lapic_regs);
|
||||||
|
|
||||||
vcpu->entry_addr = (void *)efi_ctx->rip;
|
vcpu->entry_addr = (void *)efi_ctx->vcpu_regs.rip;
|
||||||
memcpy_s(&cur_context->guest_cpu_regs, sizeof(struct acrn_gp_regs),
|
memcpy_s(&cur_context->guest_cpu_regs, sizeof(struct acrn_gp_regs),
|
||||||
&efi_ctx->gprs, sizeof(struct acrn_gp_regs));
|
&efi_ctx->vcpu_regs.gprs, sizeof(struct acrn_gp_regs));
|
||||||
|
|
||||||
/* defer irq enabling till vlapic is ready */
|
/* defer irq enabling till vlapic is ready */
|
||||||
CPU_IRQ_ENABLE();
|
CPU_IRQ_ENABLE();
|
||||||
@ -87,7 +87,7 @@ static void efi_init(void)
|
|||||||
if (!(mbi->mi_flags & MULTIBOOT_INFO_HAS_DRIVES))
|
if (!(mbi->mi_flags & MULTIBOOT_INFO_HAS_DRIVES))
|
||||||
ASSERT(0, "no multiboot drivers for uefi found");
|
ASSERT(0, "no multiboot drivers for uefi found");
|
||||||
|
|
||||||
efi_ctx = (struct boot_ctx *)hpa2hva((uint64_t)mbi->mi_drives_addr);
|
efi_ctx = (struct efi_context *)hpa2hva((uint64_t)mbi->mi_drives_addr);
|
||||||
ASSERT(efi_ctx != NULL, "no uefi context found");
|
ASSERT(efi_ctx != NULL, "no uefi context found");
|
||||||
|
|
||||||
vm_sw_loader = uefi_sw_loader;
|
vm_sw_loader = uefi_sw_loader;
|
||||||
|
@ -85,15 +85,13 @@ struct acrn_vcpu_regs {
|
|||||||
uint16_t reserved_16[4];
|
uint16_t reserved_16[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct boot_ctx {
|
|
||||||
struct acrn_vcpu_regs vcpu_regs;
|
|
||||||
#ifdef CONFIG_EFI_STUB
|
#ifdef CONFIG_EFI_STUB
|
||||||
|
struct efi_context {
|
||||||
|
struct acrn_vcpu_regs vcpu_regs;
|
||||||
void *rsdp;
|
void *rsdp;
|
||||||
void *ap_trampoline_buf;
|
void *ap_trampoline_buf;
|
||||||
#endif
|
|
||||||
}__attribute__((packed));
|
}__attribute__((packed));
|
||||||
|
|
||||||
#ifdef CONFIG_EFI_STUB
|
|
||||||
void *get_rsdp_from_uefi(void);
|
void *get_rsdp_from_uefi(void);
|
||||||
void *get_ap_trampoline_buf(void);
|
void *get_ap_trampoline_buf(void);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user