Commit Graph

123 Commits

Author SHA1 Message Date
Rafael Aquini 1ac04de9a1 scripts/gdb: redefine MAX_ORDER sanely
JIRA: https://issues.redhat.com/browse/RHEL-84184

This patch is a backport of the following upstream commit:
commit 63ce5947ef45071d825d4712d6c5ece13f1ce2f6
Author: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
Date:   Wed Jun 19 15:49:06 2024 +0800

    scripts/gdb: redefine MAX_ORDER sanely

    Patch series "Fix GDB command error".

    This patchset fixes some GDB command errors.

    1. Since memory layout of AARCH64 has been changed, we need to modify
       the layout in GDB scripts as well.

    2. Fix pool_index naming of stackdepot.

    This patch (of 6):

    Change the definition of MAX_ORDER to be inclusive.

    Link: https://lkml.kernel.org/r/20240619074911.100434-1-kuan-ying.lee@canonical.com
    Link: https://lkml.kernel.org/r/20240619074911.100434-2-kuan-ying.lee@canonical.com
    Fixes: 23baf831a32c ("mm, treewide: redefine MAX_ORDER sanely")
    Signed-off-by: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
    Cc: Jan Kiszka <jan.kiszka@siemens.com>
    Cc: Kieran Bingham <kbingham@kernel.org>
    Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Rafael Aquini <raquini@redhat.com>
2025-04-18 08:39:49 -04:00
Mark Salter 2d16cdc81b scripts/gdb: change the layout of vmemmap
JIRA: https://issues.redhat.com/browse/RHEL-40604

commit 3c0e9a200434e8bb4a2bffbaaeb381bdff5a5938
Author: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
Date: Wed, 19 Jun 2024 15:49:08 +0800

    We need to change the layout of vmemmap in gdb scripts after
    commit 32697ff38287 ("arm64: vmemmap: Avoid base2 order of
    struct page size to dimension region") changed it.

    Link: https://lkml.kernel.org/r/20240619074911.100434-4-kuan-ying.lee@canonical.com
    Fixes: 32697ff38287 ("arm64: vmemmap: Avoid base2 order of struct page size to dimension region")
    Signed-off-by: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
    Cc: Jan Kiszka <jan.kiszka@siemens.com>
    Cc: Kieran Bingham <kbingham@kernel.org>
    Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Mark Salter <msalter@redhat.com>
2024-10-31 10:42:52 -04:00
Mark Salter 676b14154b scripts/gdb: change VA_BITS_MIN when we use 16K page
JIRA: https://issues.redhat.com/browse/RHEL-40604

commit 7d8742bf853cc1d4faf08840cc64414ad5f34061
Author: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
Date: Wed, 19 Jun 2024 15:49:10 +0800

    Change VA_BITS_MIN when we use 16K page.

    Link: https://lkml.kernel.org/r/20240619074911.100434-6-kuan-ying.lee@canonical.com
    Fixes: 9684ec186f8f ("arm64: Enable LPA2 at boot if supported by the system")
    Signed-off-by: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
    Cc: Jan Kiszka <jan.kiszka@siemens.com>
    Cc: Kieran Bingham <kbingham@kernel.org>
    Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Mark Salter <msalter@redhat.com>
2024-10-31 10:42:52 -04:00
Mark Salter 5880d7b9e4 scripts/gdb: set vabits_actual based on TCR_EL1
JIRA: https://issues.redhat.com/browse/RHEL-40604

commit 04a40baec04fa0634d71ebfa0c91469160a9976e
Author: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
Date: Wed, 19 Jun 2024 15:49:09 +0800

    We encounter the following issue after commit 9cce9c6c2c3b ("arm64: mm: Handle
    LVA support as a CPU feature").

    (gdb) lx-slabinfo
    Python Exception <class 'gdb.error'>: No symbol "vabits_actual" in current context.
    Error occurred in Python: No symbol "vabits_actual" in current context.

    We set vabits_actual based on TCR_EL1 value when
    VA_BITS is bigger than 48.

    Link: https://lkml.kernel.org/r/20240619074911.100434-5-kuan-ying.lee@canonical.com
    Fixes: 9cce9c6c2c3b ("arm64: mm: Handle LVA support as a CPU feature")
    Signed-off-by: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
    Cc: Jan Kiszka <jan.kiszka@siemens.com>
    Cc: Kieran Bingham <kbingham@kernel.org>
    Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Mark Salter <msalter@redhat.com>
2024-10-31 10:42:52 -04:00
Mark Salter eced195c17 scripts/gdb/aarch64: add aarch64 page operation helper commands and configs
JIRA: https://issues.redhat.com/browse/RHEL-40604

Conflicts:
	scripts/gdb/linux/constants.py.in
	Out of order backport of commit 8ac647d96a "x86: replace
	CONFIG_HAVE_KVM with IS_ENABLED(CONFIG_KVM)"

	scripts/gdb/vmlinux-gdb.py
	No backports for vfs, radixtree, and interrupts helpers

commit eb985b5dbf9791136700c555fbf964b6c07481ce
Author: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
Date: Tue, 8 Aug 2023 16:30:14 +0800

    1. Move page table debugging from mm.py to pgtable.py.

    2. Add aarch64 kernel config and memory constants value.

    3. Add below aarch64 page operation helper commands.
       page_to_pfn, page_to_phys, pfn_to_page, page_address,
       virt_to_phys, sym_to_pfn, pfn_to_kaddr, virt_to_page.

    4. Only support CONFIG_SPARSEMEM_VMEMMAP=y now.

    Link: https://lkml.kernel.org/r/20230808083020.22254-5-Kuan-Ying.Lee@mediatek.com
    Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
    Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Cc: Chinwen Chang <chinwen.chang@mediatek.com>
    Cc: Matthias Brugger <matthias.bgg@gmail.com>
    Cc: Qun-Wei Lin <qun-wei.lin@mediatek.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Mark Salter <msalter@redhat.com>
2024-10-31 10:35:27 -04:00
Mark Salter b331750f53 scripts/gdb: add mm introspection utils
JIRA: https://issues.redhat.com/browse/RHEL-40604

commit e36903b0c19fc6e4cfd84a55840ac9559c3f2831
Author: Dmitrii Bundin <dmitrii.bundin.a@gmail.com>
Date: Mon, 2 Jan 2023 20:10:14 +0300

    This command provides a way to traverse the entire page hierarchy by a
    given virtual address on x86.  In addition to qemu's commands info
    tlb/info mem it provides the complete information about the paging
    structure for an arbitrary virtual address.  It supports 4KB/2MB/1GB and 5
    level paging.

    Here is an example output for 2MB success translation:

    (gdb) translate-vm address
    cr3:
        cr3 binary data                0x1085be003
        next entry physical address   0x1085be000
        ---
        bit  3          page level write through       False
        bit  4          page level cache disabled      False
    level 4:
        entry address                  0xffff8881085be7f8
        page entry binary data         0x800000010ac83067
        next entry physical address   0x10ac83000
        ---
        bit  0          entry present                  True
        bit  1          read/write access allowed      True
        bit  2          user access allowed            True
        bit  3          page level write through       False
        bit  4          page level cache disabled      False
        bit  5          entry has been accessed        True
        bit  7          page size                      False
        bit  11         restart to ordinary            False
        bit  63         execute disable                True
    level 3:
        entry address                  0xffff88810ac83a48
        page entry binary data         0x101af7067
        next entry physical address   0x101af7000
        ---
        bit  0          entry present                  True
        bit  1          read/write access allowed      True
        bit  2          user access allowed            True
        bit  3          page level write through       False
        bit  4          page level cache disabled      False
        bit  5          entry has been accessed        True
        bit  7          page size                      False
        bit  11         restart to ordinary            False
        bit  63         execute disable                False
    level 2:
        entry address                  0xffff888101af7368
        page entry binary data         0x80000001634008e7
        page size                      2MB
        page physical address         0x163400000
        ---
        bit  0          entry present                  True
        bit  1          read/write access allowed      True
        bit  2          user access allowed            True
        bit  3          page level write through       False
        bit  4          page level cache disabled      False
        bit  5          entry has been accessed        True
        bit  7          page size                      True
        bit  6          page dirty                     True
        bit  8          global translation             False
        bit  11         restart to ordinary            True
        bit  12         pat                            False
        bits (59, 62)   protection key                 0
        bit  63         execute disable                True

    [dmitrii.bundin.a@gmail.com: add SPDX line, other tweaks]
      Link: https://lkml.kernel.org/r/20230113175151.22278-1-dmitrii.bundin.a@gmail.com
    [akpm@linux-foundation.org: s/physicall/physical/]
    Link: https://lkml.kernel.org/r/20230102171014.31408-1-dmitrii.bundin.a@gmail.com
    Signed-off-by: Dmitrii Bundin <dmitrii.bundin.a@gmail.com>
    Acked by: Mike Rapoport (IBM) <rppt@kernel.org>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Jan Kiszka <jan.kiszka@siemens.com>
    Cc: Kieran Bingham <kbingham@kernel.org>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Mark Salter <msalter@redhat.com>
2024-10-31 10:35:25 -04:00
Donald Dutile 24697c1d64 scripts/gdb: fix usage of MOD_TEXT not defined when CONFIG_MODULES=n
JIRA: https://issues.redhat.com/browse/RHEL-28063

commit 16501630bdeb107141a0139ddc33f92ab5582c6f
Author: Clément Léger <cleger@rivosinc.com>
Date:   Tue Oct 31 13:49:04 2023 +0000

    scripts/gdb: fix usage of MOD_TEXT not defined when CONFIG_MODULES=n

    MOD_TEXT is only defined if CONFIG_MODULES=y which lead to loading failure
    of the gdb scripts when kernel is built without CONFIG_MODULES=y:

    Reading symbols from vmlinux...
    Traceback (most recent call last):
      File "/foo/vmlinux-gdb.py", line 25, in <module>
        import linux.constants
      File "/foo/scripts/gdb/linux/constants.py", line 14, in <module>
        LX_MOD_TEXT = gdb.parse_and_eval("MOD_TEXT")
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    gdb.error: No symbol "MOD_TEXT" in current context.

    Add a conditional check on CONFIG_MODULES to fix this error.

    Link: https://lkml.kernel.org/r/20231031134848.119391-1-da.gomez@samsung.com
    Fixes: b4aff7513df3 ("scripts/gdb: use mem instead of core_layout to get the module address")
    Signed-off-by: Clément Léger <cleger@rivosinc.com>
    Tested-by: Daniel Gomez <da.gomez@samsung.com>
    Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
    Cc: Jan Kiszka <jan.kiszka@siemens.com>
    Cc: Kieran Bingham <kbingham@kernel.org>
    Cc: Luis Chamberlain <mcgrof@kernel.org>
    Cc: Pankaj Raghav <p.raghav@samsung.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Donald Dutile <ddutile@redhat.com>
2024-06-17 14:17:23 -04:00
Donald Dutile fc86c9672e scripts/gdb: fix 'lx-lsmod' show the wrong size
JIRA: https://issues.redhat.com/browse/RHEL-28063

commit fb40b0537342e1acd5c2daf2ff6780c1d0d2883c
Author: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
Date:   Mon Jul 10 17:28:46 2023 +0800

    scripts/gdb: fix 'lx-lsmod' show the wrong size

    'lsmod' shows total core layout size, so we need to sum up all the
    sections in core layout in gdb scripts.

    / # lsmod
    kasan_test 200704 0 - Live 0xffff80007f640000

    Before patch:
    (gdb) lx-lsmod
    Address            Module                  Size  Used by
    0xffff80007f640000 kasan_test             36864  0

    After patch:
    (gdb) lx-lsmod
    Address            Module                  Size  Used by
    0xffff80007f640000 kasan_test            200704  0

    Link: https://lkml.kernel.org/r/20230710092852.31049-1-Kuan-Ying.Lee@mediatek.com
    Fixes: b4aff7513df3 ("scripts/gdb: use mem instead of core_layout to get the module address")
    Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
    Reviewed-by: Pankaj Raghav <p.raghav@samsung.com>
    Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Cc: Chinwen Chang <chinwen.chang@mediatek.com>
    Cc: Jan Kiszka <jan.kiszka@siemens.com>
    Cc: Kieran Bingham <kbingham@kernel.org>
    Cc: Luis Chamberlain <mcgrof@kernel.org>
    Cc: Matthias Brugger <matthias.bgg@gmail.com>
    Cc: Qun-Wei Lin <qun-wei.lin@mediatek.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Donald Dutile <ddutile@redhat.com>
2024-06-17 14:17:22 -04:00
Donald Dutile 5ed08061e6 scripts/gdb: use mem instead of core_layout to get the module address
JIRA: https://issues.redhat.com/browse/RHEL-28063

commit b4aff7513df323553de714dcf7b54e896577be1f
Author: Pankaj Raghav <p.raghav@samsung.com>
Date:   Thu Apr 13 14:00:55 2023 -0700

    scripts/gdb: use mem instead of core_layout to get the module address

    commit ac3b43283923 ("module: replace module_layout with module_memory")
    changed the struct module data structure from module_layout to
    module_memory. The core_layout member which is used while loading
    modules are not available anymore leading to the following error while
    running gdb:

    (gdb) lx-symbols
    loading vmlinux
    Python Exception <class 'gdb.error'>: There is no member named core_layout.
    Error occurred in Python: There is no member named core_layout.

    Replace core_layout with its new counterpart mem[MOD_TEXT].

    Fixes: ac3b43283923 ("module: replace module_layout with module_memory")
    Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
    Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>

Signed-off-by: Donald Dutile <ddutile@redhat.com>
2024-06-17 14:17:22 -04:00
Donald Dutile 0d61d90711 scripts/gdb: Fix gdb 'lx-symbols' command
JIRA: https://issues.redhat.com/browse/RHEL-28063

commit 23a67619bc7e12e1b3776802f16084530b357a5d
Author: Khalid Masum <khalid.masum.92@gmail.com>
Date:   Thu Jul 21 15:30:42 2022 +0600

    scripts/gdb: Fix gdb 'lx-symbols' command

    Currently the command 'lx-symbols' in gdb exits with the error`Function
    "do_init_module" not defined in "kernel/module.c"`. This occurs because
    the file kernel/module.c was moved to kernel/module/main.c.

    Fix this breakage by changing the path to "kernel/module/main.c" in
    LoadModuleBreakpoint.

    Signed-off-by: Khalid Masum <khalid.masum.92@gmail.com>
    Acked-by: Luis Chamberlain <mcgrof@kernel.org>
    Fixes: cfc1d277891e ("module: Move all into module/")
    Reviewed-by: Douglas Anderson <dianders@chromium.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Signed-off-by: Donald Dutile <ddutile@redhat.com>
2024-06-17 14:17:12 -04:00
Maxim Levitsky 8ac647d96a x86: replace CONFIG_HAVE_KVM with IS_ENABLED(CONFIG_KVM)
JIRA: https://issues.redhat.com/browse/RHEL-32430

commit dcf0926e9b899eca754a07c4064de69815b85a38
Author: Paolo Bonzini <pbonzini@redhat.com>
Date:   Thu Jan 4 15:15:43 2024 -0500

    x86: replace CONFIG_HAVE_KVM with IS_ENABLED(CONFIG_KVM)

    It is more accurate to check if KVM is enabled, instead of having the
    architecture say so.  Architectures always "have" KVM, so for example
    checking CONFIG_HAVE_KVM in x86 code is pointless, but if KVM is disabled
    in a specific build, there is no need for support code.

    Alternatively, many of the #ifdefs could simply be deleted.  However,
    this would add completely dead code.  For example, when KVM is disabled,
    there should not be any posted interrupts, i.e. NOT wiring up the "dummy"
    handlers and treating IRQs on those vectors as spurious is the right
    thing to do.

    Cc: x86@kernel.org
    Cc: kbingham@kernel.org
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>


Conflicts:
   - missing commit b0969d7687a7aaa82dcf2d1f245ef699387886da scripts/gdb: print interrupts
   - missing commit eb985b5dbf9791136700c555fbf964b6c07481ce scripts/gdb/aarch64: add aarch64 page operation helper commands and configs

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
2024-05-13 18:38:35 -04:00
Ming Lei c09eaf9199 scripts/gdb: fix SB_* constants parsing
JIRA: https://issues.redhat.com/browse/RHEL-29262

commit 6a59cb5158bff13b80f116305155fbe4967a5010
Author: Florian Fainelli <florian.fainelli@broadcom.com>
Date:   Wed Jun 7 15:13:35 2023 -0700

    scripts/gdb: fix SB_* constants parsing

    --0000000000009a0c9905fd9173ad
    Content-Transfer-Encoding: 8bit

    After f15afbd34d8f ("fs: fix undefined behavior in bit shift for
    SB_NOUSER") the constants were changed from plain integers which
    LX_VALUE() can parse to constants using the BIT() macro which causes the
    following:

    Reading symbols from build/linux-custom/vmlinux...done.
    Traceback (most recent call last):
      File "/home/fainelli/work/buildroot/output/arm64/build/linux-custom/vmlinux-gdb.py", line 25, in <module>
        import linux.constants
      File "/home/fainelli/work/buildroot/output/arm64/build/linux-custom/scripts/gdb/linux/constants.py", line 5
        LX_SB_RDONLY = ((((1UL))) << (0))

    Use LX_GDBPARSED() which does not suffer from that issue.

    f15afbd34d8f ("fs: fix undefined behavior in bit shift for SB_NOUSER")
    Link: https://lkml.kernel.org/r/20230607221337.2781730-1-florian.fainelli@broadcom.com
    Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
    Acked-by: Christian Brauner <brauner@kernel.org>
    Cc: Hao Ge <gehao@kylinos.cn>
    Cc: Jan Kiszka <jan.kiszka@siemens.com>
    Cc: Kieran Bingham <kbingham@kernel.org>
    Cc: Luis Chamberlain <mcgrof@kernel.org>
    Cc: Pankaj Raghav <p.raghav@samsung.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Ming Lei <ming.lei@redhat.com>
2024-03-19 10:07:47 +08:00
Waiman Long d147413f2b scripts/gdb: fix 'lx-current' for x86
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2190342

commit c16a3b11eaa88872d07f135df94dfa3fbcd05d10
Author: Jeff Xie <xiehuan09@gmail.com>
Date:   Sat, 4 Feb 2023 17:01:39 +0800

    scripts/gdb: fix 'lx-current' for x86

    When printing the name of the current process, it will report an error:
    (gdb) p $lx_current().comm Python Exception <class 'gdb.error'> No symbol
    "current_task" in current context.: Error occurred in Python: No symbol
    "current_task" in current context.

    Because e57ef2ed97c1 ("x86: Put hot per CPU variables into a struct")
    changed it.

    Link: https://lkml.kernel.org/r/20230204090139.1789264-1-xiehuan09@gmail.com
    Fixes: e57ef2ed97c1 ("x86: Put hot per CPU variables into a struct")
    Signed-off-by: Jeff Xie <xiehuan09@gmail.com>
    Cc: Jan Kiszka <jan.kiszka@siemens.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Waiman Long <longman@redhat.com>
2023-06-30 20:32:15 -04:00
Barry Song 526940e396 scripts/gdb: add lx_current support for arm64
arm64 uses SP_EL0 to save the current task_struct address.  While running
in EL0, SP_EL0 is clobbered by userspace.  So if the upper bit is not 1
(not TTBR1), the current address is invalid.  This patch checks the upper
bit of SP_EL0, if the upper bit is 1, lx_current() of arm64 will return
the derefrence of current task.  Otherwise, lx_current() will tell users
they are running in userspace(EL0).

While arm64 is running in EL0, it is actually pointless to print current
task as the memory of kernel space is not accessible in EL0.

Link: https://lkml.kernel.org/r/20210314203444.15188-3-song.bao.hua@hisilicon.com
Signed-off-by: Barry Song <song.bao.hua@hisilicon.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kieran Bingham <kbingham@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-05-07 00:26:33 -07:00
Barry Song dc9586823f scripts/gdb: document lx_current is only supported by x86
Patch series "scripts/gdb: clarify the platforms supporting lx_current and add arm64 support", v2.

lx_current depends on per_cpu current_task variable which exists on x86
only.  so it actually works on x86 only.  the 1st patch documents this
clearly; the 2nd patch adds support for arm64.

This patch (of 2):

x86 is the only architecture which has per_cpu current_task:

  arch$ git grep current_task | grep -i per_cpu
  x86/include/asm/current.h:DECLARE_PER_CPU(struct task_struct *, current_task);
  x86/kernel/cpu/common.c:DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
  x86/kernel/cpu/common.c:EXPORT_PER_CPU_SYMBOL(current_task);
  x86/kernel/cpu/common.c:DEFINE_PER_CPU(struct task_struct *, current_task) = &init_task;
  x86/kernel/cpu/common.c:EXPORT_PER_CPU_SYMBOL(current_task);
  x86/kernel/smpboot.c:	per_cpu(current_task, cpu) = idle;

On other architectures, lx_current() will lead to a python exception:

  (gdb) p $lx_current().pid
  Python Exception <class 'gdb.error'> No symbol "current_task" in current context.:
  Error occurred in Python: No symbol "current_task" in current context.

To avoid more people struggling and wasting time in other architectures,
document it.

Link: https://lkml.kernel.org/r/20210314203444.15188-1-song.bao.hua@hisilicon.com
Link: https://lkml.kernel.org/r/20210314203444.15188-2-song.bao.hua@hisilicon.com
Signed-off-by: Barry Song <song.bao.hua@hisilicon.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-05-07 00:26:33 -07:00
Johannes Berg 23921540d2 gdb: lx-symbols: store the abspath()
If we store the relative path, the user might later cd to a different
directory, and that would break the automatic symbol resolving that
happens when a module is loaded into the target kernel.  Fix this by
storing the abspath() of each path given, just like we already do for the
cwd (os.getcwd() is absolute.)

Link: https://lkml.kernel.org/r/20201217091747.bf4332cf2b35.I10ebbdb7e9b80ab1a5cddebf53d073be8232d656@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-05-07 00:26:32 -07:00
George Prekas db7fbf492d scripts/gdb: fix list_for_each
If the list is uninitialized (next pointer is NULL), list_for_each gets
stuck in an infinite loop. Print a message and treat list as empty.

Link: https://lkml.kernel.org/r/4ae23bb1-c333-f669-da2d-fa35c4f49018@amazon.com
Signed-off-by: George Prekas <prekageo@amazon.com>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-02-26 09:41:05 -08:00
Masahiro Yamada 2047ace966 kbuild: use always-y instead of extra-y
As commit d0e628cd81 ("kbuild: doc: clarify the difference between
extra-y and always-y") explained, extra-y should be used for listing
the prerequisites of vmlinux.

These targets are not related to vmlinux. always-y is a better fix.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
2021-02-16 12:01:45 +09:00
Ritesh Harjani 4fbe310e44 scripts/gdb/tasks: add headers and improve spacing format
With the patch.
<e.g. o/p>
      TASK          PID    COMM
0xffffffff82c2b8c0   0   swapper/0
0xffff888a0ba20040   1   systemd
0xffff888a0ba24040   2   kthreadd
0xffff888a0ba28040   3   rcu_gp

w/o
0xffffffff82c2b8c0 <init_task> 0 swapper/0
0xffff888a0ba20040 1 systemd
0xffff888a0ba24040 2 kthreadd
0xffff888a0ba28040 3 rcu_gp

Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Link: http://lkml.kernel.org/r/54c868c79b5fc364a8be7799891934a6fe6d1464.1597742951.git.riteshh@linux.ibm.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-10-16 11:11:22 -07:00
Ritesh Harjani 998ec76b92 scripts/gdb/proc: add struct mount & struct super_block addr in lx-mounts command
This is many times found useful while debugging some FS related
issue.

<e.g. output>
      mount          super_block     devname pathname fstype options
0xffff888a0bfa4b40 0xffff888a0bfc1000 none / rootfs rw 0 0
0xffff888a033f75c0 0xffff8889fcf65000 /dev/root / ext4 rw,relatime 0 0
0xffff8889fc8ce040 0xffff888a0bb51000 devtmpfs /dev devtmpfs rw,relatime 0 0

Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Link: http://lkml.kernel.org/r/a3c4177e1597b3e06d66d55e07d72c0c46a03571.1597742951.git.riteshh@linux.ibm.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-10-16 11:11:22 -07:00
Linus Torvalds d594d8f411 printk changes for 5.10
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEESH4wyp42V4tXvYsjUqAMR0iAlPIFAl+EN+oACgkQUqAMR0iA
 lPK/gA//WXBjC4FSPNr0j7kPFKQhADS3cUcp+GfuI4rYkYcJHV0yJn1kvctg1rUC
 Je+Hc+Hy5Nk93lwejj5BvQoc31zOeoPDyMje5zi5te4H2NQkaoGXHOMvUnaLcNeo
 g+HJvx+NU9MDjuc5amtK8YD69jzErD+eqrHpQOg4UToMXXcBXLafTThIi9vT1fzP
 9uwWBRlpdQyY7tYbbwFiDuu33PyoWlc6Ksp8qKdLBLz2AmGd1Rvaq+ePsq8b9tHJ
 pfv1agW0GTpzoN2pm5gFXOoYniHB/ooB1L0QLq7ylaociEyb8WbTtkn4v++EjxW8
 aGsO1WdO0MQeIWDxXQR5DYD3s+Me2DMhFPDqUc2/s0q2SGWUPFcsmCsvMAOx/clA
 HDfTWkyzB4FarZOTv0gZ7jYNOVukFzUQ1IBTtWpJifC9fT0xrRkKmKE1UgmWv0ei
 Hx5VFQyQGsDh3sUcRLhW91p4sqJCs7l01zw1A/0rb7a+QTHAqZRtbz5hyTjlViiT
 57XiyXynXW8N4Q5U6uAxCbkFFi+nP/XVQ5ggZ/QLn/4hfWWUcu0vt2bOGkRwryAT
 zYmDqViraEVWKIom74UzZ0nrIBtdhvtbFQIYuyiCQKpKMwytWXUQbUASZL2mfBZi
 h5eJx7etV6f5to5mNRsj8bbN5buX9UheEd0QFD9NJdS6aadqTac=
 =9vEl
 -----END PGP SIGNATURE-----

Merge tag 'printk-for-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux

Pull printk updates from Petr Mladek:
 "The big new thing is the fully lockless ringbuffer implementation,
  including the support for continuous lines. It will allow to store and
  read messages in any situation wihtout the risk of deadlocks and
  without the need of temporary per-CPU buffers.

  The access is still serialized by logbuf_lock. It synchronizes few
  more operations, for example, temporary buffer for formatting the
  message, syslog and kmsg_dump operations. The lock removal is being
  discussed and should be ready for the next release.

  The continuous lines are handled exactly the same way as before to
  avoid regressions in user space. It means that they are appended to
  the last message when the caller is the same. Only the last message
  can be extended.

  The data ring includes plain text of the messages. Except for an
  integer at the beginning of each message that points back to the
  descriptor ring with other metadata.

  The dictionary has to stay. journalctl uses it to filter the log. It
  allows to show messages related to a given device. The dictionary
  values are stored in the descriptor ring with the other metadata.

  This is the first part of the printk rework as discussed at Plumbers
  2019, see https://lore.kernel.org/r/87k1acz5rx.fsf@linutronix.de. The
  next big step will be handling consoles by kthreads during the normal
  system operation. It will require special handling of situations when
  the kthreads could not get scheduled, for example, early boot,
  suspend, panic.

  Other changes:

   - Add John Ogness as a reviewer for printk subsystem. He is author of
     the rework and is familiar with the code and history.

   - Fix locking in serial8250_do_startup() to prevent lockdep report.

   - Few code cleanups"

* tag 'printk-for-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux: (27 commits)
  printk: Use fallthrough pseudo-keyword
  printk: reduce setup_text_buf size to LOG_LINE_MAX
  printk: avoid and/or handle record truncation
  printk: remove dict ring
  printk: move dictionary keys to dev_printk_info
  printk: move printk_info into separate array
  printk: reimplement log_cont using record extension
  printk: ringbuffer: add finalization/extension support
  printk: ringbuffer: change representation of states
  printk: ringbuffer: clear initial reserved fields
  printk: ringbuffer: add BLK_DATALESS() macro
  printk: ringbuffer: relocate get_data()
  printk: ringbuffer: avoid memcpy() on state_var
  printk: ringbuffer: fix setting state in desc_read()
  kernel.h: Move oops_in_progress to printk.h
  scripts/gdb: update for lockless printk ringbuffer
  scripts/gdb: add utils.read_ulong()
  docs: vmcoreinfo: add lockless printk ringbuffer vmcoreinfo
  printk: reduce LOG_BUF_SHIFT range for H8300
  printk: ringbuffer: support dataless records
  ...
2020-10-13 15:58:10 -07:00
Petr Mladek 70333f4ff9 Merge branch 'printk-rework' into for-linus 2020-10-12 13:01:37 +02:00
John Ogness 74caba7f2a printk: move dictionary keys to dev_printk_info
Dictionaries are only used for SUBSYSTEM and DEVICE properties. The
current implementation stores the property names each time they are
used. This requires more space than otherwise necessary. Also,
because the dictionary entries are currently considered optional,
it cannot be relied upon that they are always available, even if the
writer wanted to store them. These issues will increase should new
dictionary properties be introduced.

Rather than storing the subsystem and device properties in the
dict ring, introduce a struct dev_printk_info with separate fields
to store only the property values. Embed this struct within the
struct printk_info to provide guaranteed availability.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/87mu1jl6ne.fsf@jogness.linutronix.de
2020-09-22 11:27:48 +02:00
John Ogness 4cfc7258f8 printk: ringbuffer: add finalization/extension support
Add support for extending the newest data block. For this, introduce
a new finalization state (desc_finalized) denoting a committed
descriptor that cannot be extended.

Until a record is finalized, a writer can reopen that record to
append new data. Reopening a record means transitioning from the
desc_committed state back to the desc_reserved state.

A writer can explicitly finalize a record if there is no intention
of extending it. Also, records are automatically finalized when a
new record is reserved. This relieves writers of needing to
explicitly finalize while also making such records available to
readers sooner. (Readers can only traverse finalized records.)

Four new memory barrier pairs are introduced. Two of them are
insignificant additions (data_realloc:A/desc_read:D and
data_realloc:A/data_push_tail:B) because they are alternate path
memory barriers that exactly match the purpose, pairing, and
context of the two existing memory barrier pairs they provide an
alternate path for. The other two new memory barrier pairs are
significant additions:

desc_reopen_last:A / _prb_commit:B - When reopening a descriptor,
    ensure the state transitions back to desc_reserved before
    fully trusting the descriptor data.

_prb_commit:B / desc_reserve:D - When committing a descriptor,
    ensure the state transitions to desc_committed before checking
    the head ID to see if the descriptor needs to be finalized.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20200914123354.832-6-john.ogness@linutronix.de
2020-09-15 16:35:27 +02:00
John Ogness 10dcb06d40 printk: ringbuffer: change representation of states
Rather than deriving the state by evaluating bits within the flags
area of the state variable, assign the states explicit values and
set those values in the flags area. Introduce macros to make it
simple to read and write state values for the state variable.

Although the functionality is preserved, the binary representation
for the states is changed.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20200914123354.832-5-john.ogness@linutronix.de
2020-09-15 15:52:49 +02:00
John Ogness e60768311a scripts/gdb: update for lockless printk ringbuffer
With the introduction of the lockless printk ringbuffer, the data
structure for the kernel log buffer was changed. Update the gdb
scripts to be able to parse/print the new log buffer structure.

Fixes: 896fbe20b4 ("printk: use the lockless ringbuffer")
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Petr Mladek <pmladek@suse.com>
[akpm@linux-foundation.org: A typo fix.]
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20200814212525.6118-3-john.ogness@linutronix.de
2020-09-08 09:33:15 +02:00
John Ogness 3e0d075cb0 scripts/gdb: add utils.read_ulong()
Add a function for reading unsigned long values, which vary in size
depending on the architecture.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20200814212525.6118-2-john.ogness@linutronix.de
2020-09-08 09:33:15 +02:00
Nick Desaulniers a3ec9f38a9 scripts/gdb: fix python 3.8 SyntaxWarning
Fixes the observed warnings:
scripts/gdb/linux/rbtree.py:20: SyntaxWarning: "is" with a literal. Did
you mean "=="?
  if node is 0:
scripts/gdb/linux/rbtree.py:36: SyntaxWarning: "is" with a literal. Did
you mean "=="?
  if node is 0:

It looks like this is a new warning added in Python 3.8. I've only seen
this once after adding the add-auto-load-safe-path rule to my ~/.gdbinit
for a new tree.

Fixes: commit 449ca0c95e ("scripts/gdb: add rb tree iterating utilities")
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Aymeric Agon-Rambosson <aymeric.agon@yandex.com>
Link: http://lkml.kernel.org/r/20200805225015.2847624-1-ndesaulniers@google.com
Link: https://adamj.eu/tech/2020/01/21/why-does-python-3-8-syntaxwarning-for-is-literal/
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-08-12 10:58:02 -07:00
Rafael J. Wysocki 86ba54fb08 Merge branches 'pm-sleep', 'pm-domains', 'powercap' and 'pm-tools'
* pm-sleep:
  PM: sleep: spread "const char *" correctness
  PM: hibernate: fix white space in a few places
  freezer: Add unsafe version of freezable_schedule_timeout_interruptible() for NFS
  PM: sleep: core: Emit changed uevent on wakeup_sysfs_add/remove

* pm-domains:
  PM: domains: Restore comment indentation for generic_pm_domain.child_links
  PM: domains: Fix up terminology with parent/child

* powercap:
  powercap: Add Power Limit4 support
  powercap: idle_inject: Replace play_idle() with play_idle_precise() in comments
  powercap: intel_rapl: add support for Sapphire Rapids

* pm-tools:
  pm-graph v5.7 - important s2idle fixes
  cpupower: Replace HTTP links with HTTPS ones
  cpupower: Fix NULL but dereferenced coccicheck errors
  cpupower: Fix comparing pointer to 0 coccicheck warns
2020-08-03 13:12:44 +02:00
Stefano Garzarella 7359608a27 scripts/gdb: fix lx-symbols 'gdb.error' while loading modules
Commit ed66f991bb ("module: Refactor section attr into bin attribute")
removed the 'name' field from 'struct module_sect_attr' triggering the
following error when invoking lx-symbols:

  (gdb) lx-symbols
  loading vmlinux
  scanning for modules in linux/build
  loading @0xffffffffc014f000: linux/build/drivers/net/tun.ko
  Python Exception <class 'gdb.error'> There is no member named name.:
  Error occurred in Python: There is no member named name.

This patch fixes the issue taking the module name from the 'struct
attribute'.

Fixes: ed66f991bb ("module: Refactor section attr into bin attribute")
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Kieran Bingham <kbingham@kernel.org>
Link: http://lkml.kernel.org/r/20200722102239.313231-1-sgarzare@redhat.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-07-24 12:42:42 -07:00
Kees Cook 8d87ae48ce PM: domains: Fix up terminology with parent/child
The genpd infrastructure uses the terms master/slave, but such uses have
no external exposures (not even in Documentation/driver-api/pm/*) and are
not mandated by nor associated with any external specifications. Change
the language used through-out to parent/child.

There was one possible exception in the debugfs node
"pm_genpd/pm_genpd_summary" but its path has no hits outside of the
kernel itself when performing a code search[1], and it seems even this
single usage has been non-functional since it was introduced due to a
typo in the Python ("apend" instead of correct "append"). Fix the typo
while we're at it.

Link: https://codesearch.debian.net/ # [1]
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-07-09 14:24:00 +02:00
Aymeric Agon-Rambosson 50e36be1fb scripts/gdb: repair rb_first() and rb_last()
The current implementations of the rb_first() and rb_last() gdb
functions have a variable that references itself in its instanciation,
which causes the function to throw an error if a specific condition on
the argument is met.  The original author rather intended to reference
the argument and made a typo.  Referring the argument instead makes the
function work as intended.

Signed-off-by: Aymeric Agon-Rambosson <aymeric.agon@yandex.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Nikolay Borisov <n.borisov.lkml@gmail.com>
Cc: Jackie Liu <liuyun01@kylinos.cn>
Cc: Jason Wessel <jason.wessel@windriver.com>
Link: http://lkml.kernel.org/r/20200427051029.354840-1-aymeric.agon@yandex.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-07 19:27:20 -07:00
Masahiro Yamada d198b34f38 .gitignore: add SPDX License Identifier
Add SPDX License Identifier to all .gitignore files.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-25 11:50:48 +01:00
Ilya Leoshkevich 8731acc506 scripts/gdb: fix debugging modules compiled with hot/cold partitioning
gcc's -freorder-blocks-and-partition option makes it group frequently
and infrequently used code in .text.hot and .text.unlikely sections
respectively.  At least when building modules on s390, this option is
used by default.

gdb assumes that all code is located in .text section, and that .text
section is located at module load address.  With such modules this is no
longer the case: there is code in .text.hot and .text.unlikely, and
either of them might precede .text.

Fix by explicitly telling gdb the addresses of code sections.

It might be tempting to do this for all sections, not only the ones in
the white list.  Unfortunately, gdb appears to have an issue, when
telling it about e.g. loadable .note.gnu.build-id section causes it to
think that non-loadable .note.Linux section is loaded at address 0,
which in turn causes NULL pointers to be resolved to bogus symbols.  So
keep using the white list approach for the time being.

Link: http://lkml.kernel.org/r/20191028152734.13065-1-iii@linux.ibm.com
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-11-06 08:47:50 -08:00
Ilya Leoshkevich 585d730d41 scripts/gdb: fix debugging modules on s390
Currently lx-symbols assumes that module text is always located at
module->core_layout->base, but s390 uses the following layout:

  +------+  <- module->core_layout->base
  | GOT  |
  +------+  <- module->core_layout->base + module->arch->plt_offset
  | PLT  |
  +------+  <- module->core_layout->base + module->arch->plt_offset +
  | TEXT |     module->arch->plt_size
  +------+

Therefore, when trying to debug modules on s390, all the symbol
addresses are skewed by plt_offset + plt_size.

Fix by adding plt_offset + plt_size to module_addr in
load_module_symbols().

Link: http://lkml.kernel.org/r/20191017085917.81791-1-iii@linux.ibm.com
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-10-19 06:32:33 -04:00
Joel Colledge ca210ba32e scripts/gdb: fix lx-dmesg when CONFIG_PRINTK_CALLER is set
When CONFIG_PRINTK_CALLER is set, struct printk_log contains an
additional member caller_id.  This affects the offset of the log text.
Account for this by using the type information from gdb to determine all
the offsets instead of using hardcoded values.

This fixes following error:

  (gdb) lx-dmesg
  Python Exception <class 'ValueError'> embedded null character:
  Error occurred in Python command: embedded null character

The read_u* utility functions now take an offset argument to make them
easier to use.

Link: http://lkml.kernel.org/r/20191011142500.2339-1-joel.colledge@linbit.com
Signed-off-by: Joel Colledge <joel.colledge@linbit.com>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Leonard Crestez <leonard.crestez@nxp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-10-19 06:32:31 -04:00
Douglas Anderson da036ae147 scripts/gdb: handle split debug
Some systems (like Chrome OS) may use "split debug" for kernel modules.
That means that the debug symbols are in a different file than the main
elf file.  Let's handle that by also searching for debug symbols that end
in ".ko.debug".

This is a packaging topic.  You can take a normal elf file and split the
debug out of it using objcopy.  Try "man objcopy" and then take a look at
the "--only-keep-debug" option.  It'll give you a whole recipe for doing
splitdebug.  The suffix used for the debug symbols is arbitrary.  If
people have other another suffix besides ".ko.debug" then we could
presumably support that too...

For portage (which is the packaging system used by Chrome OS) split debug
is supported by default (and the suffix is .ko.debug).  ...and so in
Chrome OS we always get the installed elf files stripped and then the
symbols stashed away.

At the moment we don't actually use the normal portage magic to do this
for the kernel though since it affects our ability to get good stack dumps
in the kernel.  We instead pass a script as "strip" [1].

[1] https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/refs/heads/master/eclass/cros-kernel/strip_splitdebug

Link: http://lkml.kernel.org/r/20190730234052.148744-1-dianders@chromium.org
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-09-25 17:51:40 -07:00
Leonard Crestez 778c1f5ccb scripts/gdb: add helpers to find and list devices
Add helper commands and functions for finding pointers to struct device
by enumerating linux device bus/class infrastructure.  This can be used
to fetch subsystem and driver-specific structs:

  (gdb) p *$container_of($lx_device_find_by_class_name("net", "eth0"), "struct net_device", "dev")
  (gdb) p *$container_of($lx_device_find_by_bus_name("i2c", "0-004b"), "struct i2c_client", "dev")
  (gdb) p *(struct imx_port*)$lx_device_find_by_class_name("tty", "ttymxc1")->parent->driver_data

Several generic "lx-device-list" functions are included to enumerate
devices by bus and class:

  (gdb) lx-device-list-bus usb
  (gdb) lx-device-list-class
  (gdb) lx-device-list-tree &platform_bus

Similar information is available in /sys but pointer values are
deliberately hidden.

Link: http://lkml.kernel.org/r/c948628041311cbf1b9b4cff3dda7d2073cb3eaa.1561492937.git.leonard.crestez@nxp.com
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-07-16 19:23:24 -07:00
Leonard Crestez 8207d4a88e scripts/gdb: add lx-genpd-summary command
This is like /sys/kernel/debug/pm/pm_genpd_summary except it's
accessible through a debugger.

This can be useful if the target crashes or hangs because power domains
were not properly enabled.

Link: http://lkml.kernel.org/r/f9ee627a0d4f94b894aa202fee8a98444049bed8.1561492937.git.leonard.crestez@nxp.com
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-07-16 19:23:24 -07:00
Masahiro Yamada 051f278e9d kbuild: replace KBUILD_SRCTREE with boolean building_out_of_srctree
Commit 25b146c5b8 ("kbuild: allow Kbuild to start from any directory")
deprecated KBUILD_SRCTREE.

It is only used in tools/testing/selftest/ to distinguish out-of-tree
build. Replace it with a new boolean flag, building_out_of_srctree.

I also replaced the conditional ($(srctree),.) because the next commit
will allow an absolute path to be used for $(srctree) even when building
in the source tree.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2019-07-11 00:05:09 +09:00
Fabiano Rosas ef7a77c6de scripts/gdb: fix invocation when CONFIG_COMMON_CLK is not set
CLK_GET_RATE_NOCACHE depends on CONFIG_COMMON_CLK.  Importing constants.py
when CONFIG_COMMON_CLK is not defined causes:

  (gdb) lx-symbols
  (...)
    File "scripts/gdb/linux/proc.py", line 15, in <module>
      from linux import constants
    File "scripts/gdb/linux/constants.py", line 2, in <module>
      LX_CLK_GET_RATE_NOCACHE = gdb.parse_and_eval("CLK_GET_RATE_NOCACHE")
  gdb.error: No symbol "CLK_GET_RATE_NOCACHE" in current context.

Link: http://lkml.kernel.org/r/20190523195313.24701-1-farosas@linux.ibm.com
Fixes: e7e6f462c1 ("scripts/gdb: print cached rate in lx-clk-summary")
Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Leonard Crestez <leonard.crestez@nxp.com>
Cc: Jackie Liu <liuyun01@kylinos.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-06-01 15:51:31 -07:00
Thomas Gleixner ec8f24b7fa treewide: Add SPDX license identifier - Makefile/Kconfig
Add SPDX license identifiers to all Make/Kconfig files which:

 - Have no license information of any form

These files fall under the project license, GPL v2 only. The resulting SPDX
license identifier is:

  GPL-2.0-only

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-21 10:50:46 +02:00
Leonard Crestez e7e6f462c1 scripts/gdb: print cached rate in lx-clk-summary
The clk rate is always stored in clk_core but might be out of date and
require calls to update from hardware.

Deal with that case by printing a (c) suffix.

Link: http://lkml.kernel.org/r/1a474318982a5f0125f2360c4161029b17f56bd1.1556881728.git.leonard.crestez@nxp.com
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-14 19:52:52 -07:00
Leonard Crestez 66d5c7c60a scripts/gdb: clean up error handling in list helpers
An incorrect argument to list_for_each is an internal error in gdb
scripts so a TypeError should be raised.  The gdb.GdbError exception
type is intended for user errors such as incorrect invocation.

Drop the type assertion in list_for_each_entry because list_for_each
isn't going to suddenly yield something else.

Applies to both list and hlist

Link: http://lkml.kernel.org/r/c1d3fd4db13d999a3ba57f5bbc1924862d824f61.1556881728.git.leonard.crestez@nxp.com
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-14 19:52:52 -07:00
Leonard Crestez 988b268615 scripts/gdb: add $lx_clk_core_lookup function
Finding an individual clk_core requires walking the tree which can be
quite complicated so add a helper for easy access.

(gdb) print *(struct clk_scu*)$lx_clk_core_lookup("uart0_clk")->hw

Link: http://lkml.kernel.org/r/Message-ID:
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-14 19:52:52 -07:00
Leonard Crestez d1e9710b63 scripts/gdb: initial clk support: lx-clk-summary
Add an lx-clk-summary command which prints a subset of
/sys/kernel/debug/clk/clk_summary.

This can be used to examine hangs caused by clk not being enabled.

Link: http://lkml.kernel.org/r/Message-ID:
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-14 19:52:52 -07:00
Leonard Crestez 47d0d12855 scripts/gdb: add hlist utilities
This allows easily examining kernel hlists in python.

Link: http://lkml.kernel.org/r/Message-ID:
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-14 19:52:52 -07:00
Stephen Boyd 494dbe02b6 scripts/gdb: silence pep8 checks
These scripts have some pep8 style warnings.  Fix them up so that this
directory is all pep8 clean.

Link: http://lkml.kernel.org/r/20190329220844.38234-6-swboyd@chromium.org
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Nikolay Borisov <n.borisov.lkml@gmail.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Jackie Liu <liuyun01@kylinos.cn>
Cc: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-14 19:52:52 -07:00
Stephen Boyd 442284a89a scripts/gdb: add a timer list command
Implement a command to print the timer list, much like how
/proc/timer_list is implemented.  This can be used to look at the
pending timers on a crashed system.

[swboyd@chromium.org: v2]
  Link: http://lkml.kernel.org/r/20190329220844.38234-5-swboyd@chromium.org
Link: http://lkml.kernel.org/r/20190325184522.260535-5-swboyd@chromium.org
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Nikolay Borisov <n.borisov.lkml@gmail.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Jackie Liu <liuyun01@kylinos.cn>
Cc: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-14 19:52:52 -07:00
Stephen Boyd 449ca0c95e scripts/gdb: add rb tree iterating utilities
Implement gdb functions for rb_first(), rb_last(), rb_next(), and
rb_prev().  These can be useful to iterate through the kernel's
red-black trees.

[swboyd@chromium.org: v2]
  Link: http://lkml.kernel.org/r/20190329220844.38234-4-swboyd@chromium.org
Link: http://lkml.kernel.org/r/20190325184522.260535-4-swboyd@chromium.org
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Nikolay Borisov <n.borisov.lkml@gmail.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Jackie Liu <liuyun01@kylinos.cn>
Cc: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-14 19:52:51 -07:00