mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-10-08 18:25:05 +00:00
HV: init and sanitize acrn multiboot info
Initialize and sanitize a acrn specific multiboot info struct with current supported multiboot1 in very early boot stage, which would bring below benifits: - don't need to do hpa2hva convention every time when refering boot_regs; - panic early if failed to sanitize multiboot info, so that don't need to check multiboot info pointer/flags and panic in later boot process; - keep most code unchanged when introduce multiboot2 support in future; Tracked-On: #4419 Signed-off-by: Victor Sun <victor.sun@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -31,8 +31,7 @@ static enum vboot_mode sos_boot_mode;
|
||||
*/
|
||||
void init_vboot(void)
|
||||
{
|
||||
|
||||
struct multiboot_info *mbi;
|
||||
struct acrn_multiboot_info *mbi = get_multiboot_info();
|
||||
uint32_t i;
|
||||
|
||||
const struct vboot_bootloader_map vboot_bootloader_maps[BOOTLOADER_NUM] = {
|
||||
@@ -43,23 +42,18 @@ void init_vboot(void)
|
||||
{"PXELINUX", DIRECT_BOOT_MODE},
|
||||
};
|
||||
|
||||
mbi = (struct multiboot_info *)hpa2hva((uint64_t)boot_regs[1]);
|
||||
if (mbi == NULL) {
|
||||
panic("No multiboot info");
|
||||
} else {
|
||||
for (i = 0U; i < BOOTLOADER_NUM; i++) {
|
||||
if (strncmp(hpa2hva(mbi->mi_loader_name), vboot_bootloader_maps[i].bootloader_name,
|
||||
strnlen_s(vboot_bootloader_maps[i].bootloader_name, BOOTLOADER_NAME_SIZE)) == 0) {
|
||||
/* Only support two vboot mode */
|
||||
if (vboot_bootloader_maps[i].mode == DEPRI_BOOT_MODE) {
|
||||
vboot_ops = get_deprivilege_boot_ops();
|
||||
sos_boot_mode = DEPRI_BOOT_MODE;
|
||||
} else {
|
||||
vboot_ops = get_direct_boot_ops();
|
||||
sos_boot_mode = DIRECT_BOOT_MODE;
|
||||
}
|
||||
break;
|
||||
for (i = 0U; i < BOOTLOADER_NUM; i++) {
|
||||
if (strncmp(mbi->mi_loader_name, vboot_bootloader_maps[i].bootloader_name,
|
||||
strnlen_s(vboot_bootloader_maps[i].bootloader_name, BOOTLOADER_NAME_SIZE)) == 0) {
|
||||
/* Only support two vboot mode */
|
||||
if (vboot_bootloader_maps[i].mode == DEPRI_BOOT_MODE) {
|
||||
vboot_ops = get_deprivilege_boot_ops();
|
||||
sos_boot_mode = DEPRI_BOOT_MODE;
|
||||
} else {
|
||||
vboot_ops = get_direct_boot_ops();
|
||||
sos_boot_mode = DIRECT_BOOT_MODE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user