Skip to content

Commit

Permalink
HV: add hv cmdline support for multiboot2
Browse files Browse the repository at this point in the history
The multiboot2 cmdline would be used as hypervisor cmdline, add parse logic
for the case that hypervisor boot from multiboot2 protocol.

Tracked-On: projectacrn#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>
  • Loading branch information
jsun26intel authored and wenlingz committed Jun 8, 2020
1 parent c74b194 commit 45d1f38
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
13 changes: 4 additions & 9 deletions hypervisor/boot/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
5 changes: 5 additions & 0 deletions hypervisor/boot/include/boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions hypervisor/boot/multiboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions hypervisor/boot/multiboot2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 45d1f38

Please sign in to comment.