Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b970f7d

Browse filesBrowse files
committed
kernel image fields
1 parent c5e5ed2 commit b970f7d
Copy full SHA for b970f7d

File tree

Expand file treeCollapse file tree

3 files changed

+23
-3
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+23
-3
lines changed

‎api/src/info.rs

Copy file name to clipboardExpand all lines: api/src/info.rs
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ pub struct BootInfo {
5656
pub ramdisk_addr: Optional<u64>,
5757
/// Ramdisk image size, set to 0 if addr is None
5858
pub ramdisk_len: u64,
59+
/// Kernel image address
60+
pub kernel_addr: u64,
61+
/// Kernel image size
62+
pub kernel_len: u64,
63+
/// Kernel image relocation address
64+
pub kernel_image_offset: u64,
5965

6066
#[doc(hidden)]
6167
pub _test_sentinel: u64,
@@ -76,6 +82,9 @@ impl BootInfo {
7682
tls_template: Optional::None,
7783
ramdisk_addr: Optional::None,
7884
ramdisk_len: 0,
85+
kernel_addr: 0,
86+
kernel_len: 0,
87+
kernel_image_offset: 0,
7988
_test_sentinel: 0,
8089
}
8190
}

‎common/src/lib.rs

Copy file name to clipboardExpand all lines: common/src/lib.rs
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ where
198198
let kernel_slice_start = kernel.start_address as u64;
199199
let kernel_slice_len = u64::try_from(kernel.len).unwrap();
200200

201-
let (entry_point, tls_template) = load_kernel::load_kernel(
201+
let (kernel_image_offset, entry_point, tls_template) = load_kernel::load_kernel(
202202
kernel,
203203
kernel_page_table,
204204
frame_allocator,
@@ -402,6 +402,8 @@ where
402402

403403
kernel_slice_start,
404404
kernel_slice_len,
405+
kernel_image_offset: kernel_image_offset.as_u64(),
406+
405407
ramdisk_slice_start,
406408
ramdisk_slice_len,
407409
}
@@ -429,6 +431,8 @@ pub struct Mappings {
429431
pub kernel_slice_start: u64,
430432
/// Size of the kernel slice allocation in memory.
431433
pub kernel_slice_len: u64,
434+
/// Start address of the kernel image relocated in memory.
435+
pub kernel_image_offset: u64,
432436
pub ramdisk_slice_start: Option<VirtAddr>,
433437
pub ramdisk_slice_len: u64,
434438
}
@@ -543,6 +547,9 @@ where
543547
.map(|addr| addr.as_u64())
544548
.into();
545549
info.ramdisk_len = mappings.ramdisk_slice_len;
550+
info.kernel_addr = mappings.kernel_slice_start as _;
551+
info.kernel_len = mappings.kernel_slice_len as _;
552+
info.kernel_image_offset = mappings.kernel_image_offset;
546553
info._test_sentinel = boot_config._test_sentinel;
547554
info
548555
});

‎common/src/load_kernel.rs

Copy file name to clipboardExpand all lines: common/src/load_kernel.rs
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,11 +721,15 @@ pub fn load_kernel(
721721
page_table: &mut (impl MapperAllSizes + Translate),
722722
frame_allocator: &mut impl FrameAllocator<Size4KiB>,
723723
used_entries: &mut UsedLevel4Entries,
724-
) -> Result<(VirtAddr, Option<TlsTemplate>), &'static str> {
724+
) -> Result<(VirtAddr, VirtAddr, Option<TlsTemplate>), &'static str> {
725725
let mut loader = Loader::new(kernel, page_table, frame_allocator, used_entries)?;
726726
let tls_template = loader.load_segments()?;
727727

728-
Ok((loader.entry_point(), tls_template))
728+
Ok((
729+
VirtAddr::new(loader.inner.virtual_address_offset.virtual_address_offset() as u64),
730+
loader.entry_point(),
731+
tls_template,
732+
))
729733
}
730734

731735
/// A helper type used to offset virtual addresses for position independent

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.