Skip to content

Commit c48601d

Browse files
josephlrrbradford
authored andcommitted
pvh: Add code to read PVH Boot Protocol stucts
Note that this also requires zeroing out %rdi in the Linux Boot Protocol path, so that the rdi parameter will have a valid repr. Signed-off-by: Joe Richey <[email protected]>
1 parent bbc32dd commit c48601d

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

layout.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ENTRY(ram64_start)
1+
ENTRY(linux64_start)
22

33
PHDRS
44
{

src/asm/ram64.s

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
.section .text, "ax"
2-
.global ram64_start
2+
.global linux64_start
33
.code64
44

5+
linux64_start:
6+
# Zero out %rdi, its value is unspecificed in the Linux Boot Protocol.
7+
xorq %rdi, %rdi
8+
59
ram64_start:
610
# Setup the stack (at the end of our RAM region)
711
movq $ram_max, %rsp
812

13+
# PVH start_info is in %rdi, the first paramter of the System V ABI.
914
# BootParams are in %rsi, the second paramter of the System V ABI.
1015
jmp rust64_start

src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ fn boot_from_device(device: &mut block::VirtioBlockDevice, info: &dyn boot::Info
140140
}
141141

142142
#[no_mangle]
143-
pub extern "C" fn rust64_start(_rdi: *const (), rsi: Option<&boot::Params>) -> ! {
143+
pub extern "C" fn rust64_start(rdi: Option<&pvh::StartInfo>, rsi: Option<&boot::Params>) -> ! {
144+
if let Some(start_info) = rdi {
145+
log!("\nBooting via PVH Boot Protocol");
146+
run(start_info)
147+
}
144148
if let Some(boot_params) = rsi {
145149
log!("\nBooting via Linux Boot Protocol");
146150
run(boot_params)

0 commit comments

Comments
 (0)