From 20f97f755968edd3d7230689d7410cb4cbd5a23a Mon Sep 17 00:00:00 2001 From: Jason Chen CJ Date: Tue, 30 Apr 2019 13:56:32 +0800 Subject: [PATCH] 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 Acked-by: Eddie Dong --- efi-stub/Makefile | 2 +- efi-stub/boot.c | 2 +- hypervisor/Makefile | 17 ++++++++--------- hypervisor/arch/x86/cpu.c | 2 +- hypervisor/arch/x86/guest/vm.c | 2 +- hypervisor/arch/x86/init.c | 2 +- hypervisor/arch/x86/irq.c | 2 +- hypervisor/arch/x86/trampoline.c | 2 +- hypervisor/boot/acpi.c | 2 +- hypervisor/{bsp => boot}/cmdline.c | 0 .../guest/deprivilege_boot.c} | 2 +- .../deprivilege_boot_info.c} | 2 +- .../firmware_sbl.c => boot/guest/direct_boot.c} | 2 +- .../multiboot.c => guest/direct_boot_info.c} | 0 .../guest/vboot_wrapper.c} | 6 +++--- .../include/guest/deprivilege_boot.h} | 2 +- .../include/guest/direct_boot.h} | 2 +- .../firmware.h => boot/include/guest/vboot.h} | 2 ++ hypervisor/include/arch/x86/multiboot.h | 3 --- 19 files changed, 26 insertions(+), 28 deletions(-) rename hypervisor/{bsp => boot}/cmdline.c (100%) rename hypervisor/{bsp/firmware_uefi.c => boot/guest/deprivilege_boot.c} (98%) rename hypervisor/boot/{uefi/uefi_boot.c => guest/deprivilege_boot_info.c} (97%) rename hypervisor/{bsp/firmware_sbl.c => boot/guest/direct_boot.c} (96%) rename hypervisor/boot/{sbl/multiboot.c => guest/direct_boot_info.c} (100%) rename hypervisor/{bsp/firmware_wrapper.c => boot/guest/vboot_wrapper.c} (95%) rename hypervisor/{bsp/include/firmware_uefi.h => boot/include/guest/deprivilege_boot.h} (96%) rename hypervisor/{bsp/include/firmware_sbl.h => boot/include/guest/direct_boot.h} (93%) rename hypervisor/{bsp/include/firmware.h => boot/include/guest/vboot.h} (95%) diff --git a/efi-stub/Makefile b/efi-stub/Makefile index 3a4fc9179..c7b035fe2 100644 --- a/efi-stub/Makefile +++ b/efi-stub/Makefile @@ -60,7 +60,7 @@ LDSCRIPT := $(GNUEFI_DIR)/elf_$(ARCH)_efi.lds INCDIR := $(SYSROOT)/usr/include CFLAGS=-I. -I.. -I../hypervisor/include/arch/x86/guest -I$(INCDIR)/efi -I$(INCDIR)/efi/$(ARCH) \ - -I../hypervisor/include/public -I../hypervisor/include/lib -I../hypervisor/bsp/include/ \ + -I../hypervisor/include/public -I../hypervisor/include/lib -I../hypervisor/boot/include/guest \ -DEFI_FUNCTION_WRAPPER -fPIC -fshort-wchar -ffreestanding \ -Wall -I../fs/ -D$(ARCH) -O2 -I../hypervisor/include/arch/x86 \ -include config.h diff --git a/efi-stub/boot.c b/efi-stub/boot.c index 8c21bb73e..00c5c8a1c 100644 --- a/efi-stub/boot.c +++ b/efi-stub/boot.c @@ -37,7 +37,7 @@ #include "stdlib.h" #include "boot.h" #include "acrn_common.h" -#include "firmware_uefi.h" +#include "deprivilege_boot.h" #include "MpService.h" EFI_SYSTEM_TABLE *sys_table; diff --git a/hypervisor/Makefile b/hypervisor/Makefile index b4504baf1..89e3fdc8d 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -116,8 +116,8 @@ INCLUDE_PATH += include/debug INCLUDE_PATH += include/public INCLUDE_PATH += include/dm INCLUDE_PATH += include/hw -INCLUDE_PATH += bsp/include INCLUDE_PATH += boot/include +INCLUDE_PATH += boot/include/guest INCLUDE_PATH += $(HV_OBJDIR)/include INCLUDE_PATH += arch/x86/configs/$(CONFIG_BOARD) INCLUDE_PATH += scenarios/$(SCENARIO_NAME) @@ -155,9 +155,15 @@ ifneq (,$(wildcard scenarios/$(SCENARIO_NAME)/pt_dev.c)) C_SRCS += scenarios/$(SCENARIO_NAME)/pt_dev.c endif - C_SRCS += boot/acpi.c C_SRCS += boot/dmar_parse.c +C_SRCS += boot/cmdline.c +C_SRCS += boot/guest/vboot_wrapper.c +C_SRCS += boot/guest/deprivilege_boot.c +C_SRCS += boot/guest/deprivilege_boot_info.c +C_SRCS += boot/guest/direct_boot.c +C_SRCS += boot/guest/direct_boot_info.c + S_SRCS += arch/x86/idt.S C_SRCS += arch/x86/ioapic.c C_SRCS += arch/x86/lapic.c @@ -237,15 +243,8 @@ C_SRCS += dm/vpci/pci_pt.c C_SRCS += dm/vpci/vmsi.c C_SRCS += dm/vpci/vmsix.c -C_SRCS += bsp/firmware_wrapper.c -C_SRCS += bsp/firmware_sbl.c -C_SRCS += bsp/firmware_uefi.c -C_SRCS += bsp/cmdline.c C_SRCS += bsp/const_dmar.c -C_SRCS += boot/uefi/uefi_boot.c -C_SRCS += boot/sbl/multiboot.c - # retpoline support ifeq (true, $(shell [ $(GCC_MAJOR) -eq 7 ] && [ $(GCC_MINOR) -ge 3 ] && echo true)) CFLAGS += -mindirect-branch=thunk-extern -mindirect-branch-register diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index e9a18c100..a923e5012 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #define CPU_UP_TIMEOUT 100U /* millisecond */ #define CPU_DOWN_TIMEOUT 100U /* millisecond */ diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index 8159afe81..40241d783 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include vm_sw_loader_t vm_sw_loader; diff --git a/hypervisor/arch/x86/init.c b/hypervisor/arch/x86/init.c index 31ab9bef2..1a34e854e 100644 --- a/hypervisor/arch/x86/init.c +++ b/hypervisor/arch/x86/init.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include /* Push sp magic to top of stack for call trace */ diff --git a/hypervisor/arch/x86/irq.c b/hypervisor/arch/x86/irq.c index a930b2271..fcb4fb625 100644 --- a/hypervisor/arch/x86/irq.c +++ b/hypervisor/arch/x86/irq.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include diff --git a/hypervisor/arch/x86/trampoline.c b/hypervisor/arch/x86/trampoline.c index d0ad010cc..711a95490 100644 --- a/hypervisor/arch/x86/trampoline.c +++ b/hypervisor/arch/x86/trampoline.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include static uint64_t trampoline_start16_paddr; diff --git a/hypervisor/boot/acpi.c b/hypervisor/boot/acpi.c index 8cfea7926..59516f8f0 100644 --- a/hypervisor/boot/acpi.c +++ b/hypervisor/boot/acpi.c @@ -28,7 +28,7 @@ */ #include #include -#include +#include #include "acpi_priv.h" #include "acpi.h" #include diff --git a/hypervisor/bsp/cmdline.c b/hypervisor/boot/cmdline.c similarity index 100% rename from hypervisor/bsp/cmdline.c rename to hypervisor/boot/cmdline.c diff --git a/hypervisor/bsp/firmware_uefi.c b/hypervisor/boot/guest/deprivilege_boot.c similarity index 98% rename from hypervisor/bsp/firmware_uefi.c rename to hypervisor/boot/guest/deprivilege_boot.c index 8db583536..7d5f6a7ee 100644 --- a/hypervisor/bsp/firmware_uefi.c +++ b/hypervisor/boot/guest/deprivilege_boot.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include static struct uefi_context uefi_ctx; static struct lapic_regs uefi_lapic_regs; diff --git a/hypervisor/boot/uefi/uefi_boot.c b/hypervisor/boot/guest/deprivilege_boot_info.c similarity index 97% rename from hypervisor/boot/uefi/uefi_boot.c rename to hypervisor/boot/guest/deprivilege_boot_info.c index 01ae49e45..8e08132c8 100644 --- a/hypervisor/boot/uefi/uefi_boot.c +++ b/hypervisor/boot/guest/deprivilege_boot_info.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include static int32_t uefi_sw_loader(struct acrn_vm *vm) { diff --git a/hypervisor/bsp/firmware_sbl.c b/hypervisor/boot/guest/direct_boot.c similarity index 96% rename from hypervisor/bsp/firmware_sbl.c rename to hypervisor/boot/guest/direct_boot.c index 7830e4922..b603d01c0 100644 --- a/hypervisor/bsp/firmware_sbl.c +++ b/hypervisor/boot/guest/direct_boot.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include static void sbl_init(void) { diff --git a/hypervisor/boot/sbl/multiboot.c b/hypervisor/boot/guest/direct_boot_info.c similarity index 100% rename from hypervisor/boot/sbl/multiboot.c rename to hypervisor/boot/guest/direct_boot_info.c diff --git a/hypervisor/bsp/firmware_wrapper.c b/hypervisor/boot/guest/vboot_wrapper.c similarity index 95% rename from hypervisor/bsp/firmware_wrapper.c rename to hypervisor/boot/guest/vboot_wrapper.c index 6284f1951..8e7adb017 100644 --- a/hypervisor/bsp/firmware_wrapper.c +++ b/hypervisor/boot/guest/vboot_wrapper.c @@ -9,9 +9,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include static struct firmware_operations *firmware_ops; diff --git a/hypervisor/bsp/include/firmware_uefi.h b/hypervisor/boot/include/guest/deprivilege_boot.h similarity index 96% rename from hypervisor/bsp/include/firmware_uefi.h rename to hypervisor/boot/include/guest/deprivilege_boot.h index da6b3a676..8f79e934d 100644 --- a/hypervisor/bsp/include/firmware_uefi.h +++ b/hypervisor/boot/include/guest/deprivilege_boot.h @@ -7,7 +7,7 @@ #define FIRMWARE_UEFI_H -#include +#include struct uefi_context { struct acrn_vcpu_regs vcpu_regs; diff --git a/hypervisor/bsp/include/firmware_sbl.h b/hypervisor/boot/include/guest/direct_boot.h similarity index 93% rename from hypervisor/bsp/include/firmware_sbl.h rename to hypervisor/boot/include/guest/direct_boot.h index 1ab2a3294..c907ebc9a 100644 --- a/hypervisor/bsp/include/firmware_sbl.h +++ b/hypervisor/boot/include/guest/direct_boot.h @@ -8,7 +8,7 @@ #define FIRMWARE_SBL_H -#include +#include struct firmware_operations* sbl_get_firmware_operations(void); int32_t sbl_init_vm_boot_info(struct acrn_vm *vm); diff --git a/hypervisor/bsp/include/firmware.h b/hypervisor/boot/include/guest/vboot.h similarity index 95% rename from hypervisor/bsp/include/firmware.h rename to hypervisor/boot/include/guest/vboot.h index 1cc44cb66..00a24b280 100644 --- a/hypervisor/bsp/include/firmware.h +++ b/hypervisor/boot/include/guest/vboot.h @@ -32,4 +32,6 @@ void *firmware_get_rsdp(void); void firmware_init_irq(void); int32_t firmware_init_vm_boot_info(struct acrn_vm *vm); +int32_t parse_hv_cmdline(void); + #endif /* end of include guard: FIRMWARE_H */ diff --git a/hypervisor/include/arch/x86/multiboot.h b/hypervisor/include/arch/x86/multiboot.h index d45839c2b..4740ff675 100644 --- a/hypervisor/include/arch/x86/multiboot.h +++ b/hypervisor/include/arch/x86/multiboot.h @@ -84,9 +84,6 @@ struct multiboot_module { uint32_t mm_reserved; }; -int32_t parse_hv_cmdline(void); -int32_t init_vm_boot_info(struct acrn_vm *vm); - /* boot_regs store the multiboot header address */ extern uint32_t boot_regs[2]; #endif