1. 21 Aug, 2023 18 commits
    • Ryusuke Konishi's avatar
      nilfs2: fix WARNING in mark_buffer_dirty due to discarded buffer reuse · cdaac8e7
      Ryusuke Konishi authored
      A syzbot stress test using a corrupted disk image reported that
      mark_buffer_dirty() called from __nilfs_mark_inode_dirty() or
      nilfs_palloc_commit_alloc_entry() may output a kernel warning, and can
      panic if the kernel is booted with panic_on_warn.
      
      This is because nilfs2 keeps buffer pointers in local structures for some
      metadata and reuses them, but such buffers may be forcibly discarded by
      nilfs_clear_dirty_page() in some critical situations.
      
      This issue is reported to appear after commit 28a65b49 ("nilfs2: do
      not write dirty data after degenerating to read-only"), but the issue has
      potentially existed before.
      
      Fix this issue by checking the uptodate flag when attempting to reuse an
      internally held buffer, and reloading the metadata instead of reusing the
      buffer if the flag was lost.
      
      Link: https://lkml.kernel.org/r/20230818131804.7758-1-konishi.ryusuke@gmail.comSigned-off-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Reported-by: syzbot+cdfcae656bac88ba0e2d@syzkaller.appspotmail.com
      Closes: https://lkml.kernel.org/r/0000000000003da75f05fdeffd12@google.com
      Fixes: 8c26c4e2 ("nilfs2: fix issue with flush kernel thread after remount in RO mode because of driver's internal error or metadata corruption")
      Tested-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Cc: <stable@vger.kernel.org> # 3.10+
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      cdaac8e7
    • Geert Uytterhoeven's avatar
      scripts/bloat-o-meter: count weak symbol sizes · 198430f7
      Geert Uytterhoeven authored
      Currently, bloat-o-meter does not take into account weak symbols, and
      thus ignores any size changes in code or data marked __weak.
      
      Fix this by handling weak code ("w"/"W") and data ("v"/"V").
      
      Link: https://lkml.kernel.org/r/a1e7abd2571c3bbfe75345d6ee98b276d2d5c39d.1692200010.git.geert+renesas@glider.beSigned-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      198430f7
    • Randy Dunlap's avatar
      treewide: drop CONFIG_EMBEDDED · ef815d2c
      Randy Dunlap authored
      There is only one Kconfig user of CONFIG_EMBEDDED and it can be switched
      to EXPERT or "if !ARCH_MULTIPLATFORM" (suggested by Arnd).
      
      Link: https://lkml.kernel.org/r/20230816055010.31534-1-rdunlap@infradead.orgSigned-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Acked-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: Palmer Dabbelt <palmer@rivosinc.com>	[RISC-V]
      Acked-by: default avatarGreg Ungerer <gerg@linux-m68k.org>
      Acked-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Acked-by: Michael Ellerman <mpe@ellerman.id.au>	[powerpc]
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Dinh Nguyen <dinguyen@kernel.org>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Rich Felker <dalias@libc.org>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Josh Triplett <josh@joshtriplett.org>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      ef815d2c
    • Helge Deller's avatar
      lockdep: fix static memory detection even more · 0a6b58c5
      Helge Deller authored
      On the parisc architecture, lockdep reports for all static objects which
      are in the __initdata section (e.g. "setup_done" in devtmpfs,
      "kthreadd_done" in init/main.c) this warning:
      
      	INFO: trying to register non-static key.
      
      The warning itself is wrong, because those objects are in the __initdata
      section, but the section itself is on parisc outside of range from
      _stext to _end, which is why the static_obj() functions returns a wrong
      answer.
      
      While fixing this issue, I noticed that the whole existing check can
      be simplified a lot.
      Instead of checking against the _stext and _end symbols (which include
      code areas too) just check for the .data and .bss segments (since we check a
      data object). This can be done with the existing is_kernel_core_data()
      macro.
      
      In addition objects in the __initdata section can be checked with
      init_section_contains(), and is_kernel_rodata() allows keys to be in the
      _ro_after_init section.
      
      This partly reverts and simplifies commit bac59d18 ("x86/setup: Fix static
      memory detection").
      
      Link: https://lkml.kernel.org/r/ZNqrLRaOi/3wPAdp@p100
      Fixes: bac59d18 ("x86/setup: Fix static memory detection")
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      0a6b58c5
    • Andy Shevchenko's avatar
      lib/vsprintf: declare no_hash_pointers in sprintf.h · 66553609
      Andy Shevchenko authored
      Sparse is not happy to see non-static variable without declaration:
      lib/vsprintf.c:61:6: warning: symbol 'no_hash_pointers' was not declared. 
      Should it be static?
      
      Declare respective variable in the sprintf.h.  With this, add a comment to
      discourage its use if no real need.
      
      Link: https://lkml.kernel.org/r/20230814163344.17429-3-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: default avatarMarco Elver <elver@google.com>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      66553609
    • Andy Shevchenko's avatar
      lib/vsprintf: split out sprintf() and friends · 39ced19b
      Andy Shevchenko authored
      Patch series "lib/vsprintf: Rework header inclusions", v3.
      
      Some patches that reduce the mess with the header inclusions related to
      vsprintf.c module.  Each patch has its own description, and has no
      dependencies to each other, except the collisions over modifications of
      the same places.  Hence the series.
      
      
      This patch (of 2):
      
      kernel.h is being used as a dump for all kinds of stuff for a long time. 
      sprintf() and friends are used in many drivers without need of the full
      kernel.h dependency train with it.
      
      Here is the attempt on cleaning it up by splitting out sprintf() and
      friends.
      
      Link: https://lkml.kernel.org/r/20230814163344.17429-1-andriy.shevchenko@linux.intel.com
      Link: https://lkml.kernel.org/r/20230814163344.17429-2-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      39ced19b
    • Mateusz Guzik's avatar
      kernel/fork: stop playing lockless games for exe_file replacement · a7031f14
      Mateusz Guzik authored
      xchg originated in 6e399cd1 ("prctl: avoid using mmap_sem for exe_file
      serialization").  While the commit message does not explain *why* the
      change, I found the original submission [1] which ultimately claims it
      cleans things up by removing dependency of exe_file on the semaphore.
      
      However, fe69d560 ("kernel/fork: always deny write access to current
      MM exe_file") added a semaphore up/down cycle to synchronize the state of
      exe_file against fork, defeating the point of the original change.
      
      This is on top of semaphore trips already present both in the replacing
      function and prctl (the only consumer).
      
      Normally replacing exe_file does not happen for busy processes, thus
      write-locking is not an impediment to performance in the intended use
      case.  If someone keeps invoking the routine for a busy processes they are
      trying to play dirty and that's another reason to avoid any trickery.
      
      As such I think the atomic here only adds complexity for no benefit.
      
      Just write-lock around the replacement.
      
      I also note that replacement races against the mapping check loop as
      nothing synchronizes actual assignment with with said checks but I am not
      addressing it in this patch.  (Is the loop of any use to begin with?)
      
      Link: https://lore.kernel.org/linux-mm/1424979417.10344.14.camel@stgolabs.net/ [1]
      Link: https://lkml.kernel.org/r/20230814172140.1777161-1-mjguzik@gmail.comSigned-off-by: default avatarMateusz Guzik <mjguzik@gmail.com>
      Acked-by: default avatarOleg Nesterov <oleg@redhat.com>
      Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: "Christian Brauner (Microsoft)" <brauner@kernel.org>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Konstantin Khlebnikov <koct9i@gmail.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mateusz Guzik <mjguzik@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      a7031f14
    • Alexey Dobriyan's avatar
      adfs: delete unused "union adfs_dirtail" definition · 8bd49ef2
      Alexey Dobriyan authored
      union adfs_dirtail::new stands in the way if Linux++ project:
      "new" can't be used as member's name because it is a keyword in C++.
      
      Link: https://lkml.kernel.org/r/43b0a4c8-a7cf-4ab1-98f7-0f65c096f9e8@p183Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      8bd49ef2
    • Kuan-Ying Lee's avatar
      scripts/gdb/vmalloc: add vmallocinfo support · 852622bf
      Kuan-Ying Lee authored
      This GDB script shows the vmallocinfo for user to
      analyze the vmalloc memory usage.
      
      Example output:
      0xffff800008000000-0xffff800008009000      36864 <start_kernel+372> pages=8 vmalloc
      0xffff800008009000-0xffff80000800b000       8192 <gicv2m_init_one+400> phys=0x8020000 ioremap
      0xffff80000800b000-0xffff80000800d000       8192 <bpf_prog_alloc_no_stats+72> pages=1 vmalloc
      0xffff80000800d000-0xffff80000800f000       8192 <bpf_jit_alloc_exec+16> pages=1 vmalloc
      0xffff800008010000-0xffff80000ad30000   47316992 <paging_init+452> phys=0x40210000 vmap
      0xffff80000ad30000-0xffff80000c1c0000   21561344 <paging_init+556> phys=0x42f30000 vmap
      0xffff80000c1c0000-0xffff80000c370000    1769472 <paging_init+592> phys=0x443c0000 vmap
      0xffff80000c370000-0xffff80000de90000   28442624 <paging_init+692> phys=0x44570000 vmap
      0xffff80000de90000-0xffff80000f4c1000   23269376 <paging_init+788> phys=0x46090000 vmap
      0xffff80000f4c1000-0xffff80000f4c3000       8192 <gen_pool_add_owner+112> pages=1 vmalloc
      0xffff80000f4c3000-0xffff80000f4c5000       8192 <gen_pool_add_owner+112> pages=1 vmalloc
      0xffff80000f4c5000-0xffff80000f4c7000       8192 <gen_pool_add_owner+112> pages=1 vmalloc
      
      Link: https://lkml.kernel.org/r/20230808083020.22254-9-Kuan-Ying.Lee@mediatek.comSigned-off-by: default avatarKuan-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: default avatarAndrew Morton <akpm@linux-foundation.org>
      852622bf
    • Kuan-Ying Lee's avatar
      scripts/gdb/slab: add slab support · 79939c4a
      Kuan-Ying Lee authored
      Add 'lx-slabinfo' and 'lx-slabtrace' support.
      
      This GDB scripts print slabinfo and slabtrace for user
      to analyze slab memory usage.
      
      Example output like below:
      (gdb) lx-slabinfo
           Pointer       |         name         | active_objs  |   num_objs   | objsize  | objperslab  | pagesperslab
      ------------------ | -------------------- | ------------ | ------------ | -------- | ----------- | -------------
      0xffff0000c59df480 | p9_req_t             | 0            | 0            | 280      | 29          | 2
      0xffff0000c59df280 | isp1760_qh           | 0            | 0            | 160      | 25          | 1
      0xffff0000c59df080 | isp1760_qtd          | 0            | 0            | 184      | 22          | 1
      0xffff0000c59dee80 | isp1760_urb_listite  | 0            | 0            | 136      | 30          | 1
      0xffff0000c59dec80 | asd_sas_event        | 0            | 0            | 256      | 32          | 2
      0xffff0000c59dea80 | sas_task             | 0            | 0            | 448      | 36          | 4
      0xffff0000c59de880 | bio-120              | 18           | 21           | 384      | 21          | 2
      0xffff0000c59de680 | io_kiocb             | 0            | 0            | 448      | 36          | 4
      0xffff0000c59de480 | bfq_io_cq            | 0            | 0            | 1504     | 21          | 8
      0xffff0000c59de280 | bfq_queue            | 0            | 0            | 720      | 22          | 4
      0xffff0000c59de080 | mqueue_inode_cache   | 1            | 28           | 1152     | 28          | 8
      0xffff0000c59dde80 | v9fs_inode_cache     | 0            | 0            | 832      | 39          | 8
      ...
      
      (gdb) lx-slabtrace --cache_name kmalloc-1k
      63 <tty_register_device_attr+508> waste=16632/264 age=46856/46871/46888 pid=1 cpus=6,
         0xffff800008720240 <__kmem_cache_alloc_node+236>:    mov     x22, x0
         0xffff80000862a4fc <kmalloc_trace+64>:       mov     x21, x0
         0xffff8000095d086c <tty_register_device_attr+508>:   mov     x19, x0
         0xffff8000095d0f98 <tty_register_driver+704>:        cmn     x0, #0x1, lsl #12
         0xffff80000c2677e8 <vty_init+620>:   Cannot access memory at address 0xffff80000c2677e8
         0xffff80000c265a10 <tty_init+276>:   Cannot access memory at address 0xffff80000c265a10
         0xffff80000c26d3c4 <chr_dev_init+204>:       Cannot access memory at address 0xffff80000c26d3c4
         0xffff8000080161d4 <do_one_initcall+176>:    mov     w21, w0
         0xffff80000c1c1b58 <kernel_init_freeable+956>:       Cannot access memory at address 0xffff80000c1c1b58
         0xffff80000acf1334 <kernel_init+36>: bl      0xffff8000081ac040 <async_synchronize_full>
         0xffff800008018d00 <ret_from_fork+16>:       mrs     x28, sp_el0
      
      (gdb) lx-slabtrace --cache_name kmalloc-1k --free
      428 <not-available> age=4294958600 pid=0 cpus=0,
      
      Link: https://lkml.kernel.org/r/20230808083020.22254-8-Kuan-Ying.Lee@mediatek.comSigned-off-by: default avatarKuan-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: default avatarAndrew Morton <akpm@linux-foundation.org>
      79939c4a
    • Kuan-Ying Lee's avatar
      scripts/gdb/page_owner: add page owner support · 2f060190
      Kuan-Ying Lee authored
      This GDB script prints page owner information for user to analyze the
      memory usage or memory corruption issue.
      
      Example output from an aarch64 system:
      
      (gdb) lx-dump-page-owner --pfn 655360
      page_owner tracks the page as allocated
      Page last allocated via order 0, gfp_mask: 0x8, pid: 1, tgid: 1 ("swapper/0\000\000\000\000\000\000"), ts 1295948880 ns, free_ts 1011852016 ns
      PFN: 655360, Flags: 0x3fffc0000000000
         0xffff8000086ab964 <post_alloc_hook+452>:    ldp     x19, x20, [sp, #16]
         0xffff80000862e4e0 <split_map_pages+344>:    cbnz    w22, 0xffff80000862e57c <split_map_pages+500>
         0xffff8000086370c4 <isolate_freepages_range+556>:    mov     x0, x27
         0xffff8000086bc1cc <alloc_contig_range+808>: mov     x24, x0
         0xffff80000877d6d8 <cma_alloc+772>:  mov     w1, w0
         0xffff8000082c8d18 <dma_alloc_from_contiguous+104>:  ldr     x19, [sp, #16]
         0xffff8000082ce0e8 <atomic_pool_expand+208>: mov     x19, x0
         0xffff80000c1e41b4 <__dma_atomic_pool_init+172>:     Cannot access memory at address 0xffff80000c1e41b4
         0xffff80000c1e4298 <dma_atomic_pool_init+92>:        Cannot access memory at address 0xffff80000c1e4298
         0xffff8000080161d4 <do_one_initcall+176>:    mov     w21, w0
         0xffff80000c1c1b50 <kernel_init_freeable+952>:       Cannot access memory at address 0xffff80000c1c1b50
         0xffff80000acf87dc <kernel_init+36>: bl      0xffff8000081ab100 <async_synchronize_full>
         0xffff800008018d00 <ret_from_fork+16>:       mrs     x28, sp_el0
      page last free stack trace:
         0xffff8000086a6e8c <free_unref_page_prepare+796>:    mov     w2, w23
         0xffff8000086aee1c <free_unref_page+96>:     tst     w0, #0xff
         0xffff8000086af3f8 <__free_pages+292>:       ldp     x19, x20, [sp, #16]
         0xffff80000c1f3214 <init_cma_reserved_pageblock+220>:        Cannot access memory at address 0xffff80000c1f3214
         0xffff80000c20363c <cma_init_reserved_areas+1284>:   Cannot access memory at address 0xffff80000c20363c
         0xffff8000080161d4 <do_one_initcall+176>:    mov     w21, w0
         0xffff80000c1c1b50 <kernel_init_freeable+952>:       Cannot access memory at address 0xffff80000c1c1b50
         0xffff80000acf87dc <kernel_init+36>: bl      0xffff8000081ab100 <async_synchronize_full>
         0xffff800008018d00 <ret_from_fork+16>:       mrs     x28, sp_el0
      
      Link: https://lkml.kernel.org/r/20230808083020.22254-7-Kuan-Ying.Lee@mediatek.comSigned-off-by: default avatarKuan-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: default avatarAndrew Morton <akpm@linux-foundation.org>
      2f060190
    • Kuan-Ying Lee's avatar
      scripts/gdb/stackdepot: add stackdepot support · 0e1b240a
      Kuan-Ying Lee authored
      Add support for printing the backtrace of stackdepot handle.
      
      This is the preparation patch for dumping page_owner,
      slabtrace usage.
      
      Link: https://lkml.kernel.org/r/20230808083020.22254-6-Kuan-Ying.Lee@mediatek.comSigned-off-by: default avatarKuan-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: default avatarAndrew Morton <akpm@linux-foundation.org>
      0e1b240a
    • Kuan-Ying Lee's avatar
      scripts/gdb/aarch64: add aarch64 page operation helper commands and configs · eb985b5d
      Kuan-Ying Lee authored
      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.comSigned-off-by: default avatarKuan-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: default avatarAndrew Morton <akpm@linux-foundation.org>
      eb985b5d
    • Kuan-Ying Lee's avatar
      scripts/gdb/utils: add common type usage · 4d040cbc
      Kuan-Ying Lee authored
      Since we often use 'unsigned long', 'size_t', 'usigned int'
      and 'struct page', we add these common types to utils.
      
      Link: https://lkml.kernel.org/r/20230808083020.22254-4-Kuan-Ying.Lee@mediatek.comSigned-off-by: default avatarKuan-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: default avatarAndrew Morton <akpm@linux-foundation.org>
      4d040cbc
    • Kuan-Ying Lee's avatar
      scripts/gdb/modules: add get module text support · 82141540
      Kuan-Ying Lee authored
      When we get an text address from coredump and we cannot find
      this address in vmlinux, it might located in kernel module.
      
      We want to know which kernel module it located in.
      
      This GDB scripts can help us to find the target kernel module.
      
      (gdb) lx-getmod-by-textaddr 0xffff800002d305ac
      0xffff800002d305ac is in kasan_test.ko
      
      Link: https://lkml.kernel.org/r/20230808083020.22254-3-Kuan-Ying.Lee@mediatek.comSigned-off-by: default avatarKuan-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: default avatarAndrew Morton <akpm@linux-foundation.org>
      82141540
    • Kuan-Ying Lee's avatar
      scripts/gdb/symbols: add specific ko module load command · 11f95653
      Kuan-Ying Lee authored
      Patch series "Add GDB memory helper commands", v2.
      
      I've created some GDB commands I think useful when I debug some memory
      issues and kernel module issue.
      
      For memory issue, we would like to get slabinfo, slabtrace, page_owner and
      vmallocinfo to debug the memory issues.
      
      For module issue, we would like to query kernel module name when we get a
      module text address and load module symbol by specific path.
      
      Patch 1-2:
       - Add kernel module related command.
      Patch 3-5:
       - Prepares for the memory-related command.
      Patch 6-8:
       - Add memory-related commands.
      
      
      This patch (of 8):
      
      Add lx-symbols <ko_path> command to support add specific
      ko module.
      
      Example output like below:
      (gdb) lx-symbols mm/kasan/kasan_test.ko
      loading @0xffff800002d30000: mm/kasan/kasan_test.ko
      
      Link: https://lkml.kernel.org/r/20230808083020.22254-1-Kuan-Ying.Lee@mediatek.com
      Link: https://lkml.kernel.org/r/20230808083020.22254-2-Kuan-Ying.Lee@mediatek.comSigned-off-by: default avatarKuan-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: default avatarAndrew Morton <akpm@linux-foundation.org>
      11f95653
    • Jim Cromie's avatar
      checkpatch: reword long-line warning about commit-msg · 8e7b7ffb
      Jim Cromie authored
      Reword the warning to complain about line length 1st, since thats
      whats actually tested.
      
      Link: https://lkml.kernel.org/r/20230808033019.21911-3-jim.cromie@gmail.com
      Cc: apw@canonical.com
      Cc: joe@perches.com
      Signed-off-by: default avatarJim Cromie <jim.cromie@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      8e7b7ffb
    • Jim Cromie's avatar
      checkpatch: special case extern struct in .c · 5b2c7334
      Jim Cromie authored
      "externs should be avoided in .c files" needs an exception for linker
      symbols, like those that mark the start, stop of many kernel sections.
      
      Since checkpatch already checks REALNAME to avoid looking at fragments
      changing vmlinux.lds.h, add a new else-if block to look at them
      instead.  As a simple heuristic, treat all words (in the patch-line)
      as possible symbols, to screen later warnings.
      
      For my test case, the possible-symbols included BOUNDED_BY (a macro),
      which is extra, but not troublesome - these are just to screen
      WARNINGS that might be issued on later fragments (changing .c files)
      
      Where the WARN is issued, precede it with an else-if block to catch
      one common extern-in-c use case: "extern struct foo bar[]".  Here we
      can at least issue a softer warning, after checking for a match with a
      maybe-linker-symbol parsed earlier from the patch.
      
      Though heuristic, it worked for my test-case, allowing both start__,
      stop__ $symbol's (wo the prefixes specifically named).  I've coded it
      narrowly, it can be expanded later to cover any other expressions.
      
      It does require that the externs in .c's have the additions to
      vmlinux.lds.h in the same patch.  And requires vmlinux.lds.h before .c
      fragments.
      
      Link: https://lkml.kernel.org/r/20230808033019.21911-2-jim.cromie@gmail.comSigned-off-by: default avatarJim Cromie <jim.cromie@gmail.com>
      Cc: Joe Perches <joe@perches.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      5b2c7334
  2. 18 Aug, 2023 22 commits