From 6a0a3233c3dcc4bcbf68d61e1aa044c02421bcd4 Mon Sep 17 00:00:00 2001 From: Zide Chen Date: Sun, 23 Aug 2020 21:09:51 -0700 Subject: [PATCH] hv: remove unused de-privilege and vboot wrapper code Remove deprivilege_boot.c, direct_boot.c, vboot_wrapper.c and their header fioles. Tracked-On: #5197 Signed-off-by: Zide Chen --- hypervisor/boot/guest/deprivilege_boot.c | 77 ---------------- hypervisor/boot/guest/direct_boot.c | 56 ------------ hypervisor/boot/guest/vboot_info.c | 1 - hypervisor/boot/guest/vboot_wrapper.c | 90 ------------------- .../boot/include/guest/deprivilege_boot.h | 23 ----- hypervisor/boot/include/guest/direct_boot.h | 15 ---- hypervisor/boot/include/guest/vboot.h | 30 ------- 7 files changed, 292 deletions(-) delete mode 100644 hypervisor/boot/guest/deprivilege_boot.c delete mode 100644 hypervisor/boot/guest/direct_boot.c delete mode 100644 hypervisor/boot/guest/vboot_wrapper.c delete mode 100644 hypervisor/boot/include/guest/deprivilege_boot.h delete mode 100644 hypervisor/boot/include/guest/direct_boot.h delete mode 100644 hypervisor/boot/include/guest/vboot.h diff --git a/hypervisor/boot/guest/deprivilege_boot.c b/hypervisor/boot/guest/deprivilege_boot.c deleted file mode 100644 index cbbc4bf78..000000000 --- a/hypervisor/boot/guest/deprivilege_boot.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* this is for de-privilege guest vboot method */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -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 acrn_multiboot_info *mbi = get_multiboot_info(); - - if (!depri_initialized) { - if ((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 const void* get_depri_boot_rsdp(void) -{ - return (const void*)hpa2hva((uint64_t)(depri_boot_ctx.rsdp)); -} - -static void init_depri_boot_irq(void) -{ - /* 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; -} diff --git a/hypervisor/boot/guest/direct_boot.c b/hypervisor/boot/guest/direct_boot.c deleted file mode 100644 index 520e99695..000000000 --- a/hypervisor/boot/guest/direct_boot.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* this is for direct guest_boot method */ - -#include -#include -#include -#include -#include -#include - -/* AP trampoline code buffer base address. */ -static uint64_t ap_trampoline_buf; - -static void init_direct_boot(void) -{ - ap_trampoline_buf = e820_alloc_memory(CONFIG_LOW_RAM_SIZE, MEM_1M); -} - -/* @post: return != 0UL */ -static uint64_t get_direct_boot_ap_trampoline(void) -{ - return ap_trampoline_buf; -} - -static const void* get_direct_boot_rsdp(void) -{ -#ifdef CONFIG_MULTIBOOT2 - struct acrn_multiboot_info *mbi = get_multiboot_info(); - - return mbi->mi_acpi_rsdp_va; -#else - return NULL; -#endif -} - -static void init_direct_boot_irq(void) -{ - CPU_IRQ_ENABLE(); -} - -static struct vboot_operations direct_boot_ops = { - .init = init_direct_boot, - .get_ap_trampoline = get_direct_boot_ap_trampoline, - .get_rsdp = get_direct_boot_rsdp, - .init_irq = init_direct_boot_irq, -}; - -struct vboot_operations* get_direct_boot_ops(void) -{ - return &direct_boot_ops; -} diff --git a/hypervisor/boot/guest/vboot_info.c b/hypervisor/boot/guest/vboot_info.c index 5d90f401d..df5ebfa66 100644 --- a/hypervisor/boot/guest/vboot_info.c +++ b/hypervisor/boot/guest/vboot_info.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include diff --git a/hypervisor/boot/guest/vboot_wrapper.c b/hypervisor/boot/guest/vboot_wrapper.c deleted file mode 100644 index c3085bc9e..000000000 --- a/hypervisor/boot/guest/vboot_wrapper.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define BOOTLOADER_NUM 5U -#define BOOTLOADER_NAME_SIZE 20U - -struct vboot_bootloader_map { - const char bootloader_name[BOOTLOADER_NAME_SIZE]; - enum vboot_mode mode; -}; - -static struct vboot_operations *vboot_ops; -static enum vboot_mode sos_boot_mode; - -/** - * @pre: this function is called during detect mode which is very early stage, - * other exported interfaces should not be called beforehand. - */ -void init_vboot(void) -{ - struct acrn_multiboot_info *mbi = get_multiboot_info(); - uint32_t i; - - const struct vboot_bootloader_map vboot_bootloader_maps[BOOTLOADER_NUM] = { - {"Slim BootLoader", DIRECT_BOOT_MODE}, - {"Intel IOTG/TSD ABL", DIRECT_BOOT_MODE}, - {"ACRN UEFI loader", DEPRI_BOOT_MODE}, - {"GRUB", DIRECT_BOOT_MODE}, - {"PXELINUX", DIRECT_BOOT_MODE}, - }; - - for (i = 0U; i < BOOTLOADER_NUM; i++) { - if (strncmp(mbi->mi_loader_name, vboot_bootloader_maps[i].bootloader_name, - strnlen_s(vboot_bootloader_maps[i].bootloader_name, BOOTLOADER_NAME_SIZE)) == 0) { - /* Only support two vboot mode */ - if (vboot_bootloader_maps[i].mode == DEPRI_BOOT_MODE) { - vboot_ops = get_deprivilege_boot_ops(); - sos_boot_mode = DEPRI_BOOT_MODE; - } else { - vboot_ops = get_direct_boot_ops(); - sos_boot_mode = DIRECT_BOOT_MODE; - } - break; - } - } - - /* - * vboot_ops is mandatory and it will be initialized correctly. - * The vboot_ops->init is called to assure that the boot env is - * initialized before calling other vboot_ops interface. - */ - vboot_ops->init(); -} - -/* @pre: vboot_ops != NULL */ -enum vboot_mode get_sos_boot_mode(void) -{ - return sos_boot_mode; -} - -/* @pre: vboot_ops->get_ap_trampoline != NULL */ -uint64_t get_ap_trampoline_buf(void) -{ - return vboot_ops->get_ap_trampoline(); -} - -/* @pre: vboot_ops->get_rsdp != NULL */ -const void *get_rsdp_ptr(void) -{ - return vboot_ops->get_rsdp(); -} - -/* @pre: vboot_ops->init_irq != NULL */ -void init_vboot_irq(void) -{ - return vboot_ops->init_irq(); -} diff --git a/hypervisor/boot/include/guest/deprivilege_boot.h b/hypervisor/boot/include/guest/deprivilege_boot.h deleted file mode 100644 index 4be920eb5..000000000 --- a/hypervisor/boot/include/guest/deprivilege_boot.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ -#ifndef DEPRIVILEGE_BOOT_H - -#define DEPRIVILEGE_BOOT_H - -#include - -struct depri_boot_context { - struct acrn_vcpu_regs vcpu_regs; - void *rsdp; - uint64_t ap_trampoline_buf; -} __packed; - -const struct depri_boot_context *get_depri_boot_ctx(void); -const struct lapic_regs *get_depri_boot_lapic_regs(void); - -struct vboot_operations* get_deprivilege_boot_ops(void); - -#endif /* end of include guard: DEPRIVILEGE_BOOT_H */ diff --git a/hypervisor/boot/include/guest/direct_boot.h b/hypervisor/boot/include/guest/direct_boot.h deleted file mode 100644 index 5f27b327e..000000000 --- a/hypervisor/boot/include/guest/direct_boot.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef DIRECT_BOOT_H - -#define DIRECT_BOOT_H - -#include - -struct vboot_operations* get_direct_boot_ops(void); - -#endif /* end of include guard: DIRECT_BOOT_H */ diff --git a/hypervisor/boot/include/guest/vboot.h b/hypervisor/boot/include/guest/vboot.h deleted file mode 100644 index 62a39d110..000000000 --- a/hypervisor/boot/include/guest/vboot.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef VBOOT_H - -#define VBOOT_H - -enum vboot_mode { - DIRECT_BOOT_MODE, - DEPRI_BOOT_MODE -}; - -struct vboot_operations { - void (*init)(void); - uint64_t (*get_ap_trampoline)(void); - const void *(*get_rsdp)(void); - void (*init_irq)(void); -}; - -void init_vboot(void); -void init_vboot_irq(void); -uint64_t get_ap_trampoline_buf(void); -const void *get_rsdp_ptr(void); - -enum vboot_mode get_sos_boot_mode(void); - -#endif /* end of include guard: VBOOT_H */