Skip to content

Commit 82fcaeb

Browse files
committed
pvh: Do not attempt PVH boot if kernel_offset is requested
In x86, the kernel_offset parameter is used to request that the kernel is loaded in guest memory at a fixed offset from the default load address encoded in the phdr.p_paddr field of the Elf header. Do not attempt to look for a PVH entry point if a load offset has been requested using kernel_offset, since PVH expects the kernel to be loaded at the default load address. Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
1 parent 3ca3b65 commit 82fcaeb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/loader/x86_64/elf/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ impl Elf {
130130
impl KernelLoader for Elf {
131131
/// Loads a kernel from a vmlinux elf image into guest memory.
132132
///
133-
/// The kernel is loaded into guest memory at offset `phdr.p_paddr` specified by the elf image.
133+
/// By default, the kernel is loaded into guest memory at offset `phdr.p_paddr` specified by the elf image.
134+
/// When used, `kernel_offset` specifies a fixed offset from `phdr.p_paddr` at which to load the kernel.
134135
///
135136
/// # Arguments
136137
///
@@ -212,7 +213,12 @@ impl KernelLoader for Elf {
212213
// Read in each section pointed to by the program headers.
213214
for phdr in phdrs {
214215
if phdr.p_type != elf::PT_LOAD || phdr.p_filesz == 0 {
215-
if phdr.p_type == elf::PT_NOTE {
216+
// The PVH boot protocol currently requires that the kernel is loaded at
217+
// the default kernel load address in guest memory (specified at kernel
218+
// build by the value of CONFIG_PHYSICAL_START). Therefore, only attempt
219+
// to use PVH if an offset from the default load address has not been
220+
// requested using the kernel_offset parameter.
221+
if phdr.p_type == elf::PT_NOTE && kernel_offset.is_none() {
216222
// This segment describes a Note, check if PVH entry point is encoded.
217223
loader_result.pvh_entry_addr = parse_elf_note(&phdr, kernel_image)?;
218224
}

0 commit comments

Comments
 (0)