Skip to content

Commit d008b72

Browse files
jsun26intelwenlingz
authored andcommitted
HV: add multiboot2 header info
Add multiboot2 header info in HV image so that bootloader could recognize it. Tracked-On: #4419 Signed-off-by: Victor Sun <victor.sun@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 19ffaa5 commit d008b72

File tree

4 files changed

+173
-0
lines changed

4 files changed

+173
-0
lines changed

hypervisor/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ CFLAGS += -fcf-protection=none
107107
endif
108108

109109
ASFLAGS += -m64 -nostdinc -nostdlib
110+
ifeq (y, $(CONFIG_MULTIBOOT2))
111+
ASFLAGS += -DCONFIG_MULTIBOOT2
112+
endif
110113

111114
LDFLAGS += -Wl,--gc-sections -nostartfiles -nostdlib
112115
LDFLAGS += -Wl,-n,-z,max-page-size=0x1000

hypervisor/arch/x86/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ config HYBRID
3737

3838
endchoice
3939

40+
config MULTIBOOT2
41+
bool "Multiboot2 support"
42+
default n
43+
help
44+
Support boot ACRN from multiboot2 protocol. Multiboot2 support is needed for
45+
some EFI platforms to get correct ACPI RSDP, it also could provide host efi
46+
information for hypervisor.
47+
4048
choice
4149
prompt "ACRN Scheduler"
4250
default SCHED_NOOP

hypervisor/arch/x86/boot/cpu_primary.S

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
*/
2323

2424
#include <multiboot.h>
25+
#ifdef CONFIG_MULTIBOOT2
26+
#include <multiboot2.h>
27+
#endif
28+
2529
/* MULTIBOOT HEADER */
2630
#define MULTIBOOT_HEADER_FLAGS MULTIBOOT_HEADER_NEED_MEMINFO
2731

@@ -38,6 +42,33 @@
3842
/* header checksum = -(magic + flags) */
3943
.long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
4044

45+
#ifdef CONFIG_MULTIBOOT2
46+
.align MULTIBOOT2_HEADER_ALIGN
47+
mb2_header_start:
48+
/* Magic number indicating a Multiboot2 header. */
49+
.long MULTIBOOT2_HEADER_MAGIC
50+
/* Architecture: i386. */
51+
.long MULTIBOOT2_ARCHITECTURE_I386
52+
/* Multiboot2 header length. */
53+
.long mb2_header_end - mb2_header_start
54+
/* Multiboot2 header checksum. */
55+
.long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_ARCHITECTURE_I386 + (mb2_header_end - mb2_header_start))
56+
57+
/* please be aware that each tag should be 8 bytes aligned */
58+
.align MULTIBOOT2_TAG_ALIGN
59+
info_req_tag_start:
60+
.short MULTIBOOT2_HEADER_TAG_INFORMATION_REQUEST
61+
.short 0
62+
.long info_req_tag_end - info_req_tag_start
63+
.long MULTIBOOT2_TAG_TYPE_MMAP
64+
info_req_tag_end:
65+
66+
.align MULTIBOOT2_TAG_ALIGN
67+
.short MULTIBOOT2_HEADER_TAG_END
68+
.short 0
69+
.long 8
70+
mb2_header_end:
71+
#endif
4172
.section entry, "ax"
4273

4374
.align 8

hypervisor/boot/include/multiboot2.h

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/*
2+
* Copyright (C) 2020 Intel Corporation. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
/* multiboot2.h - Multiboot 2 header file. */
8+
/* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc.
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining a copy
11+
* of this software and associated documentation files (the "Software"), to
12+
* deal in the Software without restriction, including without limitation the
13+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14+
* sell copies of the Software, and to permit persons to whom the Software is
15+
* furnished to do so, subject to the following conditions:
16+
*
17+
* The above copyright notice and this permission notice shall be included in
18+
* all copies or substantial portions of the Software.
19+
*
20+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY
23+
* DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
25+
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26+
*/
27+
28+
#ifndef MULTIBOOT2_H
29+
#define MULTIBOOT2_H
30+
31+
#define MULTIBOOT2_HEADER_ALIGN 8
32+
33+
#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6U
34+
35+
/* This should be in %eax. */
36+
#define MULTIBOOT2_INFO_MAGIC 0x36d76289U
37+
38+
/* Alignment of the multiboot info structure. */
39+
#define MULTIBOOT2_INFO_ALIGN 0x00000008U
40+
41+
/* Flags set in the 'flags' member of the multiboot header. */
42+
43+
#define MULTIBOOT2_TAG_ALIGN 8U
44+
#define MULTIBOOT2_TAG_TYPE_END 0U
45+
#define MULTIBOOT2_TAG_TYPE_CMDLINE 1U
46+
#define MULTIBOOT2_TAG_TYPE_BOOT_LOADER_NAME 2U
47+
#define MULTIBOOT2_TAG_TYPE_MODULE 3U
48+
#define MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO 4U
49+
#define MULTIBOOT2_TAG_TYPE_BOOTDEV 5U
50+
#define MULTIBOOT2_TAG_TYPE_MMAP 6U
51+
#define MULTIBOOT2_TAG_TYPE_VBE 7U
52+
#define MULTIBOOT2_TAG_TYPE_FRAMEBUFFER 8U
53+
#define MULTIBOOT2_TAG_TYPE_ELF_SECTIONS 9U
54+
#define MULTIBOOT2_TAG_TYPE_APM 10U
55+
#define MULTIBOOT2_TAG_TYPE_EFI32 11U
56+
#define MULTIBOOT2_TAG_TYPE_EFI64 12U
57+
#define MULTIBOOT2_TAG_TYPE_SMBIOS 13U
58+
#define MULTIBOOT2_TAG_TYPE_ACPI_OLD 14U
59+
#define MULTIBOOT2_TAG_TYPE_ACPI_NEW 15U
60+
#define MULTIBOOT2_TAG_TYPE_NETWORK 16U
61+
#define MULTIBOOT2_TAG_TYPE_EFI_MMAP 17U
62+
#define MULTIBOOT2_TAG_TYPE_EFI_BS 18U
63+
#define MULTIBOOT2_TAG_TYPE_EFI32_IH 19U
64+
#define MULTIBOOT2_TAG_TYPE_EFI64_IH 20U
65+
#define MULTIBOOT2_TAG_TYPE_LOAD_BASE_ADDR 21U
66+
67+
#define MULTIBOOT2_HEADER_TAG_END 0
68+
#define MULTIBOOT2_HEADER_TAG_INFORMATION_REQUEST 1
69+
#define MULTIBOOT2_HEADER_TAG_ADDRESS 2
70+
#define MULTIBOOT2_HEADER_TAG_ENTRY_ADDRESS 3
71+
#define MULTIBOOT2_HEADER_TAG_CONSOLE_FLAGS 4
72+
#define MULTIBOOT2_HEADER_TAG_FRAMEBUFFER 5
73+
#define MULTIBOOT2_HEADER_TAG_MODULE_ALIGN 6
74+
#define MULTIBOOT2_HEADER_TAG_EFI_BS 7
75+
#define MULTIBOOT2_HEADER_TAG_ENTRY_ADDRESS_EFI32 8
76+
#define MULTIBOOT2_HEADER_TAG_ENTRY_ADDRESS_EFI64 9
77+
#define MULTIBOOT2_HEADER_TAG_RELOCATABLE 10
78+
79+
#define MULTIBOOT2_ARCHITECTURE_I386 0
80+
#define MULTIBOOT2_ARCHITECTURE_MIPS32 4
81+
82+
#ifndef ASSEMBLER
83+
struct multiboot2_mmap_entry
84+
{
85+
uint64_t addr;
86+
uint64_t len;
87+
uint32_t type;
88+
uint32_t zero;
89+
};
90+
91+
struct multiboot2_tag
92+
{
93+
uint32_t type;
94+
uint32_t size;
95+
};
96+
97+
struct multiboot2_tag_string
98+
{
99+
uint32_t type;
100+
uint32_t size;
101+
char string[0];
102+
};
103+
104+
struct multiboot2_tag_module
105+
{
106+
uint32_t type;
107+
uint32_t size;
108+
uint32_t mod_start;
109+
uint32_t mod_end;
110+
char cmdline[0];
111+
};
112+
113+
struct multiboot2_tag_mmap
114+
{
115+
uint32_t type;
116+
uint32_t size;
117+
uint32_t entry_size;
118+
uint32_t entry_version;
119+
struct multiboot2_mmap_entry entries[0];
120+
};
121+
122+
struct multiboot2_tag_new_acpi
123+
{
124+
uint32_t type;
125+
uint32_t size;
126+
uint8_t rsdp[0];
127+
};
128+
129+
#endif /* ASSEMBLER */
130+
131+
#endif /* MULTIBOOT2_H */

0 commit comments

Comments
 (0)