HV: add hv cmdline support for multiboot2

The multiboot2 cmdline would be used as hypervisor cmdline, add parse logic
for the case that hypervisor boot from multiboot2 protocol.

Tracked-On: #4885

Signed-off-by: Victor Sun <victor.sun@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Victor Sun 2020-06-02 21:31:35 +08:00 committed by wenlingz
parent c74b1941a0
commit 45d1f38a5b
4 changed files with 17 additions and 11 deletions

View File

@ -9,19 +9,14 @@
#include <boot.h>
#include <pgtable.h>
#include <dbg_cmd.h>
#include <logmsg.h>
void parse_hv_cmdline(void)
{
const char *start = NULL;
const char *end = NULL;
const char *start = NULL, *end = NULL;
struct acrn_multiboot_info *mbi = &acrn_mbi;
if (boot_from_multiboot1()) {
struct multiboot_info *mbi = (struct multiboot_info *)(hpa2hva_early((uint64_t)boot_regs[1]));
if ((mbi->mi_flags & MULTIBOOT_INFO_HAS_CMDLINE) != 0U) {
start = (char *)hpa2hva_early((uint64_t)mbi->mi_cmdline);
}
if ((mbi->mi_flags & MULTIBOOT_INFO_HAS_CMDLINE) != 0U) {
start = mbi->mi_cmdline;
}
while ((start != NULL) && ((*start) != '\0')) {

View File

@ -73,6 +73,11 @@ static inline bool boot_from_multiboot2(void)
int32_t multiboot2_to_acrn_mbi(struct acrn_multiboot_info *mbi, void *mb2_info);
#endif
/*
* The extern declaration for acrn_mbi is for cmdline.c use only, other functions should use
* get_multiboot_info() API to access struct acrn_mbi because it has explict @post condition
*/
extern struct acrn_multiboot_info acrn_mbi;
struct acrn_multiboot_info *get_multiboot_info(void);
void init_acrn_multiboot_info(void);
int32_t sanitize_multiboot_info(void);

View File

@ -11,7 +11,7 @@
#include <rtl.h>
#include <logmsg.h>
static struct acrn_multiboot_info acrn_mbi = { 0U };
struct acrn_multiboot_info acrn_mbi = { 0U };
static int32_t mbi_status;
@ -50,8 +50,10 @@ int32_t sanitize_multiboot_info(void)
} else if (boot_from_multiboot2()) {
pr_info("Multiboot2 detected.");
mmap_entry_size = sizeof(struct multiboot2_mmap_entry);
}
#endif
} else {
/* mbi_status is still -ENODEV, nothing to do here */
}
if ((acrn_mbi.mi_mmap_entries != 0U) && (acrn_mbi.mi_mmap_va != NULL)) {
if (acrn_mbi.mi_mmap_entries > E820_MAX_ENTRIES) {

View File

@ -72,6 +72,10 @@ int32_t multiboot2_to_acrn_mbi(struct acrn_multiboot_info *mbi, void *mb2_info)
while ((mb2_tag->type != MULTIBOOT2_TAG_TYPE_END) && (mb2_tag < mb2_tag_end)) {
switch (mb2_tag->type) {
case MULTIBOOT2_TAG_TYPE_CMDLINE:
mbi->mi_cmdline = ((struct multiboot2_tag_string *)mb2_tag)->string;
mbi->mi_flags |= MULTIBOOT_INFO_HAS_CMDLINE;
break;
case MULTIBOOT2_TAG_TYPE_MMAP:
mb2_mmap_to_mbi(mbi, (const struct multiboot2_tag_mmap *)mb2_tag);
break;