diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2023-05-15 23:49:11 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-15 23:49:11 +0000 |
| commit | b0541c01bed231e0e6355db83c87e3ec2b196e70 (patch) | |
| tree | c3d4803c043d56077735db61476edc833c4e6e96 | |
| parent | 34a0c2172b8cdc93daa46ebf186599941baa056e (diff) | |
| parent | 56c3a949af87a6179eee655c19c89144604d17a2 (diff) | |
Merge #1460
1460: rp/multicore: ensure stack is 8-byte aligned. r=Dirbaio a=Dirbaio
bors r+
Co-authored-by: Dario Nieuwenhuis <[email protected]>
| -rw-r--r-- | embassy-rp/src/multicore.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/embassy-rp/src/multicore.rs b/embassy-rp/src/multicore.rs index 9a445c26e..bbc775105 100644 --- a/embassy-rp/src/multicore.rs +++ b/embassy-rp/src/multicore.rs | |||
| @@ -153,7 +153,12 @@ where | |||
| 153 | psm.frce_off().modify(|w| w.set_proc1(false)); | 153 | psm.frce_off().modify(|w| w.set_proc1(false)); |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | let mem = unsafe { core::slice::from_raw_parts_mut(stack.mem.as_mut_ptr() as *mut usize, stack.mem.len() / 4) }; | 156 | // The ARM AAPCS ABI requires 8-byte stack alignment. |
| 157 | // #[align] on `struct Stack` ensures the bottom is aligned, but the top could still be | ||
| 158 | // unaligned if the user chooses a stack size that's not multiple of 8. | ||
| 159 | // So, we round down to the next multiple of 8. | ||
| 160 | let stack_words = stack.mem.len() / 8 * 2; | ||
| 161 | let mem = unsafe { core::slice::from_raw_parts_mut(stack.mem.as_mut_ptr() as *mut usize, stack_words) }; | ||
| 157 | 162 | ||
| 158 | // Set up the stack | 163 | // Set up the stack |
| 159 | let mut stack_ptr = unsafe { mem.as_mut_ptr().add(mem.len()) }; | 164 | let mut stack_ptr = unsafe { mem.as_mut_ptr().add(mem.len()) }; |
