Skip to content

Commit 60fedeb

Browse files
committed
pvh: Add ELF Note definitions
Define ELF Note header structure and constants necessary for parsing the PVH entry point address encoded in the kernel ELF header. Signed-off-by: Alejandro Jimenez <[email protected]>
1 parent 0c754f3 commit 60fedeb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/loader/elf.rs

+22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright © 2020, Oracle and/or its affiliates.
2+
//
13
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
24
//
35
// Portions Copyright 2017 The Chromium OS Authors. All rights reserved.
@@ -22,6 +24,16 @@ pub const ELFMAG0: ::std::os::raw::c_uint = 127;
2224
pub const ELFDATA2LSB: ::std::os::raw::c_uint = 1;
2325
pub const PT_LOAD: ::std::os::raw::c_uint = 1;
2426

27+
// ELF Note p_type used to parse PVH entry point address
28+
pub const PT_NOTE: ::std::os::raw::c_uint = 4;
29+
30+
// 32bit entry point into the kernel. When requested to boot the
31+
// guest kernel using the PVH boot protocol, use this entry point
32+
// to start the guest in 32-bit protected mode with paging disabled.
33+
//
34+
// [ Corresponding definition in Linux kernel: include/xen/interface/elfnote.h ]
35+
pub const XEN_ELFNOTE_PHYS32_ENTRY: u32 = 18;
36+
2537
pub const ELFMAG1: u8 = b'E';
2638
pub const ELFMAG2: u8 = b'L';
2739
pub const ELFMAG3: u8 = b'F';
@@ -86,6 +98,16 @@ impl Clone for elf64_phdr {
8698
}
8799
pub type Elf64_Phdr = elf64_phdr;
88100

101+
#[repr(C)]
102+
#[derive(Debug, Default, Copy, Clone)]
103+
pub struct elf64_nhdr {
104+
pub n_namesz: Elf64_Word, // Name size
105+
pub n_descsz: Elf64_Word, // Content size
106+
pub n_type: Elf64_Word, // Content type
107+
}
108+
109+
pub type Elf64_Nhdr = elf64_nhdr;
110+
89111
#[cfg(test)]
90112
mod tests {
91113
use super::*;

0 commit comments

Comments
 (0)