Skip to content

Commit c164679

Browse files
iii-iakpm00
authored andcommitted
scripts/gdb/symbols: determine KASLR offset on s390 during early boot
Using lx-symbols during s390 early boot fails with: Error occurred in Python: 'utf-8' codec can't decode byte 0xcb in position 0: invalid continuation byte The reason is that s390 decompressor's startup_kernel() does not create vmcoreinfo note, and sets vmcore_info to kernel's physical base. This confuses get_vmcore_s390(). Fix by handling this special case. Extract vm_layout.kaslr_offset from the kernel image in physical memory, which is placed there by the decompressor using the __bootdata_preserved mechanism, and generate a synthetic vmcoreinfo note from it. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ilya Leoshkevich <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Jan Kiszka <[email protected]> Cc: Kieran Bingham <[email protected]> Cc: Vasily Gorbik <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent e97c4a2 commit c164679

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

scripts/gdb/linux/symbols.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ def get_vmcore_s390():
5454
vmcore_info = 0x0e0c
5555
paddr_vmcoreinfo_note = gdb.parse_and_eval("*(unsigned long long *)" +
5656
hex(vmcore_info))
57+
if paddr_vmcoreinfo_note == 0 or paddr_vmcoreinfo_note & 1:
58+
# In the early boot case, extract vm_layout.kaslr_offset from the
59+
# vmlinux image in physical memory.
60+
if paddr_vmcoreinfo_note == 0:
61+
kaslr_offset_phys = 0
62+
else:
63+
kaslr_offset_phys = paddr_vmcoreinfo_note - 1
64+
with utils.pagination_off():
65+
gdb.execute("symbol-file {0} -o {1}".format(
66+
utils.get_vmlinux(), hex(kaslr_offset_phys)))
67+
kaslr_offset = gdb.parse_and_eval("vm_layout.kaslr_offset")
68+
return "KERNELOFFSET=" + hex(kaslr_offset)[2:]
5769
inferior = gdb.selected_inferior()
5870
elf_note = inferior.read_memory(paddr_vmcoreinfo_note, 12)
5971
n_namesz, n_descsz, n_type = struct.unpack(">III", elf_note)

0 commit comments

Comments
 (0)