UEFI: bug fix on delivering RSDP

With current code, memcpy rsdp to 0x500 maybe overwrite uefi
code/data region.

So remove the legacy BIOS deliver method of RSDP, which need copy
the RSDP to EBDA space which is addressed by the 16bit pointer
at 0x40E or upper memory BIOS space 0xe0000-0xfffff. And just
deliver the pointer of RSDP, which is already saved in UEFI system
table, to hypervisor.

Create a function named efi_init() to separate efi initialize code.

Signed-off-by: Zheng, Gen <gen.zheng@intel.com>
This commit is contained in:
Zheng, Gen 2018-03-24 14:17:23 +08:00 committed by Jack Ren
parent 8d67f292ef
commit 1f3acb3dd9
5 changed files with 43 additions and 16 deletions

View File

@ -35,6 +35,9 @@
#include <hv_arch.h>
#include <hv_debug.h>
#include "acpi.h"
#ifdef CONFIG_EFI_STUB
#include <acrn_efi.h>
#endif
#define ACPI_SIG_RSDP "RSD PTR " /* Root System Description Ptr */
#define ACPI_OEM_ID_SIZE 6
@ -140,6 +143,12 @@ static void *get_rsdp(void)
struct acpi_table_rsdp *rsdp = NULL;
uint16_t *addr;
#ifdef CONFIG_EFI_STUB
rsdp = get_rsdp_from_uefi();
if (rsdp)
return rsdp;
#endif
/* EBDA is addressed by the 16 bit pointer at 0x40E */
addr = (uint16_t *)0x40E;

View File

@ -41,8 +41,6 @@
#define ERROR_STRING_LENGTH 32
#define EFI_LOADER_SIGNATURE "EL64"
#define LEAGCY_BIOS
#define ACPI_XSDT_ENTRY_SIZE (sizeof (UINT64))
#define ACPI_NAME_SIZE 4
#define ACPI_OEM_ID_SIZE 6
@ -448,11 +446,8 @@ again:
mbi->mi_cmdline = (UINTN)"uart=disabled";
mbi->mi_mmap_addr = (UINTN)mmap;
#ifdef LEAGCY_BIOS
/* copy rsdt in low memory space(0~0x1000) for hypervisor parsing */
memcpy((void *)0x500, (void*)rsdp, sizeof(struct acpi_table_rsdp));
*(UINT16*)(0x40E) = 0x50;
#endif
pe->rsdp = rsdp;
//Print(L"start 9!\n");
asm volatile ("mov %%cr0, %0":"=r"(pe->cr0));

View File

@ -76,7 +76,8 @@ struct e820_entry {
struct efi_ctx {
EFI_IMAGE_ENTRY_POINT entry;
EFI_HANDLE handle;
EFI_SYSTEM_TABLE* table;
EFI_SYSTEM_TABLE *table;
VOID *rsdp;
dt_addr_t gdt;
dt_addr_t idt;
uint16_t tr_sel;

View File

@ -53,12 +53,15 @@
#define UEFI_PCI_IRQ_ASSIGNMENT_NUM 28
#ifdef CONFIG_EFI_STUB
static void efi_init(void);
uint32_t efi_physical_available_ap_bitmap = 0;
uint32_t efi_wake_up_ap_bitmap = 0;
struct efi_ctx* efi_ctx = NULL;
struct lapic_regs uefi_lapic_regs;
extern uint32_t up_count;
extern unsigned long pcpu_sync;
static int efi_initialized;
void efi_spurious_handler(int vector)
{
@ -144,14 +147,18 @@ int uefi_sw_loader(struct vm *vm, struct vcpu *vcpu)
return ret;
}
#endif
void init_bsp(void)
void *get_rsdp_from_uefi(void)
{
parse_hv_cmdline();
if (!efi_initialized)
efi_init();
#ifdef CONFIG_EFI_STUB
efi_ctx = (struct efi_ctx*)(uint64_t)boot_regs[2];
return efi_ctx->rsdp;
}
static void efi_init(void)
{
efi_ctx = (struct efi_ctx *)(uint64_t)(uint32_t)boot_regs[2];
ASSERT(efi_ctx != NULL, "");
vm_sw_loader = uefi_sw_loader;
@ -159,5 +166,17 @@ void init_bsp(void)
spurious_handler = efi_spurious_handler;
save_lapic(&uefi_lapic_regs);
efi_initialized = 1;
}
#endif
void init_bsp(void)
{
parse_hv_cmdline();
#ifdef CONFIG_EFI_STUB
if (!efi_initialized)
efi_init();
#endif
}

View File

@ -37,9 +37,10 @@ typedef struct {
} __attribute__((packed)) dt_addr_t;
struct efi_ctx {
void* entry;
void* handle;
void* table;
void *entry;
void *handle;
void *table;
void *rsdp;
dt_addr_t gdt;
dt_addr_t idt;
uint16_t tr_sel;
@ -59,4 +60,6 @@ struct efi_ctx {
uint64_t efer;
}__attribute__((packed));
void *get_rsdp_from_uefi(void);
#endif /* UEFI_H*/