-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pvh: Support booting via PVH ELFNOTE #26
Commits on Mar 30, 2020
-
paging: Put tables in
static mut
We don't actually need an AtomicRefcell here. It's fine for paging::setup() to run multiple times, it's idempontent and we only do writes. We also place the page tables in #[no_mangle] static mut variables so they can be linked from assembly code. Signed-off-by: Joe Richey <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for afb4d0c - Browse repository at this point
Copy the full SHA afb4d0cView commit details -
mem: Simplify MemoryRegion methods
We really only need from_bytes and as_bytes. There's no need for a generic from_slice method. Signed-off-by: Joe Richey <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 0fb8e30 - Browse repository at this point
Copy the full SHA 0fb8e30View commit details -
errors: Improve error types and implement Debug
As our error types are enums, we can include the "source" error in our later error types. This allows for more information when debugging failures. To this end, we also implement Debug. Signed-off-by: Joe Richey <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for fce1a43 - Browse repository at this point
Copy the full SHA fce1a43View commit details -
common: Move string manipulation functions to common.rs
We can have `ascii_strip` use entirely safe code by `unwrap()`ing the result of `from_utf8` instead of using `from_utf8_unchecked`. We also add a helper function to convert a C-string pointer into a byte slice. Signed-off-by: Joe Richey <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for e40fb02 - Browse repository at this point
Copy the full SHA e40fb02View commit details -
boot: Add structures for Info, E820, and Params
To support multiple boot protocols, we need a common abstraction for the information given in a boot protocol. This is the Info trait. This also requires adding a common E820Entry structure, so we can get the memory map. We also add a boot::Params structure (i.e. the Linux Zeropage) to make reading/writing the structure easier. This will let us avoid needing to hardcode struct offsets. The layout for these structures is taken from the Kernel's arch/x86/include/uapi/asm/bootparam.h Signed-off-by: Joe Richey <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 11a8821 - Browse repository at this point
Copy the full SHA 11a8821View commit details -
fat: Add utility functions for loading data from files
This allows much of the existing code to be simplified, by letting us load the remainer of a file into a specific memory region. This also makes it much easier to write the code to load the Linux Kernel header from the bzimage file. Signed-off-by: Joe Richey <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 0f16ac3 - Browse repository at this point
Copy the full SHA 0f16ac3View commit details -
rust64_start: Read kernel boot params from %rsi
This works because Option<&T> has the same FFI layout as *const T except that a null pointer is None. Signed-off-by: Joe Richey <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for df561f8 - Browse repository at this point
Copy the full SHA df561f8View commit details -
efi: Use Info to setup allocator and EFI tables
This allows efi_exec to work with multiple boot protocols. Signed-off-by: Joe Richey <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for bd2f43b - Browse repository at this point
Copy the full SHA bd2f43bView commit details -
bzimage: Rewrite Linux Kernel Loading code
This allows Linux to be booted with any boot protocol. The old code took in the Zeropage passed in via the Linux Kernel Boot Protocol, modified it, and passed it into the Linux Kernel. This is not the correct way to boot Linux per the documentation: https://www.kernel.org/doc/Documentation/x86/boot.txt This code now correctly: - Uses a brand-new Zeropage inside the `Kernel` struct - Adds in the E820 map and RSDP pointer from the boot::Info - Reads the header from the file and copies it into the Zeropage - Loads the kernel and initrd into avalible memory - Properly manages the command-line at a fixed memory location - Jumps to the appropriate starting address Signed-off-by: Joe Richey <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for b0d9f3e - Browse repository at this point
Copy the full SHA b0d9f3eView commit details -
main: Rewrite boot_from_device
We now pass the boot::Info to `loader::load_default_entry` and `efi::efi_exec`. We also reorganize the code in this function to: - Avoid unnecessary nesting - log errors when they occur The code is now much more readable Signed-off-by: Joe Richey <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for ae9c8a9 - Browse repository at this point
Copy the full SHA ae9c8a9View commit details -
pvh: Add Structures for PVH Boot Protocol
These are simply translated from the C structs in: xen/include/public/arch-x86/hvm/start_info.h Note that unlike the Linux Boot Protocol structures, these structures don't need to be `#[repr(packed)]` as they are garunteed to have the proper alignment. Signed-off-by: Joe Richey <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 2664ab4 - Browse repository at this point
Copy the full SHA 2664ab4View commit details -
asm: Remove Serial debug statements
This approch doesn't scale to our other ASM code and it clutters the output. Signed-off-by: Joe Richey <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 8cbba8c - Browse repository at this point
Copy the full SHA 8cbba8cView commit details -
layout: Cleanup and comment linker script
Signed-off-by: Joe Richey <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 52701c5 - Browse repository at this point
Copy the full SHA 52701c5View commit details -
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]>
Configuration menu - View commit details
-
Copy full SHA for ac0db65 - Browse repository at this point
Copy the full SHA ac0db65View commit details -
pvh: Add code to transition from 32-bit to 64-bit
PVH starts in 32-bit mode, so we have to transition to 64-bit mode before we can start running Rust code. As we have not yet initialized the stack, we can only use registers and static memory. This transition does the following: - Sets up page tables to identity map 2 MiB - Loads page tables into CR3 - Sets CR4.PAE, EFER.LME, and CRO.PG - Sets up a 64-bit GDT - Long Jumps to 64-bit code We put the GDT in the .rodata section, and we put the 32-bit code in its own section. This makes it easier to debug and dissassemble the binary. Signed-off-by: Joe Richey <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 3c72242 - Browse repository at this point
Copy the full SHA 3c72242View commit details -
This adds information to the ELF binary so that a loader will know where to start the executable. This now allows the firmware to be booted via the PVH Boot Protocol. Signed-off-by: Joe Richey <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for bea1bd3 - Browse repository at this point
Copy the full SHA bea1bd3View commit details