Hi folks, This series implements CONFIG_MODVERSIONS for Rust, an important feature for distributions like Android that want to ship Rust kernel modules, and depend on modversions to help ensure module ABI compatibility. There have been earlier proposals [1][2] that would allow Rust modules to coexist with modversions, but none that actually implement symbol versioning. Unlike C, Rust source code doesn't have sufficient information about the final ABI, as the compiler has considerable freedom in adjusting structure layout for improved performance [3], for example, which makes using a source code parser like genksyms a non-starter. Based on Matt's suggestion and previous feedback from maintainers, this series uses DWARF debugging information for computing versions. DWARF is an established and relatively stable format, which includes all the necessary ABI details, and adding a CONFIG_DEBUG_INFO dependency for Rust symbol versioning seems like a reasonable trade-off. The first 12 patches of this series add a small tool for computing symbol versions from DWARF, called gendwarfksyms. When passed a list of exported symbols, the tool generates an expanded type string for each symbol, and computes symbol CRCs similarly to genksyms. gendwarfksyms is written in C and uses libdw to process DWARF, mainly because of the existing support for C host tools that use elfutils (e.g., objtool). Another compatibility issue is fitting the extremely long mangled Rust symbol names into struct modversion_info, which can only hold 55-character names (on 64-bit systems). Previous proposals suggested changing the structure to support longer names, but the conclusion was that we cannot break userspace tools that parse the version table. The next two patches of the series implement support for hashed symbol names in struct modversion_info, where names longer than 55 characters are hashed, and the hash is stored in the name field. To avoid breaking userspace tools, the binary hash is prefixed with a null-terminated string containing the name of the hash function. While userspace tools can later be updated to potentially produce more useful information about the long symbols, this allows them to continue working in the meantime. The final patch allows CONFIG_MODVERSIONS to be selected with Rust, provided that debugging information is also available. [1] https://lore.kernel.org/lkml/20230111161155.1349375-1-gary@xxxxxxxxxxx/ [2] https://lore.kernel.org/rust-for-linux/20231118025748.2778044-1-mmaurer@xxxxxxxxxx/ [3] https://lore.kernel.org/rust-for-linux/CAGSQo005hRiUZdeppCifDqG9zFDJRwahpBLE4x7-MyfJscn7tQ@xxxxxxxxxxxxxx/ Sami Sami Tolvanen (15): tools: Add gendwarfksyms gendwarfksyms: Add symbol list input handling gendwarfksyms: Add CRC calculation gendwarfksyms: Expand base_type gendwarfksyms: Add a cache gendwarfksyms: Expand type modifiers and typedefs gendwarfksyms: Add pretty-printing gendwarfksyms: Expand subroutine_type gendwarfksyms: Expand array_type gendwarfksyms: Expand structure types gendwarfksyms: Limit structure expansion gendwarfksyms: Add inline debugging modpost: Add support for hashing long symbol names module: Support hashed symbol names when checking modversions kbuild: Use gendwarfksyms to generate Rust symbol versions Makefile | 6 + init/Kconfig | 2 +- kernel/module/version.c | 38 +- rust/Makefile | 30 +- scripts/mod/Makefile | 4 +- scripts/mod/modpost.c | 20 +- scripts/mod/modpost.h | 20 + scripts/mod/symhash.c | 327 +++++++++++++ tools/Makefile | 11 +- tools/gendwarfksyms/Build | 5 + tools/gendwarfksyms/Makefile | 49 ++ tools/gendwarfksyms/cache.c | 209 +++++++++ tools/gendwarfksyms/crc32.c | 69 +++ tools/gendwarfksyms/crc32.h | 34 ++ tools/gendwarfksyms/gendwarfksyms.c | 141 ++++++ tools/gendwarfksyms/gendwarfksyms.h | 173 +++++++ tools/gendwarfksyms/symbols.c | 193 ++++++++ tools/gendwarfksyms/types.c | 697 ++++++++++++++++++++++++++++ 18 files changed, 2008 insertions(+), 20 deletions(-) create mode 100644 scripts/mod/symhash.c create mode 100644 tools/gendwarfksyms/Build create mode 100644 tools/gendwarfksyms/Makefile create mode 100644 tools/gendwarfksyms/cache.c create mode 100644 tools/gendwarfksyms/crc32.c create mode 100644 tools/gendwarfksyms/crc32.h create mode 100644 tools/gendwarfksyms/gendwarfksyms.c create mode 100644 tools/gendwarfksyms/gendwarfksyms.h create mode 100644 tools/gendwarfksyms/symbols.c create mode 100644 tools/gendwarfksyms/types.c base-commit: 6ba59ff4227927d3a8530fc2973b80e94b54d58f -- 2.45.2.627.g7a2c4fd464-goog