Skip to content

Commit a26f7c9

Browse files
TomGohguoweikang
andauthored
fix(aarch64,uspace): align to 16 bytes (#7)
Signed-off-by: Weikang Guo <guoweikang@kylinos.cn> Co-authored-by: Weikang Guo <guoweikang@kylinos.cn>
1 parent 38f5895 commit a26f7c9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/aarch64/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ impl fmt::Debug for TrapFrame {
2525
}
2626
writeln!(f, " elr: {:#x},", self.elr)?;
2727
writeln!(f, " spsr: {:#x},", self.spsr)?;
28+
writeln!(f, " pad: {:#x},", self.__pad)?;
2829
write!(f, "}}")?;
2930
Ok(())
3031
}

src/aarch64/uspace.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{trap::PageFaultFlags, TrapFrame};
1212
pub use crate::uspace_common::{ExceptionKind, ReturnReason};
1313

1414
/// Context to enter user space.
15-
#[repr(C)]
15+
#[repr(C, align(16))]
1616
#[derive(Debug, Clone, Copy)]
1717
pub struct UserContext {
1818
tf: TrapFrame,
@@ -23,6 +23,7 @@ pub struct UserContext {
2323
}
2424

2525
impl UserContext {
26+
const PAD_MAGIC: u64 = 0x1234_5678_9abc_def0;
2627
/// Creates a new context with the given entry point, user stack pointer,
2728
/// and the argument.
2829
pub fn new(entry: usize, ustack_top: VirtAddr, arg0: usize) -> Self {
@@ -39,7 +40,7 @@ impl UserContext {
3940
+ SPSR_EL1::I::Unmasked
4041
+ SPSR_EL1::F::Masked)
4142
.value,
42-
__pad: 0,
43+
__pad: Self::PAD_MAGIC,
4344
},
4445
sp: ustack_top.as_usize() as _,
4546
tpidr: 0,

0 commit comments

Comments
 (0)