Skip to content

Commit

Permalink
pvh: Add ELF Note definitions
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
aljimenezb committed Mar 6, 2020
1 parent 0c754f3 commit 60fedeb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/loader/elf.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright © 2020, Oracle and/or its affiliates.
//
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Portions Copyright 2017 The Chromium OS Authors. All rights reserved.
Expand All @@ -22,6 +24,16 @@ pub const ELFMAG0: ::std::os::raw::c_uint = 127;
pub const ELFDATA2LSB: ::std::os::raw::c_uint = 1;
pub const PT_LOAD: ::std::os::raw::c_uint = 1;

// ELF Note p_type used to parse PVH entry point address
pub const PT_NOTE: ::std::os::raw::c_uint = 4;

// 32bit entry point into the kernel. When requested to boot the
// guest kernel using the PVH boot protocol, use this entry point
// to start the guest in 32-bit protected mode with paging disabled.
//
// [ Corresponding definition in Linux kernel: include/xen/interface/elfnote.h ]
pub const XEN_ELFNOTE_PHYS32_ENTRY: u32 = 18;

pub const ELFMAG1: u8 = b'E';
pub const ELFMAG2: u8 = b'L';
pub const ELFMAG3: u8 = b'F';
Expand Down Expand Up @@ -86,6 +98,16 @@ impl Clone for elf64_phdr {
}
pub type Elf64_Phdr = elf64_phdr;

#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct elf64_nhdr {
pub n_namesz: Elf64_Word, // Name size
pub n_descsz: Elf64_Word, // Content size
pub n_type: Elf64_Word, // Content type
}

pub type Elf64_Nhdr = elf64_nhdr;

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit 60fedeb

Please sign in to comment.