Browse Source

clone: align the given stack pointer on or1k and riscv

This was an oversight specific to these archs; others have always
aligned the new stack pointer correctly.
Alex Rønne Petersen 3 months ago
parent
commit
5e03c03fcd
3 changed files with 4 additions and 0 deletions
  1. 2 0
      src/thread/or1k/clone.s
  2. 1 0
      src/thread/riscv32/clone.s
  3. 1 0
      src/thread/riscv64/clone.s

+ 2 - 0
src/thread/or1k/clone.s

@@ -6,6 +6,8 @@
 .hidden __clone
 .type   __clone,@function
 __clone:
+	l.xori	r11, r0, -4
+	l.and	r4, r4, r11
 	l.addi	r4, r4, -8
 	l.sw	0(r4), r3
 	l.sw	4(r4), r6

+ 1 - 0
src/thread/riscv32/clone.s

@@ -8,6 +8,7 @@
 .type  __clone, %function
 __clone:
 	# Save func and arg to stack
+	andi a1, a1, -16
 	addi a1, a1, -16
 	sw a0, 0(a1)
 	sw a3, 4(a1)

+ 1 - 0
src/thread/riscv64/clone.s

@@ -8,6 +8,7 @@
 .type  __clone, %function
 __clone:
 	# Save func and arg to stack
+	andi a1, a1, -16
 	addi a1, a1, -16
 	sd a0, 0(a1)
 	sd a3, 8(a1)