* [PATCH 0/3] scripts/gdb/symbols: determine KASLR offset on s390 during early boot
@ 2025-05-15 15:52 Ilya Leoshkevich
2025-05-15 15:52 ` [PATCH 1/3] scripts/gdb/symbols: factor out get_vmlinux() Ilya Leoshkevich
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ilya Leoshkevich @ 2025-05-15 15:52 UTC (permalink / raw)
To: Jan Kiszka, Kieran Bingham, Andrew Morton
Cc: linux-kernel, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Ilya Leoshkevich
Hi,
I noticed that debugging s390 early boot using the support I introduced
in commit 28939c3e9925 ("scripts/gdb/symbols: determine KASLR offset on
s390") does not work.
The reason is that decompressor does not provide the vmcoreinfo note,
so KASLR offset needs to be extracted in a different way, which this
series implements. Patches 1-2 are trivial refactorings, and patch 3 is
the implementation.
Best regards,
Ilya
Ilya Leoshkevich (3):
scripts/gdb/symbols: factor out get_vmlinux()
scripts/gdb/symbols: factor out pagination_off()
scripts/gdb/symbols: determine KASLR offset on s390 during early boot
scripts/gdb/linux/symbols.py | 38 +++++++++++++++++++-----------------
scripts/gdb/linux/utils.py | 20 +++++++++++++++++++
2 files changed, 40 insertions(+), 18 deletions(-)
--
2.49.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] scripts/gdb/symbols: factor out get_vmlinux()
2025-05-15 15:52 [PATCH 0/3] scripts/gdb/symbols: determine KASLR offset on s390 during early boot Ilya Leoshkevich
@ 2025-05-15 15:52 ` Ilya Leoshkevich
2025-05-15 15:52 ` [PATCH 2/3] scripts/gdb/symbols: factor out pagination_off() Ilya Leoshkevich
2025-05-15 15:52 ` [PATCH 3/3] scripts/gdb/symbols: determine KASLR offset on s390 during early boot Ilya Leoshkevich
2 siblings, 0 replies; 4+ messages in thread
From: Ilya Leoshkevich @ 2025-05-15 15:52 UTC (permalink / raw)
To: Jan Kiszka, Kieran Bingham, Andrew Morton
Cc: linux-kernel, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Ilya Leoshkevich
Move the code that determines the current vmlinux file into a separate
function. It will be useful later in order to analyze the kernel image
in physical memory during s390 early boot.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
scripts/gdb/linux/symbols.py | 6 +-----
scripts/gdb/linux/utils.py | 9 +++++++++
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py
index b255177301e9..25c4627c60e5 100644
--- a/scripts/gdb/linux/symbols.py
+++ b/scripts/gdb/linux/symbols.py
@@ -178,11 +178,7 @@ lx-symbols command."""
saved_states.append({'breakpoint': bp, 'enabled': bp.enabled})
# drop all current symbols and reload vmlinux
- orig_vmlinux = 'vmlinux'
- for obj in gdb.objfiles():
- if (obj.filename.endswith('vmlinux') or
- obj.filename.endswith('vmlinux.debug')):
- orig_vmlinux = obj.filename
+ orig_vmlinux = utils.get_vmlinux()
gdb.execute("symbol-file", to_string=True)
kerneloffset = get_kerneloffset()
if kerneloffset is None:
diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py
index 03ebdccf5f69..fc94ff6a6d72 100644
--- a/scripts/gdb/linux/utils.py
+++ b/scripts/gdb/linux/utils.py
@@ -251,3 +251,12 @@ def parse_vmcore(s):
else:
kerneloffset = int(match.group(1), 16)
return VmCore(kerneloffset=kerneloffset)
+
+
+def get_vmlinux():
+ vmlinux = 'vmlinux'
+ for obj in gdb.objfiles():
+ if (obj.filename.endswith('vmlinux') or
+ obj.filename.endswith('vmlinux.debug')):
+ vmlinux = obj.filename
+ return vmlinux
--
2.49.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] scripts/gdb/symbols: factor out pagination_off()
2025-05-15 15:52 [PATCH 0/3] scripts/gdb/symbols: determine KASLR offset on s390 during early boot Ilya Leoshkevich
2025-05-15 15:52 ` [PATCH 1/3] scripts/gdb/symbols: factor out get_vmlinux() Ilya Leoshkevich
@ 2025-05-15 15:52 ` Ilya Leoshkevich
2025-05-15 15:52 ` [PATCH 3/3] scripts/gdb/symbols: determine KASLR offset on s390 during early boot Ilya Leoshkevich
2 siblings, 0 replies; 4+ messages in thread
From: Ilya Leoshkevich @ 2025-05-15 15:52 UTC (permalink / raw)
To: Jan Kiszka, Kieran Bingham, Andrew Morton
Cc: linux-kernel, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Ilya Leoshkevich
Move the code that turns off pagination into a separate function. It
will be useful later in order to prevent hangs when loading symbols for
kernel image in physical memory during s390 early boot.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
scripts/gdb/linux/symbols.py | 20 +++++++-------------
scripts/gdb/linux/utils.py | 11 +++++++++++
2 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py
index 25c4627c60e5..0c7af712c44c 100644
--- a/scripts/gdb/linux/symbols.py
+++ b/scripts/gdb/linux/symbols.py
@@ -38,19 +38,13 @@ if hasattr(gdb, 'Breakpoint'):
# Disable pagination while reporting symbol (re-)loading.
# The console input is blocked in this context so that we would
# get stuck waiting for the user to acknowledge paged output.
- show_pagination = gdb.execute("show pagination", to_string=True)
- pagination = show_pagination.endswith("on.\n")
- gdb.execute("set pagination off")
-
- if module_name in cmd.loaded_modules:
- gdb.write("refreshing all symbols to reload module "
- "'{0}'\n".format(module_name))
- cmd.load_all_symbols()
- else:
- cmd.load_module_symbols(module)
-
- # restore pagination state
- gdb.execute("set pagination %s" % ("on" if pagination else "off"))
+ with utils.pagination_off():
+ if module_name in cmd.loaded_modules:
+ gdb.write("refreshing all symbols to reload module "
+ "'{0}'\n".format(module_name))
+ cmd.load_all_symbols()
+ else:
+ cmd.load_module_symbols(module)
return False
diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py
index fc94ff6a6d72..dc379ab11af0 100644
--- a/scripts/gdb/linux/utils.py
+++ b/scripts/gdb/linux/utils.py
@@ -260,3 +260,14 @@ def get_vmlinux():
obj.filename.endswith('vmlinux.debug')):
vmlinux = obj.filename
return vmlinux
+
+
+@contextlib.contextmanager
+def pagination_off():
+ show_pagination = gdb.execute("show pagination", to_string=True)
+ pagination = show_pagination.endswith("on.\n")
+ gdb.execute("set pagination off")
+ try:
+ yield
+ finally:
+ gdb.execute("set pagination %s" % ("on" if pagination else "off"))
--
2.49.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] scripts/gdb/symbols: determine KASLR offset on s390 during early boot
2025-05-15 15:52 [PATCH 0/3] scripts/gdb/symbols: determine KASLR offset on s390 during early boot Ilya Leoshkevich
2025-05-15 15:52 ` [PATCH 1/3] scripts/gdb/symbols: factor out get_vmlinux() Ilya Leoshkevich
2025-05-15 15:52 ` [PATCH 2/3] scripts/gdb/symbols: factor out pagination_off() Ilya Leoshkevich
@ 2025-05-15 15:52 ` Ilya Leoshkevich
2 siblings, 0 replies; 4+ messages in thread
From: Ilya Leoshkevich @ 2025-05-15 15:52 UTC (permalink / raw)
To: Jan Kiszka, Kieran Bingham, Andrew Morton
Cc: linux-kernel, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Ilya Leoshkevich
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.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
scripts/gdb/linux/symbols.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py
index 0c7af712c44c..2332bd8eddf1 100644
--- a/scripts/gdb/linux/symbols.py
+++ b/scripts/gdb/linux/symbols.py
@@ -54,6 +54,18 @@ def get_vmcore_s390():
vmcore_info = 0x0e0c
paddr_vmcoreinfo_note = gdb.parse_and_eval("*(unsigned long long *)" +
hex(vmcore_info))
+ if paddr_vmcoreinfo_note == 0 or paddr_vmcoreinfo_note & 1:
+ # In the early boot case, extract vm_layout.kaslr_offset from the
+ # vmlinux image in physical memory.
+ if paddr_vmcoreinfo_note == 0:
+ kaslr_offset_phys = 0
+ else:
+ kaslr_offset_phys = paddr_vmcoreinfo_note - 1
+ with utils.pagination_off():
+ gdb.execute("symbol-file {0} -o {1}".format(
+ utils.get_vmlinux(), hex(kaslr_offset_phys)))
+ kaslr_offset = gdb.parse_and_eval("vm_layout.kaslr_offset")
+ return "KERNELOFFSET=" + hex(kaslr_offset)[2:]
inferior = gdb.selected_inferior()
elf_note = inferior.read_memory(paddr_vmcoreinfo_note, 12)
n_namesz, n_descsz, n_type = struct.unpack(">III", elf_note)
--
2.49.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-05-15 15:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-15 15:52 [PATCH 0/3] scripts/gdb/symbols: determine KASLR offset on s390 during early boot Ilya Leoshkevich
2025-05-15 15:52 ` [PATCH 1/3] scripts/gdb/symbols: factor out get_vmlinux() Ilya Leoshkevich
2025-05-15 15:52 ` [PATCH 2/3] scripts/gdb/symbols: factor out pagination_off() Ilya Leoshkevich
2025-05-15 15:52 ` [PATCH 3/3] scripts/gdb/symbols: determine KASLR offset on s390 during early boot Ilya Leoshkevich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®