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 30, 2020
1 parent 3c72242 commit bea1bd3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion layout.ld
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ENTRY(linux64_start)
PHDRS
{
ram PT_LOAD FILEHDR PHDRS ;
note PT_NOTE ;
}

/* Loaders like to put stuff in low memory (< 1M), so we don't use it. */
Expand All @@ -13,9 +14,10 @@ stack_size = 64K;

SECTIONS
{
/* Mapping the program headers into RAM makes the file smaller. */
/* Mapping the program headers and note into RAM makes the file smaller. */
. = ram_min;
. += SIZEOF_HEADERS;
.note : { *(.note) } :note :ram

/* These sections are mapped into RAM from the file. Omitting :ram from
later sections avoids emitting empty sections in the final binary. */
Expand Down
1 change: 1 addition & 0 deletions src/asm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
global_asm!(include_str!("note.s"));
global_asm!(include_str!("ram32.s"));
global_asm!(include_str!("ram64.s"));
global_asm!(include_str!("gdt64.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 ram32_start
desc_end:
.align 4

0 comments on commit bea1bd3

Please sign in to comment.