From ede89793ecb0e62ab0f24eabaf5a0b60127b42b9 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Sat, 16 Sep 2017 14:36:58 -0700 Subject: [PATCH] microcode: Restore frame pointer as well as stack pointer. --- src/microcode/cmpauxmd/i386.m4 | 6 ++++-- src/microcode/cmpauxmd/x86-64.m4 | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/microcode/cmpauxmd/i386.m4 b/src/microcode/cmpauxmd/i386.m4 index 7d9fe7c9e..aea85be5d 100644 --- a/src/microcode/cmpauxmd/i386.m4 +++ b/src/microcode/cmpauxmd/i386.m4 @@ -677,12 +677,14 @@ interface_to_scheme_proceed: ') OP(mov,l) TW(EVR(Free),rfree) # Free pointer = %edi OP(mov,l) TW(LOF(REGBLOCK_VAL(),regs),REG(eax)) # Value/dynamic link - OP(mov,l) TW(IMM(ADDRESS_MASK),rmask) # = %ebp - # Restore the C stack pointer, which we zeroed back in # scheme_to_interface, for within_c_stack. + # Restore the C frame pointer too; the interface may have called + # Re_Enter_Interpreter which probably clobbered both. OP(mov,l) TW(REG(esp),EVR(C_Stack_Pointer)) OP(mov,l) TW(EVR(stack_pointer),REG(esp)) + OP(mov,l) TW(REG(ebp),EVT(C_Frame_Pointer)) + OP(mov,l) TW(IMM(ADDRESS_MASK),rmask) # = %ebp OP(mov,l) TW(REG(eax),REG(ecx)) # Preserve if used OP(and,l) TW(rmask,REG(ecx)) # Restore potential dynamic link OP(mov,l) TW(REG(ecx),LOF(REGBLOCK_DLINK(),regs)) diff --git a/src/microcode/cmpauxmd/x86-64.m4 b/src/microcode/cmpauxmd/x86-64.m4 index b7a19c93d..ed1a5cbca 100644 --- a/src/microcode/cmpauxmd/x86-64.m4 +++ b/src/microcode/cmpauxmd/x86-64.m4 @@ -476,11 +476,14 @@ ifdef(`WIN32', # Register block = %rsi ` OP(lea,q) TW(ABS(EVR(Registers)),regs)') OP(mov,q) TW(ABS(EVR(Free)),rfree) # Free pointer = %rdi OP(mov,q) TW(QOF(REGBLOCK_VAL(),regs),REG(rax)) # Value/dynamic link - OP(mov,q) TW(IMM(ADDRESS_MASK),rmask) # = %rbp # Restore the C stack pointer, which we zeroed back in # scheme_to_interface, for within_c_stack. + # Restore the C frame pointer too; the interface may have called + # Re_Enter_Interpreter which probably clobbered both. OP(mov,q) TW(REG(rsp),ABS(EVR(C_Stack_Pointer))) OP(mov,q) TW(ABS(EVR(stack_pointer)),REG(rsp)) + OP(mov,q) TW(REG(rbp),ABS(EVR(C_Frame_Pointer))) + OP(mov,q) TW(IMM(ADDRESS_MASK),rmask) # = %rbp OP(mov,q) TW(REG(rax),REG(rcx)) # Preserve if used OP(and,q) TW(rmask,REG(rcx)) # Restore potential dynamic link OP(mov,q) TW(REG(rcx),QOF(REGBLOCK_DLINK(),regs)) -- 2.25.1