aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>2012-01-28 13:42:35 +0200
committerPekka Enberg <penberg@kernel.org>2012-01-28 22:19:45 +0200
commit2ffd5b493019fe4e7aa8e2c7b948203291af6a84 (patch)
tree6ac9bb4333214fb39cf38ea170b7b04ebbf0ebbe
parent1cf0e537d09d5b50a1d94c026871c234bcc982d3 (diff)
downloadjato-2ffd5b493019fe4e7aa8e2c7b948203291af6a84.tar.gz
x86-64: use %rbp instead of %rsp to retrieve *this for locking
Using %rsp to get *this seems fragile, we can look it up relative to %rbp if we know the frame size and the stack layout used by prologs. Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro> Signed-off-by: Pekka Enberg <penberg@kernel.org>
-rw-r--r--arch/x86/emit_64.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/x86/emit_64.c b/arch/x86/emit_64.c
index b150f499..f7ec81ea 100644
--- a/arch/x86/emit_64.c
+++ b/arch/x86/emit_64.c
@@ -1399,7 +1399,9 @@ void emit_unlock(struct buffer *buf, struct vm_object *obj)
void emit_lock_this(struct buffer *buf, unsigned long frame_size)
{
- __emit64_mov_membase_reg(buf, MACH_REG_RSP, 0x00, MACH_REG_RDI);
+ unsigned long this_offset = frame_size + 8 * NR_CALLEE_SAVE_REGS + 8;
+
+ __emit64_mov_membase_reg(buf, MACH_REG_RBP, - this_offset, MACH_REG_RDI);
emit_save_regparm(buf);
__emit_call(buf, vm_object_lock);
emit_restore_regparm(buf);
@@ -1411,7 +1413,9 @@ void emit_lock_this(struct buffer *buf, unsigned long frame_size)
void emit_unlock_this(struct buffer *buf, unsigned long frame_size)
{
- __emit64_mov_membase_reg(buf, MACH_REG_RSP, 0x00, MACH_REG_RDI);
+ unsigned long this_offset = frame_size + 8 * NR_CALLEE_SAVE_REGS + 8;
+
+ __emit64_mov_membase_reg(buf, MACH_REG_RBP, - this_offset, MACH_REG_RDI);
__emit_push_reg(buf, MACH_REG_RAX);
emit_save_regparm(buf);
__emit_call(buf, vm_object_unlock);