Skip to content

Commit 654fb22

Browse files
committed
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 c106bdb commit 654fb22

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

layout.ld

+1-1
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

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
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
# Indicate (via serial) that we are in long/64-bit mode
711
movw $0x3f8, %dx
@@ -11,5 +15,6 @@ ram64_start:
1115
# Setup the stack (at the end of our RAM region)
1216
movq $ram_max, %rsp
1317

18+
# PVH start_info is in %rdi, the first paramter of the System V ABI.
1419
# BootParams are in %rsi, the second paramter of the System V ABI.
1520
jmp rust64_start

src/main.rs

+5-1
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)