svn commit: r246318 - head/sys/arm/arm

Andrew Turner andrew at FreeBSD.org
Mon Feb 4 09:48:51 UTC 2013


Author: andrew
Date: Mon Feb  4 09:48:50 2013
New Revision: 246318
URL: http://svnweb.freebsd.org/changeset/base/246318

Log:
  Use the STACKALIGN macro to alight the stack rather than with a magic mask.
  
  Submitted by:	Christoph Mallon <christoph.mallon gmx.de>

Modified:
  head/sys/arm/arm/vm_machdep.c

Modified: head/sys/arm/arm/vm_machdep.c
==============================================================================
--- head/sys/arm/arm/vm_machdep.c	Mon Feb  4 09:42:12 2013	(r246317)
+++ head/sys/arm/arm/vm_machdep.c	Mon Feb  4 09:48:50 2013	(r246318)
@@ -362,8 +362,8 @@ cpu_set_upcall_kse(struct thread *td, vo
 {
 	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);


More information about the svn-src-head mailing list