Skip to content

Commit

Permalink
pvh: Support booting via PVH ELFNOTE
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
josephlr committed Nov 14, 2019
1 parent 7826a04 commit d305424
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions layout.ld
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ENTRY(ram64_start)

PHDRS
{
notes PT_NOTE ;
rodata PT_LOAD FILEHDR PHDRS ;
data PT_LOAD ;
text PT_LOAD ;
Expand All @@ -23,6 +24,7 @@ SECTIONS
. = ram_min;
. += SIZEOF_HEADERS;

.notes : { *(.note .note.* .notes) } :rodata :notes
.rodata : { *(.rodata .rodata.*) } :rodata
.data : { *(.data .data.*) *(.bss .bss.*) } :data
.text : {
Expand Down
20 changes: 20 additions & 0 deletions src/asm/notes.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.section .notes, "a"

# From xen/include/public/elfnote.h, "Physical entry point into the kernel."
XEN_ELFNOTE_PHYS32_ENTRY = 18

# We don't bother defining an ELFNOTE macro, as we only have one note.
# This is equialent to the kernel's:
# ELFNOTE(Xen, XEN_ELFNOTE_PHYS32_ENTRY, .long ram32_start)
.align 4
.long name_end - name_start # namesz
.long desc_end - desc_start # descsz
.long XEN_ELFNOTE_PHYS32_ENTRY # type
name_start:
.asciz "Xen"
name_end:
.align 4
desc_start:
.long ram32_start
desc_end:
.align 4
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ mod virtio;
#[cfg(all(not(test), feature = "rom"))]
global_asm!(include_str!("asm/rom.s"));
#[cfg(not(test))]
global_asm!(include_str!("asm/notes.s"));
#[cfg(not(test))]
global_asm!(include_str!("asm/ram32.s"));
#[cfg(not(test))]
global_asm!(include_str!("asm/ram64.s"));
Expand Down

0 comments on commit d305424

Please sign in to comment.