HV: modularization: use loader_name char array in acrn boot info

The patch has below changes:
	1. rename mi_loader_name in acrn_boot_info struct to loader_name;
	2. change loader_name type from pointer to array to avoid accessing
	   original multiboot info region;
	3. remove mi_drivers_length and mi_drivers_addr which are never used;

Tracked-On: #5661

Signed-off-by: Victor Sun <victor.sun@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
Victor Sun 2021-06-08 10:58:54 +08:00 committed by wenlingz
parent 484d3ec9df
commit 16624bab5e
4 changed files with 11 additions and 9 deletions

View File

@ -37,11 +37,11 @@ int32_t sanitize_acrn_boot_info(struct acrn_boot_info *abi)
pr_err("no uefi info found!");
}
if (abi->mi_loader_name[0] == '\0') {
if (abi->loader_name[0] == '\0') {
pr_err("no bootloader name found!");
abi_status = -EINVAL;
} else {
printf("%s Bootloader: %s\n", abi->protocol_name, abi->mi_loader_name);
printf("%s Bootloader: %s\n", abi->protocol_name, abi->loader_name);
}
return abi_status;

View File

@ -15,7 +15,7 @@
#define MAX_MMAP_ENTRIES 32U
#define MAX_BOOTARGS_SIZE 2048U
#define MAX_LOADER_NAME_SIZE 32U
#define MAX_PROTOCOL_NAME_SIZE 16U
/* The modules in multiboot are: Pre-launched VM: kernel/ramdisk/acpi; SOS VM: kernel/ramdisk */
@ -28,14 +28,11 @@ struct acrn_boot_info {
char protocol_name[MAX_PROTOCOL_NAME_SIZE];
const char cmdline[MAX_BOOTARGS_SIZE];
const char *mi_loader_name;
const char loader_name[MAX_LOADER_NAME_SIZE];
uint32_t mi_mods_count;
struct multiboot_module mi_mods[MAX_MODULE_NUM];
uint32_t mi_drives_length;
uint32_t mi_drives_addr;
uint32_t mi_mmap_entries;
struct multiboot_mmap mi_mmap_entry[MAX_MMAP_ENTRIES];

View File

@ -21,7 +21,10 @@ int32_t multiboot_to_acrn_bi(struct acrn_boot_info *abi, void *mb_info) {
(void)strncpy_s((void *)(abi->cmdline), MAX_BOOTARGS_SIZE, (char *)hpa2hva_early((uint64_t)mbi->mi_cmdline),
strnlen_s((char *)hpa2hva_early((uint64_t)mbi->mi_cmdline), (MAX_BOOTARGS_SIZE - 1U)));
abi->mi_loader_name = (char *)hpa2hva_early((uint64_t)mbi->mi_loader_name);
(void)strncpy_s((void *)(abi->loader_name), MAX_LOADER_NAME_SIZE,
(char *)hpa2hva_early((uint64_t)mbi->mi_loader_name),
strnlen_s((char *)hpa2hva_early((uint64_t)mbi->mi_loader_name), (MAX_LOADER_NAME_SIZE - 1U)));
abi->mi_mmap_entries = mbi->mi_mmap_length / sizeof(struct multiboot_mmap);
abi->mi_mods_count = mbi->mi_mods_count;

View File

@ -98,7 +98,9 @@ int32_t multiboot2_to_acrn_bi(struct acrn_boot_info *abi, void *mb2_info)
mod_idx++;
break;
case MULTIBOOT2_TAG_TYPE_BOOT_LOADER_NAME:
abi->mi_loader_name = ((struct multiboot2_tag_string *)mb2_tag)->string;
str = ((struct multiboot2_tag_string *)mb2_tag)->string;
(void)strncpy_s((void *)(abi->loader_name), MAX_LOADER_NAME_SIZE, str,
strnlen_s(str, (MAX_LOADER_NAME_SIZE - 1U)));
break;
case MULTIBOOT2_TAG_TYPE_ACPI_NEW:
abi->mi_acpi_rsdp_va = ((struct multiboot2_tag_new_acpi *)mb2_tag)->rsdp;