Skip to content

Commit b6d0427

Browse files
iii-iAlexander Gordeev
authored andcommitted
scripts/gdb/symbols: make lx-symbols skip the s390 decompressor
When one starts QEMU with the -S flag and attaches GDB, the kernel is not yet loaded, and the current instruction is an entry point to the decompressor. In case the intention is to debug the early kernel boot, and not the decompressor, e.g., put a breakpoint on some kernel function and see all the invocations, one has to skip the decompressor. There are many ways to do this, and so far people wrote private scripts or memorized certain command sequences. Make it work out of the box like this: $ gdb -ex 'target remote :6812' -ex 'source vmlinux-gdb.py' vmlinux Remote debugging using :6812 0x0000000000010000 in ?? () (gdb) lx-symbols loading vmlinux (gdb) x/i $pc => 0x3ffe0100000 <startup_continue>: lghi %r2,0 Implement this by reading the address of the jump_to_kernel() function from the lowcore, and step until DAT is turned on. Signed-off-by: Ilya Leoshkevich <[email protected]> Acked-by: Jan Kiszka <[email protected]> Tested-by: Alexander Gordeev <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexander Gordeev <[email protected]>
1 parent 996f7f2 commit b6d0427

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

scripts/gdb/linux/symbols.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,30 @@ def get_kerneloffset():
8484
return None
8585

8686

87+
def is_in_s390_decompressor():
88+
# DAT is always off in decompressor. Use this as an indicator.
89+
# Note that in the kernel, DAT can be off during kexec() or restart.
90+
# Accept this imprecision in order to avoid complicating things.
91+
# It is unlikely that someone will run lx-symbols at these points.
92+
pswm = int(gdb.parse_and_eval("$pswm"))
93+
return (pswm & 0x0400000000000000) == 0
94+
95+
96+
def skip_decompressor():
97+
if utils.is_target_arch("s390"):
98+
if is_in_s390_decompressor():
99+
# The address of the jump_to_kernel function is statically placed
100+
# into svc_old_psw.addr (see ipl_data.c); read it from there. DAT
101+
# is off, so we do not need to care about lowcore relocation.
102+
svc_old_pswa = 0x148
103+
jump_to_kernel = int(gdb.parse_and_eval("*(unsigned long long *)" +
104+
hex(svc_old_pswa)))
105+
gdb.execute("tbreak *" + hex(jump_to_kernel))
106+
gdb.execute("continue")
107+
while is_in_s390_decompressor():
108+
gdb.execute("stepi")
109+
110+
87111
class LxSymbols(gdb.Command):
88112
"""(Re-)load symbols of Linux kernel and currently loaded modules.
89113
@@ -204,6 +228,8 @@ def load_all_symbols(self):
204228
saved_state['breakpoint'].enabled = saved_state['enabled']
205229

206230
def invoke(self, arg, from_tty):
231+
skip_decompressor()
232+
207233
self.module_paths = [os.path.abspath(os.path.expanduser(p))
208234
for p in arg.split()]
209235
self.module_paths.append(os.getcwd())

0 commit comments

Comments
 (0)