• Peter Zijlstra's avatar
    x86_64: Allow breakpoints to emulate call instructions · 988bb5e5
    Peter Zijlstra authored
    commit 4b33dadf upstream.
    
    In order to allow breakpoints to emulate call instructions, they need to push
    the return address onto the stack. The x86_64 int3 handler adds a small gap
    to allow the stack to grow some. Use this gap to add the return address to
    be able to emulate a call instruction at the breakpoint location.
    
    These helper functions are added:
    
      int3_emulate_jmp(): changes the location of the regs->ip to return there.
    
     (The next two are only for x86_64)
      int3_emulate_push(): to push the address onto the gap in the stack
      int3_emulate_call(): push the return address and change regs->ip
    
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: Nicolai Stange <nstange@suse.de>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: the arch/x86 maintainers <x86@kernel.org>
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Jiri Kosina <jikos@kernel.org>
    Cc: Miroslav Benes <mbenes@suse.cz>
    Cc: Petr Mladek <pmladek@suse.com>
    Cc: Joe Lawrence <joe.lawrence@redhat.com>
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Cc: Tim Chen <tim.c.chen@linux.intel.com>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Mimi Zohar <zohar@linux.ibm.com>
    Cc: Juergen Gross <jgross@suse.com>
    Cc: Nick Desaulniers <ndesaulniers@google.com>
    Cc: Nayna Jain <nayna@linux.ibm.com>
    Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
    Cc: Joerg Roedel <jroedel@suse.de>
    Cc: "open list:KERNEL SELFTEST FRAMEWORK" <linux-kselftest@vger.kernel.org>
    Cc: stable@vger.kernel.org
    Fixes: b700e7f0 ("livepatch: kernel: add support for live patching")
    Tested-by: default avatarNicolai Stange <nstange@suse.de>
    Reviewed-by: default avatarNicolai Stange <nstange@suse.de>
    Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    [ Modified to only work for x86_64 and added comment to int3_emulate_push() ]
    Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    988bb5e5
text-patching.h 2.26 KB