From 3da6055c2c175fe1a290484838d43ab5804536ae Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 4 Feb 2013 09:48:50 +0000 Subject: [PATCH] Use the STACKALIGN macro to alight the stack rather than with a magic mask. Submitted by: Christoph Mallon --- sys/arm/arm/vm_machdep.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sys/arm/arm/vm_machdep.c b/sys/arm/arm/vm_machdep.c index 22a209b4faad..9326546374c2 100644 --- a/sys/arm/arm/vm_machdep.c +++ b/sys/arm/arm/vm_machdep.c @@ -362,8 +362,8 @@ cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg, { struct trapframe *tf = td->td_frame; - tf->tf_usr_sp = ((int)stack->ss_sp + stack->ss_size - - sizeof(struct trapframe)) & ~7; + tf->tf_usr_sp = STACKALIGN((int)stack->ss_sp + stack->ss_size + - sizeof(struct trapframe)); tf->tf_pc = (int)entry; tf->tf_r0 = (int)arg; tf->tf_spsr = PSR_USR32_MODE; @@ -396,14 +396,13 @@ cpu_thread_alloc(struct thread *td) { td->td_pcb = (struct pcb *)(td->td_kstack + td->td_kstack_pages * PAGE_SIZE) - 1; - td->td_frame = (struct trapframe *) - ((u_int)td->td_kstack + USPACE_SVC_STACK_TOP - sizeof(struct pcb)) - 1; /* * Ensure td_frame is aligned to an 8 byte boundary as it will be * placed into the stack pointer which must be 8 byte aligned in * the ARM EABI. */ - td->td_frame = (struct trapframe *)((u_int)td->td_frame & ~7); + td->td_frame = (struct trapframe *)STACKALIGN((u_int)td->td_kstack + + USPACE_SVC_STACK_TOP - sizeof(struct pcb) - 1); #ifdef __XSCALE__ #ifndef CPU_XSCALE_CORE3 pmap_use_minicache(td->td_kstack, td->td_kstack_pages * PAGE_SIZE);