Skip to content

Commit

Permalink
BootInfo: Add tls_align
Browse files Browse the repository at this point in the history
  • Loading branch information
mkroening committed Dec 2, 2021
1 parent 4edf87d commit 709eea3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/arch/aarch64/kernel/bootinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct BootInfo {
pub hcip: [u8; 4],
pub hcgateway: [u8; 4],
pub hcmask: [u8; 4],
pub tls_align: u64,
}

impl BootInfo {
Expand Down Expand Up @@ -58,6 +59,7 @@ impl BootInfo {
hcip: [255, 255, 255, 255],
hcgateway: [255, 255, 255, 255],
hcmask: [255, 255, 255, 0],
tls_align: 0,
}
}
}
Expand All @@ -71,6 +73,7 @@ impl fmt::Debug for BootInfo {
writeln!(f, "tls_start {:#x}", self.tls_start)?;
writeln!(f, "tls_filesz {:#x}", self.tls_filesz)?;
writeln!(f, "tls_memsz {:#x}", self.tls_memsz)?;
writeln!(f, "tls_align {:#x}", self.tls_align)?;
writeln!(f, "image_size {:#x}", self.image_size)?;
writeln!(f, "current_stack_address {:#x}", self.current_stack_address)?;
writeln!(
Expand Down
4 changes: 4 additions & 0 deletions src/arch/aarch64/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ pub fn get_tls_memsz() -> usize {
0
}

pub fn get_tls_align() -> usize {
0
}

/// Whether HermitCore is running under the "uhyve" hypervisor.
pub fn is_uhyve() -> bool {
unsafe { core::ptr::read_volatile(&BOOT_INFO.uhyve) != 0 }
Expand Down
6 changes: 6 additions & 0 deletions src/arch/x86_64/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub struct BootInfo {
hcip: [u8; 4],
hcgateway: [u8; 4],
hcmask: [u8; 4],
tls_align: u64,
}

impl BootInfo {
Expand Down Expand Up @@ -106,6 +107,7 @@ impl BootInfo {
hcip: [0; 4],
hcgateway: [0; 4],
hcmask: [0; 4],
tls_align: 0,
};

pub const fn current_stack_address_offset() -> isize {
Expand Down Expand Up @@ -239,6 +241,10 @@ pub fn get_tls_memsz() -> usize {
unsafe { core::ptr::read_volatile(&(*BOOT_INFO).tls_memsz) as usize }
}

pub fn get_tls_align() -> usize {
unsafe { core::ptr::read_volatile(&(*BOOT_INFO).tls_align) as usize }
}

pub fn get_mbinfo() -> VirtAddr {
unsafe { VirtAddr(core::ptr::read_volatile(&(*BOOT_INFO).mb_info)) }
}
Expand Down
8 changes: 4 additions & 4 deletions src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

#[cfg(target_arch = "x86_64")]
pub use crate::arch::x86_64::kernel::{
get_base_address, get_cmdline, get_cmdsize, get_image_size, get_tls_filesz, get_tls_memsz,
get_tls_start, is_single_kernel, is_uhyve,
get_base_address, get_cmdline, get_cmdsize, get_image_size, get_tls_align, get_tls_filesz,
get_tls_memsz, get_tls_start, is_single_kernel, is_uhyve,
};

#[cfg(target_arch = "aarch64")]
pub use crate::arch::aarch64::kernel::{
get_base_address, get_cmdline, get_cmdsize, get_image_size, get_tls_filesz, get_tls_memsz,
get_tls_start, is_single_kernel, is_uhyve,
get_base_address, get_cmdline, get_cmdsize, get_image_size, get_tls_align, get_tls_filesz,
get_tls_memsz, get_tls_start, is_single_kernel, is_uhyve,
};

use crate::util;
Expand Down

0 comments on commit 709eea3

Please sign in to comment.