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:
Yin Fengwei 2018-09-28 14:50:14 +08:00 committed by lijinxia
parent ba1aa40707
commit adc7913741
5 changed files with 30 additions and 32 deletions

View File

@ -7,7 +7,7 @@
#include <hypervisor.h>
#include <vm0_boot.h>
#ifdef CONFIG_EFI_STUB
extern struct boot_ctx* efi_ctx;
extern struct efi_context* efi_ctx;
#endif
#define REAL_MODE_BSP_INIT_CODE_SEL (0xf000U)

View File

@ -45,11 +45,11 @@ extern const uint64_t guest_entry;
static UINT64 hv_hpa;
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;
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
* 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;
struct multiboot_info *mbi;
struct multiboot_mmap *mmap;
struct boot_ctx *efi_ctx;
struct efi_context *efi_ctx;
int i, j;
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_STATUS err;
struct multiboot_info *mbi;
struct boot_ctx *efi_ctx;
struct efi_context *efi_ctx;
struct acpi_table_rsdp *rsdp = NULL;
int i;
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"
"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 %%rbx, %0" : "=r"(efi_ctx->gprs.rbx));
asm volatile ("movq %%rcx, %0" : "=r"(efi_ctx->gprs.rcx));
asm volatile ("movq %%rdx, %0" : "=r"(efi_ctx->gprs.rdx));
asm volatile ("movq %%rdi, %0" : "=r"(efi_ctx->gprs.rdi));
asm volatile ("movq %%rsi, %0" : "=r"(efi_ctx->gprs.rsi));
asm volatile ("movq %%rsp, %0" : "=r"(efi_ctx->gprs.rsp));
asm volatile ("movq %%rbp, %0" : "=r"(efi_ctx->gprs.rbp));
asm volatile ("movq %%r8, %0" : "=r"(efi_ctx->gprs.r8));
asm volatile ("movq %%r9, %0" : "=r"(efi_ctx->gprs.r9));
asm volatile ("movq %%r10, %0" : "=r"(efi_ctx->gprs.r10));
asm volatile ("movq %%r11, %0" : "=r"(efi_ctx->gprs.r11));
asm volatile ("movq %%r12, %0" : "=r"(efi_ctx->gprs.r12));
asm volatile ("movq %%r13, %0" : "=r"(efi_ctx->gprs.r13));
asm volatile ("movq %%r14, %0" : "=r"(efi_ctx->gprs.r14));
asm volatile ("movq %%r15, %0" : "=r"(efi_ctx->gprs.r15));
asm volatile ("movq %%rax, %0" : "=r"(efi_ctx->vcpu_regs.gprs.rax));
asm volatile ("movq %%rbx, %0" : "=r"(efi_ctx->vcpu_regs.gprs.rbx));
asm volatile ("movq %%rcx, %0" : "=r"(efi_ctx->vcpu_regs.gprs.rcx));
asm volatile ("movq %%rdx, %0" : "=r"(efi_ctx->vcpu_regs.gprs.rdx));
asm volatile ("movq %%rdi, %0" : "=r"(efi_ctx->vcpu_regs.gprs.rdi));
asm volatile ("movq %%rsi, %0" : "=r"(efi_ctx->vcpu_regs.gprs.rsi));
asm volatile ("movq %%rsp, %0" : "=r"(efi_ctx->vcpu_regs.gprs.rsp));
asm volatile ("movq %%rbp, %0" : "=r"(efi_ctx->vcpu_regs.gprs.rbp));
asm volatile ("movq %%r8, %0" : "=r"(efi_ctx->vcpu_regs.gprs.r8));
asm volatile ("movq %%r9, %0" : "=r"(efi_ctx->vcpu_regs.gprs.r9));
asm volatile ("movq %%r10, %0" : "=r"(efi_ctx->vcpu_regs.gprs.r10));
asm volatile ("movq %%r11, %0" : "=r"(efi_ctx->vcpu_regs.gprs.r11));
asm volatile ("movq %%r12, %0" : "=r"(efi_ctx->vcpu_regs.gprs.r12));
asm volatile ("movq %%r13, %0" : "=r"(efi_ctx->vcpu_regs.gprs.r13));
asm volatile ("movq %%r14, %0" : "=r"(efi_ctx->vcpu_regs.gprs.r14));
asm volatile ("movq %%r15, %0" : "=r"(efi_ctx->vcpu_regs.gprs.r15));
hv_jump(hv_hpa, mbi, efi_ctx);
asm volatile (".global guest_entry\n\t"

View File

@ -76,14 +76,14 @@ typedef void(*hv_func)(int, struct multiboot_info*);
#define MBOOT_MMAP_NUMS 128
#define MBOOT_MMAP_SIZE (sizeof(struct multiboot_mmap) * MBOOT_MMAP_NUMS)
#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 \
(CONFIG_RAM_SIZE + MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE + BOOT_CTX_SIZE)
#define MBOOT_MMAP_PTR(addr) \
((struct multiboot_mmap *)((VOID *)addr + CONFIG_RAM_SIZE))
#define MBOOT_INFO_PTR(addr) ((struct multiboot_info *) \
((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))

View File

@ -11,7 +11,7 @@
#ifdef CONFIG_EFI_STUB
static void efi_init(void);
struct boot_ctx* efi_ctx = NULL;
struct efi_context* efi_ctx = NULL;
struct lapic_regs uefi_lapic_regs;
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);
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),
&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 */
CPU_IRQ_ENABLE();
@ -87,7 +87,7 @@ static void efi_init(void)
if (!(mbi->mi_flags & MULTIBOOT_INFO_HAS_DRIVES))
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");
vm_sw_loader = uefi_sw_loader;

View File

@ -85,15 +85,13 @@ struct acrn_vcpu_regs {
uint16_t reserved_16[4];
};
struct boot_ctx {
struct acrn_vcpu_regs vcpu_regs;
#ifdef CONFIG_EFI_STUB
struct efi_context {
struct acrn_vcpu_regs vcpu_regs;
void *rsdp;
void *ap_trampoline_buf;
#endif
}__attribute__((packed));
#ifdef CONFIG_EFI_STUB
void *get_rsdp_from_uefi(void);
void *get_ap_trampoline_buf(void);
#endif