Skip to content

Commit 9a56f4c

Browse files
committed
pvh: Add PVH ELFNOTE
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]>
1 parent 491d208 commit 9a56f4c

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

layout.ld

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ ENTRY(linux64_start)
33
PHDRS
44
{
55
program PT_LOAD FILEHDR PHDRS ;
6+
note PT_NOTE ;
67
}
78

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

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

30+
/* These sections are not mapped into RAM */
31+
.note : { *(.note) } :note
32+
2933
/* Match edk2's GccBase.lds DISCARD section */
3034
/DISCARD/ : {
3135
*(.note.GNU-stack)

src/asm/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
global_asm!(include_str!("note.s"));
12
global_asm!(include_str!("ram32.s"));
23
global_asm!(include_str!("ram64.s"));

src/asm/note.s

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.section .note, "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 pvh_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 pvh32_start
19+
desc_end:
20+
.align 4

0 commit comments

Comments
 (0)