mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-11-15 12:00:26 +00:00
This commit moves struct acrn_vm under common header vm.h, and move some x86-specific members of struct acrn_vm into arch_vm. This commit focuses on struct cleanup only. API cleanup will be in future patch series. The affected members are: e820_entry_num e820_entries wire_mode wbinvd_lock vlapic_mode_lock vcpuid_entry_nr vcpuid_level vcpuid_xlevel vcpuid_entries reset_control pm sworld_control sworld_snapshot intr_inject_delay_delta Moved to common vm.h: ept_lock -> rename to stg2pt_lock ept_pgtable -> rename to stg2_pgtable nworld_eptp -> rename to root_stg2ptp emul_mmio_lock nr_emul_mmio_regions emul_mmio emul_pio To avoid circular dependency, some in-header helpers are also moved into common vm.h. Tracked-On: #8830 Signed-off-by: Yifan Liu <yifan1.liu@intel.com> Reviewed-by: Fei Li <fei1.li@intel.com> Acked-by: Wang Yu1 <yu1.wang@intel.com>
64 lines
1.4 KiB
C
64 lines
1.4 KiB
C
/*
|
|
* Copyright (C) 2018-2022 Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <vm.h>
|
|
#include <vboot.h>
|
|
#include <errno.h>
|
|
#include <logmsg.h>
|
|
|
|
/**
|
|
* @pre sw_module != NULL
|
|
*/
|
|
void load_sw_module(struct acrn_vm *vm, struct sw_module_info *sw_module)
|
|
{
|
|
if ((sw_module->size != 0) && (sw_module->load_addr != NULL)) {
|
|
(void)copy_to_gpa(vm, sw_module->src_addr, (uint64_t)sw_module->load_addr, sw_module->size);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @pre vm != NULL
|
|
*/
|
|
int32_t prepare_os_image(struct acrn_vm *vm)
|
|
{
|
|
int32_t ret = -EINVAL;
|
|
/* get primary vcpu */
|
|
struct acrn_vcpu *vcpu = vcpu_from_vid(vm, BSP_CPU_ID);
|
|
struct sw_module_info *acpi_info = &(vm->sw.acpi_info);
|
|
|
|
switch (vm->sw.kernel_type) {
|
|
#ifdef CONFIG_GUEST_KERNEL_BZIMAGE
|
|
case KERNEL_BZIMAGE:
|
|
ret = bzimage_loader(vm);
|
|
break;
|
|
#endif
|
|
#ifdef CONFIG_GUEST_KERNEL_RAWIMAGE
|
|
case KERNEL_RAWIMAGE:
|
|
ret = rawimage_loader(vm);
|
|
break;
|
|
#endif
|
|
#ifdef CONFIG_GUEST_KERNEL_ELF
|
|
case KERNEL_ELF:
|
|
ret = elf_loader(vm);
|
|
break;
|
|
#endif
|
|
default:
|
|
ret = -EINVAL;
|
|
break;
|
|
}
|
|
|
|
if (ret == 0) {
|
|
/* Copy Guest OS ACPI to its load location */
|
|
load_sw_module(vm, acpi_info);
|
|
/* Set VCPU entry point to kernel entry */
|
|
vcpu_set_rip(vcpu, (uint64_t)vm->sw.kernel_info.kernel_entry_addr);
|
|
pr_info("%s, VM %hu VCPU %hu Entry: 0x%016lx ", __func__, vm->vm_id, vcpu->vcpu_id,
|
|
vm->sw.kernel_info.kernel_entry_addr);
|
|
}
|
|
|
|
return ret;
|
|
}
|