HV: vm_load: refine api of get_bzimage_kernel_load_addr()
As the previous commit said the kernel load address should be moved
from init_vm_sw_load() to vm_sw_loader() stage. This patch refines
the API of get_bzimage_kernel_load_addr() in init_vm_kernel_info()
for later use.
@@ -145,15 +145,12 @@ static void init_vm_acpi_info(struct acrn_vm *vm, const struct abi_module *mod)
/**
* @pre vm != NULL
*/
-static void *get_kernel_load_addr(struct acrn_vm *vm)
+static void *get_bzimage_kernel_load_addr(struct acrn_vm *vm)
{
void *load_addr = NULL;
struct vm_sw_info *sw_info = &vm->sw;
struct zero_page *zeropage;
- struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id);
- switch (sw_info->kernel_type) {
- case KERNEL_BZIMAGE:
/* According to the explaination for pref_address
* in Documentation/x86/boot.txt, a relocating
* bootloader should attempt to load kernel at pref_address
@@ -196,14 +193,7 @@ static void *get_kernel_load_addr(struct acrn_vm *vm)
pr_err("Non-relocatable kernel found, risk to boot!");
}
}
- break;
- case KERNEL_ZEPHYR:
- load_addr = (void *)vm_config->os_config.kernel_load_addr;
- break;
- default:
- pr_err("Unsupported Kernel type.");
- break;
- }
+
if (load_addr == NULL) {
pr_err("Could not get kernel load addr of VM %d .", vm->vm_id);
}
@@ -226,7 +216,13 @@ static int32_t init_vm_kernel_info(struct acrn_vm *vm, const struct abi_module *
vm->sw.kernel_info.kernel_src_addr = mod->start;
if (vm->sw.kernel_info.kernel_src_addr != NULL) {
vm->sw.kernel_info.kernel_size = mod->size;
- vm->sw.kernel_info.kernel_load_addr = get_kernel_load_addr(vm);
+ if (vm->sw.kernel_type == KERNEL_BZIMAGE) {
+ vm->sw.kernel_info.kernel_load_addr = get_bzimage_kernel_load_addr(vm);
+ } else if (vm->sw.kernel_type == KERNEL_ZEPHYR) {
+ vm->sw.kernel_info.kernel_load_addr = (void *)vm_config->os_config.kernel_load_addr;
+ } else {
+ pr_err("Unsupported Kernel type.");
+ }
}
return (vm->sw.kernel_info.kernel_load_addr == NULL) ? (-EINVAL) : 0;
