Skip to content
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

fix(x86_64): explicitly decrease alignment of i128 to 8 #31

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hermit-entry"
version = "0.9.9"
version = "0.9.10"
authors = ["Martin Kröning <mkroening@posteo.net>"]
edition = "2021"
description = "Hermit's loading and entry API."
Expand Down
5 changes: 4 additions & 1 deletion src/boot_info/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ impl From<RawPlatformInfo> for PlatformInfo {
has_pci,
num_cpus,
cpu_freq,
boot_time: OffsetDateTime::from_unix_timestamp_nanos(boot_time).unwrap(),
boot_time: OffsetDateTime::from_unix_timestamp_nanos(i128::from_ne_bytes(
boot_time.0,
))
.unwrap(),
},
RawPlatformInfo::LinuxBootParams {
command_line_data,
Expand Down
2 changes: 1 addition & 1 deletion src/boot_info/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl From<PlatformInfo> for RawPlatformInfo {
has_pci,
num_cpus,
cpu_freq,
boot_time: boot_time.unix_timestamp_nanos(),
boot_time: boot_time.unix_timestamp_nanos().to_ne_bytes().into(),
},
PlatformInfo::LinuxBootParams {
command_line,
Expand Down
13 changes: 12 additions & 1 deletion src/boot_info/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@ struct RawLoadInfo {
tls_info: TlsInfo,
}

#[derive(Clone, Copy, Debug)]
#[cfg_attr(target_arch = "x86_64", repr(C, align(8)))]
#[cfg_attr(not(target_arch = "x86_64"), repr(transparent))]
struct Align8<T>(pub T);

impl<T> From<T> for Align8<T> {
fn from(value: T) -> Self {
Self(value)
}
}

#[cfg_attr(not(all(feature = "loader", feature = "kernel")), allow(dead_code))]
#[derive(Clone, Copy, Debug)]
#[repr(C)]
Expand All @@ -174,7 +185,7 @@ enum RawPlatformInfo {
has_pci: bool,
num_cpus: NonZeroU64,
cpu_freq: Option<NonZeroU32>,
boot_time: i128,
boot_time: Align8<[u8; 16]>,
},
LinuxBootParams {
command_line_data: *const u8,
Expand Down