hv: vboot: init fdt module for pre-launched VM

Pre-launched VM needs to load pre-compiled FDT binary (which is the same
when it needs pre-compiled ACPI binary).

Tracked-On: #8838
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
Acked-by: Wang Yu1 <yu1.wang@intel.com>
This commit is contained in:
Yifan Liu
2025-10-06 03:14:08 +00:00
committed by acrnsi-robot
parent b5098f8f25
commit f8f57328b6
3 changed files with 39 additions and 2 deletions

View File

@@ -17,6 +17,7 @@
#include <logmsg.h>
#include <vboot.h>
#include <vacpi.h>
#include <vfdt.h>
#ifdef ARCH_VBOOT_SEED_SUPPORT
#include <asm/seed.h>
#endif
@@ -46,6 +47,16 @@ static void init_vm_acpi_info(struct acrn_vm *vm, const struct abi_module *mod)
vm->sw.acpi_info.size = ACPI_MODULE_SIZE;
}
/* TODO: For statically built FDT, the logic is almost the same as ACPI.
* merge them into "hardware description mechanism" flow.
*/
static void init_vm_fdt_info(struct acrn_vm *vm, const struct abi_module *mod)
{
vm->sw.fdt_info.src_addr = mod->start;
vm->sw.fdt_info.size = mod->size;
vm->sw.fdt_info.load_addr = (void *)VIRT_FDT_LOAD_ADDR;
}
/**
* @pre vm != NULL && mod != NULL
*/
@@ -168,6 +179,7 @@ static int32_t init_vm_sw_load(struct acrn_vm *vm, const struct acrn_boot_info *
struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id);
struct abi_module *mod;
int32_t ret = -EINVAL;
bool fw_loaded = false;
dev_dbg(DBG_LEVEL_BOOT, "mod counts=%d\n", abi->mods_count);
@@ -198,11 +210,20 @@ static int32_t init_vm_sw_load(struct acrn_vm *vm, const struct acrn_boot_info *
}
if (is_prelaunched_vm(vm)) {
/* Load ACPI and/or FDT, whichever is available */
mod = get_mod_by_tag(abi, vm_config->acpi_config.acpi_mod_tag);
if ((mod != NULL) && (mod->size == ACPI_MODULE_SIZE)) {
init_vm_acpi_info(vm, mod);
} else {
pr_err("failed to load VM %d acpi module", vm->vm_id);
fw_loaded = true;
}
mod = get_mod_by_tag(abi, vm_config->fdt_config.fdt_mod_tag);
if (mod != NULL) {
init_vm_fdt_info(vm, mod);
fw_loaded = true;
}
if (!fw_loaded) {
pr_err("failed to load ACPI module or FDT for VM%d", vm->vm_id);
}
}

View File

@@ -52,6 +52,7 @@ int32_t prepare_os_image(struct acrn_vm *vm)
if (ret == 0) {
/* Copy Guest OS ACPI to its load location */
load_sw_module(vm, acpi_info);
load_sw_module(vm, &(vm->sw.fdt_info));
pr_dbg("%s, VM%hu 0x%016lx", __func__, vm->vm_id,
vm->sw.kernel_info.kernel_entry_addr);
}

View File

@@ -0,0 +1,15 @@
/*
* Copyright (C) 2019-2022 Intel Corporation.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef VFDT_H
#define VFDT_H
/* Use a pre-loaded multiboot module as pre-launched VM FDT.
* The module file should be generated by acrn-config tool;
*/
#define VIRT_FDT_LOAD_ADDR 0x80200000UL
#endif /* VFDT_H */