mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-10 12:32:45 +00:00
reshuffle init_vm_boot_info
now only SOS need decide boot with de-privilege or direct boot mode, while for other pre-launched VMs, they should use direct boot mode. this patch merge boot/guest/direct_boot_info.c & boot/guest/deprivilege_boot_info.c into boot/guest/vboot_info.c, and change init_direct_vboot_info() function name to init_general_vm_boot_info(). in init_vm_boot_info(), depend on get_sos_boot_mode(), SOS may choose to init vm boot info by setting the vm_sw_loader to deprivilege specific one; for SOS using DIRECT_BOOT_MODE and all other VMS, they will use general_sw_loader as vm_sw_loader and go through init_general_vm_boot_info() for virtual boot vm info filling. this patch also move spurious handler initilization for de-privilege mode from boot/guest/deprivilege_boot.c to boot/guest/vboot_info.c, and just set it in deprivilege sw_loader before irq enabling. Changes to be committed: modified: Makefile modified: arch/x86/guest/vm.c modified: boot/guest/deprivilege_boot.c deleted: boot/guest/deprivilege_boot_info.c modified: boot/guest/direct_boot.c renamed: boot/guest/direct_boot_info.c -> boot/guest/vboot_info.c modified: boot/guest/vboot_wrapper.c modified: boot/include/guest/deprivilege_boot.h modified: boot/include/guest/direct_boot.h modified: boot/include/guest/vboot.h new file: boot/include/guest/vboot_info.h modified: common/vm_load.c modified: include/arch/x86/guest/vm.h Tracked-On: #1842 Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
parent
0018da4114
commit
238d8bbaa2
@ -168,9 +168,8 @@ C_SRCS += boot/dmar_info.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
|
||||
C_SRCS += boot/guest/vboot_info.c
|
||||
|
||||
S_SRCS += arch/x86/idt.S
|
||||
C_SRCS += arch/x86/ioapic.c
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <mmu.h>
|
||||
#include <logmsg.h>
|
||||
#include <vboot.h>
|
||||
#include <vboot_info.h>
|
||||
#include <board.h>
|
||||
|
||||
vm_sw_loader_t vm_sw_loader;
|
||||
@ -666,10 +667,6 @@ void prepare_vm(uint16_t vm_id, struct acrn_vm_config *vm_config)
|
||||
}
|
||||
|
||||
if (err == 0) {
|
||||
if (vm_sw_loader == NULL) {
|
||||
vm_sw_loader = general_sw_loader;
|
||||
}
|
||||
|
||||
(void )vm_sw_loader(vm);
|
||||
|
||||
/* start vm BSP automatically */
|
||||
|
@ -63,23 +63,9 @@ static void* get_depri_boot_rsdp(void)
|
||||
return hpa2hva((uint64_t)(depri_boot_ctx.rsdp));
|
||||
}
|
||||
|
||||
static void depri_boot_spurious_handler(uint32_t vector)
|
||||
{
|
||||
if (get_pcpu_id() == BOOT_CPU_ID) {
|
||||
struct acrn_vcpu *vcpu = per_cpu(vcpu, BOOT_CPU_ID);
|
||||
|
||||
if (vcpu != NULL) {
|
||||
vlapic_set_intr(vcpu, vector, LAPIC_TRIG_EDGE);
|
||||
} else {
|
||||
pr_err("%s vcpu or vlapic is not ready, interrupt lost\n", __func__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void init_depri_boot_irq(void)
|
||||
{
|
||||
spurious_handler = (spurious_handler_t)depri_boot_spurious_handler;
|
||||
/* we defer irq enabling till vlapic is ready */
|
||||
/* nothing to do for now */
|
||||
}
|
||||
|
||||
static struct vboot_operations depri_boot_ops = {
|
||||
@ -87,7 +73,6 @@ static struct vboot_operations depri_boot_ops = {
|
||||
.get_ap_trampoline = get_depri_boot_ap_trampoline,
|
||||
.get_rsdp = get_depri_boot_rsdp,
|
||||
.init_irq = init_depri_boot_irq,
|
||||
.init_vboot_info = init_depri_vboot_info,
|
||||
};
|
||||
|
||||
struct vboot_operations* get_deprivilege_boot_ops(void)
|
||||
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <types.h>
|
||||
#include <cpu.h>
|
||||
#include <per_cpu.h>
|
||||
#include <guest/vm.h>
|
||||
#include <boot_context.h>
|
||||
#include <deprivilege_boot.h>
|
||||
|
||||
static int32_t depri_boot_sw_loader(struct acrn_vm *vm)
|
||||
{
|
||||
int32_t ret = 0;
|
||||
/* get primary vcpu */
|
||||
struct acrn_vcpu *vcpu = vcpu_from_vid(vm, BOOT_CPU_ID);
|
||||
struct acrn_vcpu_regs *vcpu_regs = &boot_context;
|
||||
const struct depri_boot_context *depri_boot_ctx = get_depri_boot_ctx();
|
||||
const struct lapic_regs *depri_boot_lapic_regs = get_depri_boot_lapic_regs();
|
||||
|
||||
pr_dbg("Loading guest to run-time location");
|
||||
|
||||
vlapic_restore(vcpu_vlapic(vcpu), depri_boot_lapic_regs);
|
||||
|
||||
/* For UEFI platform, the bsp init regs come from two places:
|
||||
* 1. saved in depri_boot: gpregs, rip
|
||||
* 2. saved when HV started: other registers
|
||||
* We copy the info saved in depri_boot to boot_context and
|
||||
* init bsp with boot_context.
|
||||
*/
|
||||
memcpy_s(&(vcpu_regs->gprs), sizeof(struct acrn_gp_regs),
|
||||
&(depri_boot_ctx->vcpu_regs.gprs), sizeof(struct acrn_gp_regs));
|
||||
|
||||
vcpu_regs->rip = depri_boot_ctx->vcpu_regs.rip;
|
||||
set_vcpu_regs(vcpu, vcpu_regs);
|
||||
|
||||
/* defer irq enabling till vlapic is ready */
|
||||
CPU_IRQ_ENABLE();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t init_depri_vboot_info(__unused struct acrn_vm *vm)
|
||||
{
|
||||
vm_sw_loader = depri_boot_sw_loader;
|
||||
|
||||
return 0;
|
||||
}
|
@ -37,7 +37,6 @@ static struct vboot_operations direct_boot_ops = {
|
||||
.get_ap_trampoline = get_direct_boot_ap_trampoline,
|
||||
.get_rsdp = get_direct_boot_rsdp,
|
||||
.init_irq = init_direct_boot_irq,
|
||||
.init_vboot_info = init_direct_vboot_info,
|
||||
};
|
||||
|
||||
struct vboot_operations* get_direct_boot_ops(void)
|
||||
|
@ -1,11 +1,15 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <types.h>
|
||||
#include <rtl.h>
|
||||
#include <errno.h>
|
||||
#include <per_cpu.h>
|
||||
#include <irq.h>
|
||||
#include <boot_context.h>
|
||||
#include <sprintf.h>
|
||||
#include <multiboot.h>
|
||||
#include <pgtable.h>
|
||||
@ -14,6 +18,7 @@
|
||||
#include <mmu.h>
|
||||
#include <vm.h>
|
||||
#include <logmsg.h>
|
||||
#include <deprivilege_boot.h>
|
||||
|
||||
#define ACRN_DBG_BOOT 6U
|
||||
|
||||
@ -150,16 +155,7 @@ static void *get_kernel_load_addr(void *kernel_src_addr)
|
||||
return (void *)zeropage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param[inout] vm pointer to a vm descriptor
|
||||
*
|
||||
* @retval 0 on success
|
||||
* @retval -EINVAL on invalid parameters
|
||||
*
|
||||
* @pre vm != NULL
|
||||
* @pre is_sos_vm(vm) == true
|
||||
*/
|
||||
int32_t init_direct_vboot_info(struct acrn_vm *vm)
|
||||
static int32_t init_general_vm_boot_info(struct acrn_vm *vm)
|
||||
{
|
||||
struct multiboot_module *mods = NULL;
|
||||
struct multiboot_info *mbi = NULL;
|
||||
@ -238,3 +234,70 @@ int32_t init_direct_vboot_info(struct acrn_vm *vm)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void depri_boot_spurious_handler(uint32_t vector)
|
||||
{
|
||||
if (get_pcpu_id() == BOOT_CPU_ID) {
|
||||
struct acrn_vcpu *vcpu = per_cpu(vcpu, BOOT_CPU_ID);
|
||||
|
||||
if (vcpu != NULL) {
|
||||
vlapic_set_intr(vcpu, vector, LAPIC_TRIG_EDGE);
|
||||
} else {
|
||||
pr_err("%s vcpu or vlapic is not ready, interrupt lost\n", __func__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t depri_boot_sw_loader(struct acrn_vm *vm)
|
||||
{
|
||||
int32_t ret = 0;
|
||||
/* get primary vcpu */
|
||||
struct acrn_vcpu *vcpu = vcpu_from_vid(vm, BOOT_CPU_ID);
|
||||
struct acrn_vcpu_regs *vcpu_regs = &boot_context;
|
||||
const struct depri_boot_context *depri_boot_ctx = get_depri_boot_ctx();
|
||||
const struct lapic_regs *depri_boot_lapic_regs = get_depri_boot_lapic_regs();
|
||||
|
||||
pr_dbg("Loading guest to run-time location");
|
||||
|
||||
vlapic_restore(vcpu_vlapic(vcpu), depri_boot_lapic_regs);
|
||||
|
||||
/* For UEFI platform, the bsp init regs come from two places:
|
||||
* 1. saved in depri_boot: gpregs, rip
|
||||
* 2. saved when HV started: other registers
|
||||
* We copy the info saved in depri_boot to boot_context and
|
||||
* init bsp with boot_context.
|
||||
*/
|
||||
memcpy_s(&(vcpu_regs->gprs), sizeof(struct acrn_gp_regs),
|
||||
&(depri_boot_ctx->vcpu_regs.gprs), sizeof(struct acrn_gp_regs));
|
||||
|
||||
vcpu_regs->rip = depri_boot_ctx->vcpu_regs.rip;
|
||||
set_vcpu_regs(vcpu, vcpu_regs);
|
||||
|
||||
/* defer irq enabling till vlapic is ready */
|
||||
spurious_handler = depri_boot_spurious_handler;
|
||||
CPU_IRQ_ENABLE();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param[inout] vm pointer to a vm descriptor
|
||||
*
|
||||
* @retval 0 on success
|
||||
* @retval -EINVAL on invalid parameters
|
||||
*
|
||||
* @pre vm != NULL
|
||||
*/
|
||||
int32_t init_vm_boot_info(struct acrn_vm *vm)
|
||||
{
|
||||
int32_t ret = 0;
|
||||
|
||||
if (is_sos_vm(vm) && (get_sos_boot_mode() == DEPRI_BOOT_MODE)) {
|
||||
vm_sw_loader = depri_boot_sw_loader;
|
||||
} else {
|
||||
vm_sw_loader = direct_boot_sw_loader;
|
||||
ret = init_general_vm_boot_info(vm);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
@ -95,9 +95,3 @@ void init_vboot_irq(void)
|
||||
{
|
||||
return vboot_ops->init_irq();
|
||||
}
|
||||
|
||||
/* @pre: vboot_ops->init_vboot_info != NULL */
|
||||
int32_t init_vm_boot_info(struct acrn_vm *vm)
|
||||
{
|
||||
return vboot_ops->init_vboot_info(vm);
|
||||
}
|
||||
|
@ -19,6 +19,5 @@ 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);
|
||||
int32_t init_depri_vboot_info(__unused struct acrn_vm *vm);
|
||||
|
||||
#endif /* end of include guard: DEPRIVILEGE_BOOT_H */
|
||||
|
@ -11,6 +11,5 @@
|
||||
#include <vboot.h>
|
||||
|
||||
struct vboot_operations* get_direct_boot_ops(void);
|
||||
int32_t init_direct_vboot_info(struct acrn_vm *vm);
|
||||
|
||||
#endif /* end of include guard: DIRECT_BOOT_H */
|
||||
|
@ -13,19 +13,16 @@ enum vboot_mode {
|
||||
DEPRI_BOOT_MODE
|
||||
};
|
||||
|
||||
struct acrn_vm;
|
||||
struct vboot_operations {
|
||||
void (*init)(void);
|
||||
uint64_t (*get_ap_trampoline)(void);
|
||||
void *(*get_rsdp)(void);
|
||||
void (*init_irq)(void);
|
||||
int32_t (*init_vboot_info)(struct acrn_vm *vm);
|
||||
};
|
||||
|
||||
void init_vboot_operations(void);
|
||||
void init_vboot(void);
|
||||
void init_vboot_irq(void);
|
||||
int32_t init_vm_boot_info(struct acrn_vm *vm);
|
||||
uint64_t get_ap_trampoline_buf(void);
|
||||
void *get_rsdp_ptr(void);
|
||||
|
||||
|
13
hypervisor/boot/include/guest/vboot_info.h
Normal file
13
hypervisor/boot/include/guest/vboot_info.h
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef VBOOT_INFO_H
|
||||
|
||||
#define VBOOT_INFO_H
|
||||
|
||||
int32_t init_vm_boot_info(struct acrn_vm *vm);
|
||||
|
||||
#endif /* end of include guard: VBOOT_INFO_H */
|
@ -97,7 +97,7 @@ static uint64_t create_zero_page(struct acrn_vm *vm)
|
||||
return gpa;
|
||||
}
|
||||
|
||||
int32_t general_sw_loader(struct acrn_vm *vm)
|
||||
int32_t direct_boot_sw_loader(struct acrn_vm *vm)
|
||||
{
|
||||
int32_t ret = 0;
|
||||
char dyn_bootargs[100] = {0};
|
||||
|
@ -210,7 +210,7 @@ uint16_t get_vmid_by_uuid(const uint8_t *uuid);
|
||||
struct acrn_vm *get_vm_from_vmid(uint16_t vm_id);
|
||||
struct acrn_vm *get_sos_vm(void);
|
||||
|
||||
int32_t general_sw_loader(struct acrn_vm *vm);
|
||||
int32_t direct_boot_sw_loader(struct acrn_vm *vm);
|
||||
|
||||
typedef int32_t (*vm_sw_loader_t)(struct acrn_vm *vm);
|
||||
extern vm_sw_loader_t vm_sw_loader;
|
||||
|
Loading…
Reference in New Issue
Block a user