From f44fb6856b99fc2ff6840bea1db0a5e0e6a68fd7 Mon Sep 17 00:00:00 2001 From: Victor Sun Date: Tue, 2 Feb 2021 15:43:40 +0800 Subject: [PATCH] HV: init VM bootargs only for LaaG Currently the VM bootargs load address is hard-coded at 8KB right before kernel load address, this should work for Linux guest kernel only. Linux kernel bzImage boot protocol guarantees its load address to be high than GPA 8K so the address would never be overflowed, other OS like Zephyr has no such assumption. Tracked-On: #5689 Signed-off-by: Victor Sun Reviewed-by: Jason Chen CJ --- hypervisor/boot/guest/vboot_info.c | 5 ++++- hypervisor/common/vm_load.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hypervisor/boot/guest/vboot_info.c b/hypervisor/boot/guest/vboot_info.c index 71aad8921..e76cc1b58 100644 --- a/hypervisor/boot/guest/vboot_info.c +++ b/hypervisor/boot/guest/vboot_info.c @@ -225,7 +225,10 @@ static int32_t init_vm_sw_load(struct acrn_vm *vm, const struct acrn_multiboot_i } if (ret == 0) { - init_vm_bootargs_info(vm, mbi); + /* Currently VM bootargs only support Linux kernel bzImage format */ + if (vm->sw.kernel_type == KERNEL_BZIMAGE) { + init_vm_bootargs_info(vm, mbi); + } /* check whether there is a ramdisk module */ mod = get_mod_by_tag(mbi, vm_config->os_config.ramdisk_mod_tag); if (mod != NULL) { diff --git a/hypervisor/common/vm_load.c b/hypervisor/common/vm_load.c index 145d6d720..5e14dbedb 100644 --- a/hypervisor/common/vm_load.c +++ b/hypervisor/common/vm_load.c @@ -212,7 +212,7 @@ int32_t vm_sw_loader(struct acrn_vm *vm) ramdisk_info->size); } /* Copy Guest OS bootargs to its load location */ - if (bootargs_info->size != 0U) { + if ((bootargs_info->size != 0U) && (bootargs_info->load_addr != NULL)) { (void)copy_to_gpa(vm, bootargs_info->src_addr, (uint64_t)bootargs_info->load_addr, (strnlen_s((char *)bootargs_info->src_addr, MAX_BOOTARGS_SIZE) + 1U));