From 55f3e4afdb5c8816b46c2f0dbae51b5ef70ef77a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 20 Nov 2024 14:39:04 +0100 Subject: [PATCH] fix(x86_64): use unaligned write for TLS pointer TLS alignment may be 4 and require an unaligned write. This was found with hermit-c and cargo-careful. --- src/arch/x86_64/kernel/scheduler.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arch/x86_64/kernel/scheduler.rs b/src/arch/x86_64/kernel/scheduler.rs index 1de51e63f7..e3ff66d31a 100644 --- a/src/arch/x86_64/kernel/scheduler.rs +++ b/src/arch/x86_64/kernel/scheduler.rs @@ -293,7 +293,7 @@ impl TaskTLS { // thread_ptr = block_ptr + tls_offset let thread_ptr = block[tls_offset..].as_mut_ptr().cast::<()>(); unsafe { - thread_ptr.cast::<*mut ()>().write(thread_ptr); + thread_ptr.cast::<*mut ()>().write_unaligned(thread_ptr); } let this = Self {