You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
s390/entry: Add CFI statements to pgm_check_handler
When debugging kernel crashes using GDB, it is helpful to be able to
obtain a backtrace after pgm_check_handler(). Currently this does not
work, because pgm_check_handler() lacks CFI.
Add missing CFI statements.
Old PSW should be obtained from lowcore, which is not addressed
relative to CFA. GNU assembler does not have directives for this, so
synthesize a DW_OP_const8u expression using .cfi_escape.
Make use of uleb128() and data8() directives introduced in binutils
2.45 for this; add a fallback in case they are not available.
Introduce CFI_OFFSET_MULTIPLE() and CFI_RESTORE_MULTIPLE() macros for
describing the effects of STMG and LMG. Unfortunately .cfi_offset and
.cfi_restore do not work with variables like .Lreg, so synthesize the
respective instructions using .cfi_escape.
With this unwinding begins to work. For example, manually corrupting
do_execveat_common()'s filename and setting a breakpoint on
__do_pgm_check() produces the following backtrace:
Thread 8 hit Breakpoint 3, __do_pgm_check (regs=0x37fe0a23b18) at ./arch/s390/include/asm/lowcore.h:224
224 asm_inline(
(gdb) bt
#0 __do_pgm_check (regs=0x37fe0a23b18) at ./arch/s390/include/asm/lowcore.h:224
#1 0x000003ffe0cc08f4 in pgm_check_handler () at arch/s390/kernel/entry.S:339
#2 0x000003ffe04f2510 in __set_nameidata (p=0x37fe0a23c78, dfd=<optimized out>, name=0xfffffff666666667) at fs/namei.c:668
#3 set_nameidata (p=0x37fe0a23c78, dfd=<optimized out>, name=0xfffffff666666667, root=0x0 <fini>) at fs/namei.c:679
#4 do_filp_open (dfd=-100, pathname=0xfffffff666666667, op=0x37fe0a23db0, op@entry=0x3ffe04e5cc2 <do_open_execat+178>) at fs/namei.c:4160
#5 0x000003ffe04e5c72 in do_open_execat (fd=fd@entry=-100, name=name@entry=0xfffffff666666667, flags=flags@entry=0) at fs/exec.c:783
torvalds#6 0x000003ffe04e5dee in alloc_bprm (fd=fd@entry=-100, filename=filename@entry=0xfffffff666666667, flags=0) at fs/exec.c:1410
torvalds#7 0x000003ffe04e6040 in do_execveat_common (fd=fd@entry=-100, filename=0xfffffff666666667, argv=..., envp=..., envp@entry=..., flags=flags@entry=0)
at fs/exec.c:1811
torvalds#8 0x000003ffe04e69c6 in do_execve (filename=<optimized out>, __argv=<optimized out>, __envp=0x2aa21a6bb60) at fs/exec.c:1934
torvalds#9 __do_sys_execve (filename=<optimized out>, argv=<optimized out>, envp=0x2aa21a6bb60) at fs/exec.c:2010
torvalds#10 __se_sys_execve (filename=<optimized out>, argv=<optimized out>, envp=2929732270944) at fs/exec.c:2005
torvalds#11 __s390x_sys_execve (regs=<optimized out>) at fs/exec.c:2005
torvalds#12 0x000003ffe0cb3cb6 in __do_syscall (regs=0x37fe0a23f40, per_trap=<optimized out>) at arch/s390/kernel/syscall.c:125
torvalds#13 0x000003ffe0cc078e in system_call () at arch/s390/kernel/entry.S:261
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
0 commit comments