Author: Armin Rigo <[email protected]>
Branch: stmgc-c4
Changeset: r67115:9d966eac78e1
Date: 2013-09-27 23:32 +0200
http://bitbucket.org/pypy/pypy/changeset/9d966eac78e1/
Log: Save and restore stm_shadowstack.
diff --git a/rpython/jit/backend/x86/arch.py b/rpython/jit/backend/x86/arch.py
--- a/rpython/jit/backend/x86/arch.py
+++ b/rpython/jit/backend/x86/arch.py
@@ -16,7 +16,7 @@
# +--------------------+ <== aligned to 16 bytes
# | return address |
# +--------------------+
-# | STM resume buf | (4 extra words, only with STM)
+# | STM resume buf | (16 extra bytes, only with STM)
# +--------------------+
# | saved regs |
# +--------------------+
@@ -45,4 +45,4 @@
assert PASS_ON_MY_FRAME >= 12 # asmgcc needs at least JIT_USE_WORDS + 3
-STM_RESUME_BUF = 4
+STM_RESUME_BUF = 16 / WORD
diff --git a/rpython/jit/backend/x86/assembler.py
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -568,12 +568,18 @@
mc.MOV_rr(esp.value, edi.value)
mc.SUB_ri(esp.value, FRAME_FIXED_SIZE * WORD)
#
+ # restore the shadowstack pointer from stm_resume_buffer[1]
+ rst = self._get_stm_tl(gcrootmap.get_root_stack_top_addr())
+ mc.MOV_rs(eax.value, (FRAME_FIXED_SIZE + 1) * WORD)
+ self._tl_segment_if_stm(mc)
+ mc.MOV_jr(rst, eax.value)
+ #
# must restore 'ebp' from its saved value in the shadowstack
self._reload_frame_if_necessary(mc)
#
- # jump to the place saved in the stm_resume_buffer
+ # jump to the place saved in stm_resume_buffer[0]
# (to "HERE" in genop_stm_transaction_break())
- mc.MOV_rs(eax.value, FRAME_FIXED_SIZE * WORD)
+ mc.MOV_rs(eax.value, (FRAME_FIXED_SIZE + 0) * WORD)
mc.PUSH_r(eax.value)
mc.JMP_r(eax.value)
self.stm_longjmp_callback_addr = mc.materialize(self.cpu.asmmemmgr, [])
@@ -2897,12 +2903,15 @@
# Fill the stm resume buffer. Don't do it before the call!
# The previous transaction may still be aborted during the call
# above, so we need the old content of the buffer!
- # For now the buffer only contains the address of the resume
- # point in this piece of code (at "HERE").
+ # The buffer contains the address of the resume point in this
+ # piece of code (at "HERE") at offset 0, and at offset WORD it
+ # contains a copy of the current shadowstack pointer.
+ self._load_shadowstack_top_in_ebx(mc, self.cpu.gc_ll_descr.gcrootmap)
+ mc.MOV_sr((FRAME_FIXED_SIZE + 1) * WORD, ebx.value)
mc.CALL_l(0)
# "HERE"
mc.POP_r(eax.value)
- mc.MOV_sr(FRAME_FIXED_SIZE * WORD, eax.value)
+ mc.MOV_sr((FRAME_FIXED_SIZE + 0) * WORD, eax.value)
#
# patch the JZ above
offset = mc.get_relative_pos() - jz_location
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit