acrn-hypervisor/hypervisor/boot/guest/deprivilege_boot.c

79 lines
1.8 KiB
C
Raw Normal View History

/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/* this is for de-privilege guest vboot method */
#include <types.h>
#include <acrn_common.h>
#include <pgtable.h>
#include <logmsg.h>
#include <rtl.h>
#include <vlapic.h>
#include <lapic.h>
#include <per_cpu.h>
#include <guest/vm.h>
#include <multiboot.h>
restruct boot and bsp dir for firmware stuff currently, ACRN hypervisor can either boot from sbl/abl or uefi, that's why we have different firmware method under bsp & boot dirs. but the fact is that we actually have two different operations based on different guest boot mode: 1. de-privilege-boot: ACRN hypervisor will boot VM0 in the same context as native(before entering hypervisor) - it means hypervisor will co-work with ACRN UEFI bootloader, restore the context env and de-privilege this env to VM0 guest. 2. direct-boot: ACRN hypervisor will directly boot different pre-launched VM(including SOS), it will setup guest env by pre-defined configuration, and prepare guest kernel image, ramdisk which fetch from multiboot modules. this patch is trying to: - rename files related with firmware, change them to guest vboot related - restruct all guest boot stuff in boot & bsp dirs into a new boot/guest dir - use de-privilege & direct boot to distinguish two different boot operations this patch is pure file movement, the rename of functions based on old assumption will be in the following patch. Changes to be committed: modified: ../efi-stub/Makefile modified: ../efi-stub/boot.c modified: Makefile modified: arch/x86/cpu.c modified: arch/x86/guest/vm.c modified: arch/x86/init.c modified: arch/x86/irq.c modified: arch/x86/trampoline.c modified: boot/acpi.c renamed: bsp/cmdline.c -> boot/cmdline.c renamed: bsp/firmware_uefi.c -> boot/guest/deprivilege_boot.c renamed: boot/uefi/uefi_boot.c -> boot/guest/deprivilege_boot_info.c renamed: bsp/firmware_sbl.c -> boot/guest/direct_boot.c renamed: boot/sbl/multiboot.c -> boot/guest/direct_boot_info.c renamed: bsp/firmware_wrapper.c -> boot/guest/vboot_wrapper.c modified: boot/include/acpi.h renamed: bsp/include/firmware_uefi.h -> boot/include/guest/deprivilege_boot.h renamed: bsp/include/firmware_sbl.h -> boot/include/guest/direct_boot.h renamed: bsp/include/firmware.h -> boot/include/guest/vboot.h modified: include/arch/x86/multiboot.h Tracked-On: #1842 Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-30 13:56:32 +08:00
#include <deprivilege_boot.h>
static struct depri_boot_context depri_boot_ctx;
static struct lapic_regs depri_boot_lapic_regs;
static void init_depri_boot(void)
{
static bool depri_initialized = false;
struct multiboot_info *mbi = NULL;
if (!depri_initialized) {
mbi = (struct multiboot_info *) hpa2hva(((uint64_t)(uint32_t)boot_regs[1]));
if ((mbi == NULL) || ((mbi->mi_flags & MULTIBOOT_INFO_HAS_DRIVES) == 0U)) {
pr_err("no multiboot drivers for depri_boot found");
} else {
(void)memcpy_s(&depri_boot_ctx, sizeof(struct depri_boot_context),
hpa2hva((uint64_t)mbi->mi_drives_addr),
sizeof(struct depri_boot_context));
save_lapic(&depri_boot_lapic_regs);
}
depri_initialized = true;
}
}
const struct depri_boot_context *get_depri_boot_ctx(void)
{
return &depri_boot_ctx;
}
const struct lapic_regs *get_depri_boot_lapic_regs(void)
{
return &depri_boot_lapic_regs;
}
static uint64_t get_depri_boot_ap_trampoline(void)
{
return depri_boot_ctx.ap_trampoline_buf;
}
static void* get_depri_boot_rsdp(void)
{
return hpa2hva((uint64_t)(depri_boot_ctx.rsdp));
}
static void init_depri_boot_irq(void)
{
2019-05-13 20:14:02 +08:00
/* nothing to do for now */
}
static struct vboot_operations depri_boot_ops = {
.init = init_depri_boot,
.get_ap_trampoline = get_depri_boot_ap_trampoline,
.get_rsdp = get_depri_boot_rsdp,
.init_irq = init_depri_boot_irq,
};
struct vboot_operations* get_deprivilege_boot_ops(void)
{
return &depri_boot_ops;
}