[RFC PATCH 00/15] Support module memory layout change on Linux 6.4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patchset supports module memory layout change on Linux 6.4 by
kernel commit [1].  Without the patchset, crash cannot even start a
session with an error message like this:

  crash: invalid structure member offset: module_core_size
         FILE: kernel.c  LINE: 3787  FUNCTION: module_init()

(For the current crash, you can use "crash --no_modules" option without
module functionalities to avoid the failure of startup.)

This patchset is also located at GitHub [2].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ac3b43283923
[2] https://github.com/k-hagio/crash/tree/6.4-module.wip2

Probably most of module and symbol functions will work, though maybe 
there might be lack of fixes for some functions and there might be my 
misunderstanding of crash code.  (There are also some functions not 
fixed because crash does not use them for the recent kernels.)

Please let me know if there are any bugs and comments on the design, 
coding style and etc.

* The current patchset is a draft and kind of POC, fixes are piled up 
and no code and performance optimization.  I will rearrange them later. 

* Currently enum mod_mem_type is backported from the kernel as it is, 
because I'm not sure whether it's likely to change soon.

* The new module memory areas are scattered, and managed by the 
following struct load_module members.

struct load_module {
...
         /* For 6.4 module_memory */
         struct module_memory mem[MOD_MEM_NUM_TYPES];
         struct syment **symtable;
         struct syment **symend;
         struct syment *ext_symtable[MOD_MEM_NUM_TYPES];
         struct syment *ext_symend[MOD_MEM_NUM_TYPES];
         struct syment *load_symtable[MOD_MEM_NUM_TYPES];
         struct syment *load_symend[MOD_MEM_NUM_TYPES];
         int address_order[MOD_MEM_NUM_TYPES];
         int nr_mems;
};

* "sym -M" output is ordered by module text start address on a 
per-module basis for now. (how can I say...)  So if you get all of 
module symbols in address order, need to sort them.  But modules will be 
mixed.

crash> sym -M | grep MODULE          # displayed per module
...
ffffffffc046f000 MODULE TEXT START: dm_mirror
ffffffffc0472000 MODULE TEXT END: dm_mirror
ffffffffc0473000 MODULE DATA START: dm_mirror
ffffffffc0475000 MODULE DATA END: dm_mirror
ffffffffc0476000 MODULE RODATA START: dm_mirror
ffffffffc0478000 MODULE RODATA END: dm_mirror
ffffffffc044b000 MODULE RO_AFTER_INIT START: libata  # lower than the 
previous
ffffffffc044c000 MODULE RO_AFTER_INIT END: libata
ffffffffc0479000 MODULE TEXT START: libata
ffffffffc049d000 MODULE TEXT END: libata
ffffffffc049e000 MODULE DATA START: libata
ffffffffc04c8000 MODULE DATA END: libata
...
crash> sym -M | grep MODULE | sort   # displayed in address order
...
ffffffffc0468000 MODULE RODATA START: dm_region_hash
ffffffffc046a000 MODULE RODATA END: dm_region_hash
ffffffffc046b000 MODULE RODATA START: t10_pi
ffffffffc046c000 MODULE RODATA END: t10_pi
ffffffffc046d000 MODULE TEXT START: ghash_clmulni_intel
ffffffffc046e000 MODULE TEXT END: ghash_clmulni_intel
ffffffffc046f000 MODULE TEXT START: dm_mirror
ffffffffc0472000 MODULE TEXT END: dm_mirror
...

Kazuhito Hagio (15):
  Add support for struct module_memory on Linux 6.4 and later
  Support "sym -l|-M|-m" options
  Make "sym -m" option print symbols in address order
  Fix verify_module() and next_module_vaddr()
  Fix {lowest,highest}_modules_address() and is_kernel_text()
  Support "mod -s|-S" options
  Support percpu symbols for "sym" options
  Support "mod -d|-D" options
  Support "sym -n" option
  Support "sym -p" option
  Fix module_symbol() and is_kernel_text()
  Remove unused find_mod_etext() in store_module_symbols_v3()
  Fix get_section, check_for_dups, symbol_query, symbol_name_count
  Fix symbol_search_next, symbol_complete_match and get_syment_array
  mod: Change "BASE" on header to "TEXT_BASE" to clarify

 defs.h         |   45 ++
 gdb-10.2.patch |   16 +
 kernel.c       |   47 +-
 memory.c       |   36 +-
 symbols.c      | 1571 +++++++++++++++++++++++++++++++++++++++++++++---
 5 files changed, 1616 insertions(+), 99 deletions(-)

-- 
2.31.1

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux