From 709eea3f4eb8003e914854bf7ced79ad7b24973c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Thu, 2 Dec 2021 23:25:52 +0100 Subject: [PATCH] BootInfo: Add tls_align --- src/arch/aarch64/kernel/bootinfo.rs | 3 +++ src/arch/aarch64/kernel/mod.rs | 4 ++++ src/arch/x86_64/kernel/mod.rs | 6 ++++++ src/environment.rs | 8 ++++---- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/arch/aarch64/kernel/bootinfo.rs b/src/arch/aarch64/kernel/bootinfo.rs index a9639959ea..fad82d53b1 100644 --- a/src/arch/aarch64/kernel/bootinfo.rs +++ b/src/arch/aarch64/kernel/bootinfo.rs @@ -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 { @@ -58,6 +59,7 @@ impl BootInfo { hcip: [255, 255, 255, 255], hcgateway: [255, 255, 255, 255], hcmask: [255, 255, 255, 0], + tls_align: 0, } } } @@ -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!( diff --git a/src/arch/aarch64/kernel/mod.rs b/src/arch/aarch64/kernel/mod.rs index 7dca808894..2053336270 100644 --- a/src/arch/aarch64/kernel/mod.rs +++ b/src/arch/aarch64/kernel/mod.rs @@ -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 } diff --git a/src/arch/x86_64/kernel/mod.rs b/src/arch/x86_64/kernel/mod.rs index 6d4280c9df..cc57b123b6 100644 --- a/src/arch/x86_64/kernel/mod.rs +++ b/src/arch/x86_64/kernel/mod.rs @@ -76,6 +76,7 @@ pub struct BootInfo { hcip: [u8; 4], hcgateway: [u8; 4], hcmask: [u8; 4], + tls_align: u64, } impl BootInfo { @@ -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 { @@ -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)) } } diff --git a/src/environment.rs b/src/environment.rs index 5e38828abe..9a09ba5a4a 100644 --- a/src/environment.rs +++ b/src/environment.rs @@ -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;