Skip to content

Commit

Permalink
pvh: Add PVH ELFNOTE
Browse files Browse the repository at this point in the history
This adds information to the ELF binary so that a loader will know
where to start the executable. This now allows the firmware to be
booted via the PVH Boot Protocol.

Signed-off-by: Joe Richey <[email protected]>
  • Loading branch information
josephlr committed Mar 29, 2020
1 parent 151b028 commit 7eb58d2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions layout.ld
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ENTRY(linux64_start)
PHDRS
{
program PT_LOAD FILEHDR PHDRS ;
note PT_NOTE ;
}

/* Loaders like to put stuff in low memory (< 1M), so we don't use it. */
Expand All @@ -26,6 +27,9 @@ SECTIONS

ASSERT((. <= ram_max - stack_size), "firmware size too big for RAM region")

/* These sections are not mapped into RAM */
.note : { *(.note) } :note

/* Match edk2's GccBase.lds DISCARD section */
/DISCARD/ : {
*(.note.GNU-stack)
Expand Down
1 change: 1 addition & 0 deletions src/asm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
global_asm!(include_str!("note.s"));
global_asm!(include_str!("ram32.s"));
global_asm!(include_str!("ram64.s"));
20 changes: 20 additions & 0 deletions src/asm/note.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.section .note, "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 pvh_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 pvh32_start
desc_end:
.align 4

0 comments on commit 7eb58d2

Please sign in to comment.