Skip to content

Commit bc80435

Browse files
committed
fix(x86_64): explicitly decrease alignment of i128 to 8
Signed-off-by: Martin Kröning <[email protected]>
1 parent d7a6340 commit bc80435

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/boot_info/kernel.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ impl From<RawPlatformInfo> for PlatformInfo {
6666
has_pci,
6767
num_cpus,
6868
cpu_freq,
69-
boot_time: OffsetDateTime::from_unix_timestamp_nanos(boot_time).unwrap(),
69+
boot_time: OffsetDateTime::from_unix_timestamp_nanos(i128::from_ne_bytes(
70+
boot_time.0,
71+
))
72+
.unwrap(),
7073
},
7174
RawPlatformInfo::LinuxBootParams {
7275
command_line_data,

src/boot_info/loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl From<PlatformInfo> for RawPlatformInfo {
5454
has_pci,
5555
num_cpus,
5656
cpu_freq,
57-
boot_time: boot_time.unix_timestamp_nanos(),
57+
boot_time: boot_time.unix_timestamp_nanos().to_ne_bytes().into(),
5858
},
5959
PlatformInfo::LinuxBootParams {
6060
command_line,

src/boot_info/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,17 @@ struct RawLoadInfo {
158158
tls_info: TlsInfo,
159159
}
160160

161+
#[derive(Clone, Copy, Debug)]
162+
#[cfg_attr(target_arch = "x86_64", repr(C, align(8)))]
163+
#[cfg_attr(not(target_arch = "x86_64"), repr(transparent))]
164+
struct Align8<T>(pub T);
165+
166+
impl<T> From<T> for Align8<T> {
167+
fn from(value: T) -> Self {
168+
Self(value)
169+
}
170+
}
171+
161172
#[cfg_attr(not(all(feature = "loader", feature = "kernel")), allow(dead_code))]
162173
#[derive(Clone, Copy, Debug)]
163174
#[repr(C)]
@@ -174,7 +185,7 @@ enum RawPlatformInfo {
174185
has_pci: bool,
175186
num_cpus: NonZeroU64,
176187
cpu_freq: Option<NonZeroU32>,
177-
boot_time: i128,
188+
boot_time: Align8<[u8; 16]>,
178189
},
179190
LinuxBootParams {
180191
command_line_data: *const u8,

0 commit comments

Comments
 (0)