diff --git a/api/src/info.rs b/api/src/info.rs index 23646499..965fcf40 100644 --- a/api/src/info.rs +++ b/api/src/info.rs @@ -56,11 +56,11 @@ pub struct BootInfo { pub ramdisk_addr: Optional, /// Ramdisk image size, set to 0 if addr is None pub ramdisk_len: u64, - /// Kernel image address + /// Physical address of the kernel ELF in memory. pub kernel_addr: u64, - /// Kernel image size + /// Size of the kernel ELF in memory. pub kernel_len: u64, - /// Kernel image relocation address + /// Virtual address of the loaded kernel image. pub kernel_image_offset: u64, #[doc(hidden)] diff --git a/common/src/legacy_memory_region.rs b/common/src/legacy_memory_region.rs index bf804e9c..6f4b1741 100644 --- a/common/src/legacy_memory_region.rs +++ b/common/src/legacy_memory_region.rs @@ -110,10 +110,11 @@ where pub fn construct_memory_map( self, regions: &mut [MaybeUninit], - kernel_slice_start: u64, + kernel_slice_start: PhysAddr, kernel_slice_len: u64, ) -> &mut [MemoryRegion] { let mut next_index = 0; + let kernel_slice_start = kernel_slice_start.as_u64(); for descriptor in self.original { let mut start = descriptor.start(); diff --git a/common/src/lib.rs b/common/src/lib.rs index 65a06b82..3c407644 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -195,7 +195,7 @@ where enable_write_protect_bit(); let config = kernel.config; - let kernel_slice_start = kernel.start_address as u64; + let kernel_slice_start = PhysAddr::new(kernel.start_address as _); let kernel_slice_len = u64::try_from(kernel.len).unwrap(); let (kernel_image_offset, entry_point, tls_template) = load_kernel::load_kernel( @@ -402,7 +402,7 @@ where kernel_slice_start, kernel_slice_len, - kernel_image_offset: kernel_image_offset.as_u64(), + kernel_image_offset, ramdisk_slice_start, ramdisk_slice_len, @@ -428,11 +428,11 @@ pub struct Mappings { pub tls_template: Option, /// Start address of the kernel slice allocation in memory. - pub kernel_slice_start: u64, + pub kernel_slice_start: PhysAddr, /// Size of the kernel slice allocation in memory. pub kernel_slice_len: u64, - /// Start address of the kernel image relocated in memory. - pub kernel_image_offset: u64, + /// Relocation offset of the kernel image in virtual memory. + pub kernel_image_offset: VirtAddr, pub ramdisk_slice_start: Option, pub ramdisk_slice_len: u64, } @@ -547,9 +547,9 @@ where .map(|addr| addr.as_u64()) .into(); info.ramdisk_len = mappings.ramdisk_slice_len; - info.kernel_addr = mappings.kernel_slice_start as _; + info.kernel_addr = mappings.kernel_slice_start.as_u64(); info.kernel_len = mappings.kernel_slice_len as _; - info.kernel_image_offset = mappings.kernel_image_offset; + info.kernel_image_offset = mappings.kernel_image_offset.as_u64(); info._test_sentinel = boot_config._test_sentinel; info }); diff --git a/src/uefi/pxe.rs b/src/uefi/pxe.rs index 4eac7f8c..25049a28 100644 --- a/src/uefi/pxe.rs +++ b/src/uefi/pxe.rs @@ -1,7 +1,6 @@ use std::path::Path; use anyhow::Context; -use bootloader_boot_config::BootConfig; pub fn create_uefi_tftp_folder( bootloader_path: &Path,