lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <cc4af3fa0fcda2a52cbbab05463e0ad0561fd017.1756521755.git.ritesh.list@gmail.com>
Date: Sat, 30 Aug 2025 09:15:34 +0530
From: "Ritesh Harjani (IBM)" <ritesh.list@...il.com>
To: Jan Kiszka <jan.kiszka@...mens.com>,
	Kieran Bingham <kbingham@...nel.org>
Cc: linux-kernel@...r.kernel.org,
	linuxppc-dev@...ts.ozlabs.org,
	"Ritesh Harjani (IBM)" <ritesh.list@...il.com>
Subject: [PATCH 01/02] scripts/gdb/cpus: Add support for get_current_task for powerpc book3s64

This adds support to query p $lx_current() for ppc64 book3s64.
This allows us to utilize gdb scripts functions like:

function lx_current
function lx_task_by_pid
function lx_thread_info
function lx_thread_info_by_pid

e.g.
(gdb) p $lx_current()->comm
$1 = "swapper\000\000\000\000\000\000\000\00

Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@...il.com>
---
 scripts/gdb/linux/constants.py.in |  1 +
 scripts/gdb/linux/cpus.py         | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/scripts/gdb/linux/constants.py.in b/scripts/gdb/linux/constants.py.in
index c3886739a028..154db10fe94a 100644
--- a/scripts/gdb/linux/constants.py.in
+++ b/scripts/gdb/linux/constants.py.in
@@ -152,6 +152,7 @@ if IS_BUILTIN(CONFIG_ARM64):
     LX_VALUE(CONFIG_ARM64_VA_BITS)
     LX_VALUE(CONFIG_PAGE_SHIFT)
     LX_VALUE(CONFIG_ARCH_FORCE_MAX_ORDER)
+LX_CONFIG(CONFIG_PPC_BOOK3S_64)
 LX_CONFIG(CONFIG_SPARSEMEM)
 LX_CONFIG(CONFIG_SPARSEMEM_EXTREME)
 LX_CONFIG(CONFIG_SPARSEMEM_VMEMMAP)
diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py
index 6edf4ef61636..c250de14ac19 100644
--- a/scripts/gdb/linux/cpus.py
+++ b/scripts/gdb/linux/cpus.py
@@ -13,7 +13,7 @@

 import gdb

-from linux import tasks, utils
+from linux import tasks, utils, constants


 task_type = utils.CachedType("struct task_struct")
@@ -207,6 +207,21 @@ def get_current_task(cpu):
             current_task = scratch_reg.cast(task_ptr_type)

         return current_task.dereference()
+    elif utils.is_target_arch("powerpc"):
+        if not constants.LX_CONFIG_PPC_BOOK3S_64:
+            raise gdb.GdbError('For now only supported for BOOK3S_64')
+
+        msr = gdb.parse_and_eval("(unsigned long)$msr")
+        # PR (Problem State) should be 0 for kernel mode
+        in_kernel = msr & (0x1 << 14) == 0
+        if in_kernel:
+            paca_ptr_type = gdb.lookup_type("struct paca_struct").pointer()
+            paca_ptr = gdb.parse_and_eval("$r13")
+            paca = paca_ptr.cast(paca_ptr_type).dereference()
+            return paca["__current"].cast(task_ptr_type).dereference()
+        else:
+            raise gdb.GdbError("Sorry, obtaining the current task is not allowed "
+                               "while running in userspace (Problem State)")
     else:
         raise gdb.GdbError("Sorry, obtaining the current task is not yet "
                            "supported with this arch")
--
2.50.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ