Files
acrn-hypervisor/hypervisor/boot/guest/rawimage_loader.c
Yifan Liu 7bcb81314f hv: riscv: initialize service vm vfdt
Initialize Service VM vFDT by reserving hypervisor and pre-launched VM
memory regions.

The vFDT is copied to Service VM to the place just before the kernel
load address, and this needs to be fixed later when MMU module is
implemented.

Tracked-On: #8841
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
Acked-by: Wang Yu1 <yu1.wang@intel.com>
2025-11-14 10:44:41 +08:00

43 lines
1.1 KiB
C

/*
* Copyright (C) 2021-2022 Intel Corporation.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <vm.h>
#include <vboot.h>
#include <guest_memory.h>
#include <pgtable.h>
/**
* @pre vm != NULL
*/
static void load_rawimage(struct acrn_vm *vm)
{
struct sw_kernel_info *sw_kernel = &(vm->sw.kernel_info);
const struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id);
uint64_t kernel_load_gpa;
/* TODO: GPA 0 load support */
kernel_load_gpa = vm_config->os_config.kernel_load_addr;
/* TODO: For simplicity assume there are enough space just before kernel load address
* Fix this after implementing find_space_from_vm_vfdt API
*/
if (vm->sw.fdt_info.src_addr != NULL) {
vm->sw.fdt_info.load_addr = (void *)round_page_down(kernel_load_gpa - MAX_FDT_SIZE);
}
/* Copy the guest kernel image to its run-time location */
(void)copy_to_gpa(vm, sw_kernel->kernel_src_addr, kernel_load_gpa, sw_kernel->kernel_size);
sw_kernel->kernel_entry_addr = (void *)vm_config->os_config.kernel_entry_addr;
}
int32_t rawimage_loader(struct acrn_vm *vm)
{
load_rawimage(vm);
return 0;
}