Skip to content

Commit d305424

Browse files
committed
pvh: Support booting via PVH ELFNOTE
This PR adds support for booting via the Xen HVM direct boot ABI. See: https://xenbits.xen.org/docs/4.12-testing/misc/pvh.html This uses a 32-bit unpaged entry point, so we just point it at ram32_start. This allows our firmware to be used with QEMU's -kernel option. Signed-off-by: Joe Richey <joerichey@google.com>
1 parent 7826a04 commit d305424

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

layout.ld

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ ENTRY(ram64_start)
22

33
PHDRS
44
{
5+
notes PT_NOTE ;
56
rodata PT_LOAD FILEHDR PHDRS ;
67
data PT_LOAD ;
78
text PT_LOAD ;
@@ -23,6 +24,7 @@ SECTIONS
2324
. = ram_min;
2425
. += SIZEOF_HEADERS;
2526

27+
.notes : { *(.note .note.* .notes) } :rodata :notes
2628
.rodata : { *(.rodata .rodata.*) } :rodata
2729
.data : { *(.data .data.*) *(.bss .bss.*) } :data
2830
.text : {

src/asm/notes.s

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.section .notes, "a"
2+
3+
# From xen/include/public/elfnote.h, "Physical entry point into the kernel."
4+
XEN_ELFNOTE_PHYS32_ENTRY = 18
5+
6+
# We don't bother defining an ELFNOTE macro, as we only have one note.
7+
# This is equialent to the kernel's:
8+
# ELFNOTE(Xen, XEN_ELFNOTE_PHYS32_ENTRY, .long ram32_start)
9+
.align 4
10+
.long name_end - name_start # namesz
11+
.long desc_end - desc_start # descsz
12+
.long XEN_ELFNOTE_PHYS32_ENTRY # type
13+
name_start:
14+
.asciz "Xen"
15+
name_end:
16+
.align 4
17+
desc_start:
18+
.long ram32_start
19+
desc_end:
20+
.align 4

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ mod virtio;
4141
#[cfg(all(not(test), feature = "rom"))]
4242
global_asm!(include_str!("asm/rom.s"));
4343
#[cfg(not(test))]
44+
global_asm!(include_str!("asm/notes.s"));
45+
#[cfg(not(test))]
4446
global_asm!(include_str!("asm/ram32.s"));
4547
#[cfg(not(test))]
4648
global_asm!(include_str!("asm/ram64.s"));

0 commit comments

Comments
 (0)