diff options
author | Pekka Enberg <penberg@kernel.org> | 2012-02-15 16:36:53 +0200 |
---|---|---|
committer | Pekka Enberg <penberg@kernel.org> | 2012-02-15 16:36:53 +0200 |
commit | d4e6ba67e7662987d6aaace3d052edff01ed9294 (patch) | |
tree | 559b47d773fe7bc47e90948b4cbeace1563123f3 | |
parent | 817ddf7020c22aa2646f8993ea40151b58c8df1b (diff) | |
download | jato-d4e6ba67e7662987d6aaace3d052edff01ed9294.tar.gz |
x86-64: Fix stack pointer alignment with -Xdebug:stack
Running EntryTest on x86-64 with -Xdebug:stack crashes as follows:
./jato -Xdebug:stack -cp test/functional -bootclasspath test/functional:`./tools/classpath-config`/share/classpath/glibj.zip -Djava.library.path=`./tools/classpath-config`/lib/classpath/ -Xnosystemclassloader jvm/EntryTest
[main] SIGSEGV at RIP 3de6406973 while accessing memory address 00000000.
[main] Registers:
[main] rsp: 00007fff9282db78
[main] rax: 0000000000000000 rbx: 0000000001be3090 rcx: 0000000000000020
[main] rdx: 000000000000016c rsi: 000000000000005b rdi: 0000000001be3090
[main] rbp: 00007fff9282dce8 r8: 000000000000000a r9: 0000000070000021
[main] r10: 000000006ffffdff r11: 0000000000000246 r12: 00007fff9282dda0
[main] r13: 000000006ffffeff r14: 00007fff9282dae0 r15: 00007fff9282da80
[main] Stack:
[main] 000000000000002d 0000003de6847ffe 0000000000000001 0000000000000014
[main] 00007fff9282dbf8 000000000000002a 0000003de687447e 00007fff9282e200
[main] 00007f6a4844a000 00007f6a4844ad00 00007f6a48449c58 00007fff9282db78
[main] Code: 83 a8 02 00 00 0f 85 7b 05 00 00 48 89 df e8 55 3f 00 00 f6 45 10 08 0f 84 cb 00 00 00 f6 83 d4 03 00 00 20 48 8b 05 ed 8f 21 00 <66> 0f 6f 85 40 ff ff ff 48 0f 45 c3 48 83 3d 51 82 21 00 00 48
[main] Native and Java stack trace:
[main] [<3de6406973>] native : signal_bh_trampoline+3de5fc030f (arch/x86/signal-bh.S:124)
[main] [<3de6407e76>] native : signal_bh_trampoline+3de5fc1812 (arch/x86/signal-bh.S:124)
Aborted
The problem is that when we push a 8 byte canary on the stack, the stack
pointer is no longer aligned to 16 bytes which is required for some SSE
operations on 64-bit.
This patch fixes the issue.
Signed-off-by: Pekka Enberg <penberg@kernel.org>
-rw-r--r-- | arch/x86/emit_64.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/x86/emit_64.c b/arch/x86/emit_64.c index 8ffbc21f..6ad37047 100644 --- a/arch/x86/emit_64.c +++ b/arch/x86/emit_64.c @@ -1219,6 +1219,8 @@ void emit_prolog(struct buffer *buf, struct stack_frame *frame, if (opt_debug_stack) { __emit_mov_imm_reg(buf, STACK_FRAME_REDZONE_END, MACH_REG_RAX); __emit_push_reg(buf, MACH_REG_RAX); + /* Keep stack pointer aligned to 16 bytes */ + __emit64_sub_imm_reg(buf, X86_STACK_ALIGN - sizeof(unsigned long), MACH_REG_RSP); } } @@ -1243,6 +1245,8 @@ static void do_stack_redzone_check(unsigned long magic) static void emit_stack_redzone_check(struct buffer *buf) { + __emit_add_imm_reg(buf, X86_STACK_ALIGN - sizeof(unsigned long), MACH_REG_RSP); + /* Pass the magic value to do_stack_redzone_check(). */ __emit_pop_reg(buf, MACH_REG_RDI); |