diff --git a/hypervisor/boot/guest/vboot_info.c b/hypervisor/boot/guest/vboot_info.c index f833d1122..502b6a25b 100644 --- a/hypervisor/boot/guest/vboot_info.c +++ b/hypervisor/boot/guest/vboot_info.c @@ -17,6 +17,7 @@ #include #include #include +#include #ifdef ARCH_VBOOT_SEED_SUPPORT #include #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); } } diff --git a/hypervisor/common/vm_load.c b/hypervisor/common/vm_load.c index 4d6aa5769..cea9e13b8 100644 --- a/hypervisor/common/vm_load.c +++ b/hypervisor/common/vm_load.c @@ -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); } diff --git a/hypervisor/include/dm/vfdt.h b/hypervisor/include/dm/vfdt.h new file mode 100644 index 000000000..dcec0b4bf --- /dev/null +++ b/hypervisor/include/dm/vfdt.h @@ -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 */