# HG changeset patch # User mdoerr # Date 1474961190 -7200 # Node ID ad7de42d606ba94664f60bff150d02e4e4c48a2f # Parent 310c8762869668d30623731301c7322d12067cf7 8166689: PPC64: Race condition between stack bang and non-entrant patching Reviewed-by: goetz diff -r 310c87628696 -r ad7de42d606b hotspot/src/cpu/ppc/vm/c1_MacroAssembler_ppc.cpp --- a/hotspot/src/cpu/ppc/vm/c1_MacroAssembler_ppc.cpp Mon Sep 26 14:21:21 2016 -0400 +++ b/hotspot/src/cpu/ppc/vm/c1_MacroAssembler_ppc.cpp Tue Sep 27 09:26:30 2016 +0200 @@ -64,17 +64,16 @@ void C1_MacroAssembler::build_frame(int frame_size_in_bytes, int bang_size_in_bytes) { + // Avoid stack bang as first instruction. It may get overwritten by patch_verified_entry. + const Register return_pc = R20; + mflr(return_pc); + + // Make sure there is enough stack space for this method's activation. assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect"); - // Make sure there is enough stack space for this method's activation. generate_stack_overflow_check(bang_size_in_bytes); - // Create the frame. - const Register return_pc = R0; - - mflr(return_pc); - // Get callers sp. - std(return_pc, _abi(lr), R1_SP); // SP->lr = return_pc - push_frame(frame_size_in_bytes, R0); // SP -= frame_size_in_bytes + std(return_pc, _abi(lr), R1_SP); // SP->lr = return_pc + push_frame(frame_size_in_bytes, R0); // SP -= frame_size_in_bytes } diff -r 310c87628696 -r ad7de42d606b hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp --- a/hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp Mon Sep 26 14:21:21 2016 -0400 +++ b/hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp Tue Sep 27 09:26:30 2016 +0200 @@ -2550,7 +2550,7 @@ __ lbzx(R17_tos, Rclass_or_obj, Roffset); __ extsb(R17_tos, R17_tos); __ push(ztos); - if (!is_static) { + if (!is_static && rc == may_rewrite) { // use btos rewriting, no truncating to t/f bit is needed for getfield. patch_bytecode(Bytecodes::_fast_bgetfield, Rbc, Rscratch); } @@ -2874,7 +2874,9 @@ if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1. __ andi(R17_tos, R17_tos, 0x1); __ stbx(R17_tos, Rclass_or_obj, Roffset); - if (!is_static) { patch_bytecode(Bytecodes::_fast_zputfield, Rbc, Rscratch, true, byte_no); } + if (!is_static && rc == may_rewrite) { + patch_bytecode(Bytecodes::_fast_zputfield, Rbc, Rscratch, true, byte_no); + } if (!support_IRIW_for_not_multiple_copy_atomic_cpu) { __ beq(CR_is_vol, Lvolatile); // Volatile? }