[PATCH v3 20/20] Documentation/kbuild: Add DWARF module versioning

2024-09-23 Thread Sami Tolvanen
Add documentation for gendwarfksyms changes, and the kABI stability features that can be useful for distributions even though they're not used in mainline kernels. Signed-off-by: Sami Tolvanen --- Documentation/kbuild/gendwarfksyms.rst | 274 + Documentation/k

[PATCH v3 18/20] export: Add __gendwarfksyms_ptr_ references to exported symbols

2024-09-23 Thread Sami Tolvanen
igned-off-by: Sami Tolvanen --- include/linux/export.h | 15 +++ 1 file changed, 15 insertions(+) diff --git a/include/linux/export.h b/include/linux/export.h index 0bbd02fd351d..cf71d3202e5b 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -52,9 +52,24 @@

[PATCH v3 19/20] kbuild: Add gendwarfksyms as an alternative to genksyms

2024-09-23 Thread Sami Tolvanen
When MODVERSIONS is enabled, allow selecting gendwarfksyms as the implementation, but default to genksyms. Signed-off-by: Sami Tolvanen --- kernel/module/Kconfig | 25 - scripts/Makefile | 2 +- scripts/Makefile.build | 39

[PATCH v3 17/20] gendwarfksyms: Add support for symbol type pointers

2024-09-23 Thread Sami Tolvanen
xternal_symbol); Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/dwarf.c | 55 +- scripts/gendwarfksyms/examples/symbolptr.c | 29 scripts/gendwarfksyms/gendwarfksyms.h | 7 +++ scripts/gendwarfksyms/symbols.c| 27 +++ 4 file

[PATCH v3 16/20] gendwarfksyms: Add support for reserved and ignored fields

2024-09-23 Thread Sami Tolvanen
truct { int b; int v; }; }; Here gendwarfksyms --stable replaces the union with the type of the placeholder field when calculating versions. Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/dwarf.c | 202 +- scripts/gendwarfksyms/exa

[PATCH v3 15/20] gendwarfksyms: Add support for kABI rules

2024-09-23 Thread Sami Tolvanen
tory. Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/Makefile | 1 + scripts/gendwarfksyms/dwarf.c | 19 +- scripts/gendwarfksyms/examples/kabi.h | 61 ++ scripts/gendwarfksyms/examples/kabi_rules.c | 56 + scripts/gendwarfksyms/gendwar

[PATCH v3 14/20] gendwarfksyms: Add symbol versioning

2024-09-23 Thread Sami Tolvanen
Calculate symbol versions from the fully expanded type strings in type_map, and output the versions in a genksyms-compatible format. Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/dwarf.c | 25 +- scripts/gendwarfksyms/gendwarfksyms.c | 11 ++- scripts/gendwarfksyms

[PATCH v3 13/20] gendwarfksyms: Add symtypes output

2024-09-23 Thread Sami Tolvanen
references are wrapped in single quotes. E.g.: s#'core::result::Result' 2. The actual type definition is the simple parsed DWARF format we output with --dump-dies, not the preprocessed C-style format genksyms produces. Signed-off-by: Sami Tolvanen --- scripts/gen

[PATCH v3 12/20] gendwarfksyms: Add die_map debugging

2024-09-23 Thread Sami Tolvanen
Debugging the DWARF processing can be somewhat challenging, so add more detailed debugging output for die_map operations. Add the --dump-die-map flag, which adds color coded tags to the output for die_map changes. Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/dwarf.c | 15

[PATCH v3 11/20] gendwarfksyms: Limit structure expansion

2024-09-23 Thread Sami Tolvanen
type. This should be plenty for detecting ABI differences, but it stops us from pulling in half the kernel for types that contain pointers to large kernel data structures, like task_struct, for example. Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/Makefile| 1 + scripts

[PATCH v3 10/20] gendwarfksyms: Expand structure types

2024-09-23 Thread Sami Tolvanen
type { base_type u8 byte_size(1) encoding(7) } data_ptr data_member_location(0) , member base_type usize byte_size(8) encoding(7) length data_member_location(8) } byte_size(16) alignment(8) msg ) -> base_type void Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/

[PATCH v3 09/20] gendwarfksyms: Expand array_type

2024-09-23 Thread Sami Tolvanen
(8) } Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/dwarf.c | 30 ++ 1 file changed, 30 insertions(+) diff --git a/scripts/gendwarfksyms/dwarf.c b/scripts/gendwarfksyms/dwarf.c index 5bdab5b80ca2..caf25da0a9b9 100644 --- a/scripts/gendwarfksyms/dwarf.c

[PATCH v3 08/20] gendwarfksyms: Expand subroutine_type

2024-09-23 Thread Sami Tolvanen
) } } ) -> base_type unsigned long byte_size(8) encoding(7) Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/dwarf.c | 84 ++- scripts/gendwarfksyms/gendwarfksyms.h | 4 ++ 2 files changed, 85 insertions(+), 3 deletions(-) diff --git a/scripts/gendwarfks

[PATCH v3 07/20] gendwarfksyms: Expand type modifiers and typedefs

2024-09-23 Thread Sami Tolvanen
-off-by: Sami Tolvanen --- scripts/gendwarfksyms/die.c | 12 + scripts/gendwarfksyms/dwarf.c | 67 +++ scripts/gendwarfksyms/gendwarfksyms.h | 5 ++ 3 files changed, 84 insertions(+) diff --git a/scripts/gendwarfksyms/die.c b/scripts/gendwarfksyms

[PATCH v3 06/20] gendwarfksyms: Add a cache for processed DIEs

2024-09-23 Thread Sami Tolvanen
Basic types in DWARF repeat frequently and traversing the DIEs using libdw is relatively slow. Add a simple hashtable based cache for the processed DIEs. Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/Makefile| 1 + scripts/gendwarfksyms/die.c | 143

[PATCH v3 05/20] gendwarfksyms: Expand base_type

2024-09-23 Thread Sami Tolvanen
variable base_type unsigned long byte_size(8) encoding(7) ... Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/dwarf.c | 157 ++ 1 file changed, 157 insertions(+) diff --git a/scripts/gendwarfksyms/dwarf.c b/scripts/gendwarfksyms/dwarf.c index

[PATCH v3 04/20] gendwarfksyms: Add address matching

2024-09-23 Thread Sami Tolvanen
d-off-by: Sami Tolvanen --- scripts/gendwarfksyms/gendwarfksyms.c | 2 + scripts/gendwarfksyms/gendwarfksyms.h | 13 +++ scripts/gendwarfksyms/symbols.c | 153 +- 3 files changed, 165 insertions(+), 3 deletions(-) diff --git a/scripts/gendwarfksyms/gendwarfksyms

[PATCH v3 03/20] tools: Add gendwarfksyms

2024-09-23 Thread Sami Tolvanen
Add a basic DWARF parser, which uses libdw to traverse the debugging information in an object file and looks for functions and variables. In follow-up patches, this will be expanded to produce symbol versions for CONFIG_MODVERSIONS from DWARF. Signed-off-by: Sami Tolvanen --- kernel/module

[PATCH v3 02/20] scripts: move genksyms crc32 implementation to a common include

2024-09-23 Thread Sami Tolvanen
To avoid duplication between host programs, move the crc32 code to a shared header file. Suggested-by: Petr Pavlu Signed-off-by: Sami Tolvanen --- scripts/genksyms/genksyms.c | 77 +- scripts/include/crc32.h | 93 + 2 files

[PATCH v3 01/20] scripts: import more list macros

2024-09-23 Thread Sami Tolvanen
Import list_is_first, list_is_last, list_replace, and list_replace_init. Signed-off-by: Sami Tolvanen --- scripts/include/list.h | 50 ++ 1 file changed, 50 insertions(+) diff --git a/scripts/include/list.h b/scripts/include/list.h index fea1e2b79063

[PATCH v3 00/20] Implement DWARF modversions

2024-09-23 Thread Sami Tolvanen
C and assembly code. Note that with gendwarfksyms, we have to actually build a temporary .o file for calculating assembly modversions. --- Sami Tolvanen (20): scripts: import more list macros scripts: move genksyms crc32 implementation to a common include tools: Add gendwarfksyms gendwarfks

Re: [PATCH v2 16/19] gendwarfksyms: Add support for reserved structure fields

2024-09-12 Thread Sami Tolvanen
Hi, On Thu, Sep 12, 2024 at 2:58 PM Benno Lossin wrote: > > On 12.09.24 22:58, Sami Tolvanen wrote: > > That's an interesting point. Is the problem that you cannot assign > > arbitrary values to the Rust enum that bindgen generates, or is using > > a #define the pr

Re: [PATCH v2 16/19] gendwarfksyms: Add support for reserved structure fields

2024-09-12 Thread Sami Tolvanen
Hi Benno, On Thu, Sep 12, 2024 at 11:08 AM Benno Lossin wrote: > > On 12.09.24 18:06, Sami Tolvanen wrote: > > > > I thought about this a bit and I wonder if we need a separate > > mechanism for that, or is it sufficient to just #define any additional > > hidden val

Re: [PATCH v2 16/19] gendwarfksyms: Add support for reserved structure fields

2024-09-12 Thread Sami Tolvanen
On Wed, Sep 11, 2024 at 4:43 AM Petr Pavlu wrote: > > On 8/31/24 02:05, Sami Tolvanen wrote: > > On Fri, Aug 30, 2024 at 9:34 AM Miroslav Benes wrote: > >> > >> yes, this is one of the approaches we use in SLES. We add kabi paddings > >> to some structures

Re: [PATCH v2 14/19] gendwarfksyms: Add symbol versioning

2024-09-11 Thread Sami Tolvanen
Hi Petr, On Wed, Sep 11, 2024 at 3:08 AM Petr Pavlu wrote: > > On 8/15/24 19:39, Sami Tolvanen wrote: > > +static inline unsigned long partial_crc32(const char *s, unsigned long crc) > > +{ > > + while (*s) > > + crc = partial_crc32_one(*s

Re: [PATCH v2 13/19] gendwarfksyms: Add symtypes output

2024-09-10 Thread Sami Tolvanen
Hi Petr, On Tue, Sep 10, 2024 at 7:58 AM Petr Pavlu wrote: > > On 8/15/24 19:39, Sami Tolvanen wrote: > > @@ -122,6 +135,16 @@ int main(int argc, const char **argv) > > > > check(symbol_read_exports(stdin)); > > > > + if (symtypes_file) { > > +

Re: [PATCH v2 01/19] tools: Add gendwarfksyms

2024-09-10 Thread Sami Tolvanen
On Tue, Sep 10, 2024 at 2:44 AM Masahiro Yamada wrote: > > On Fri, Sep 6, 2024 at 5:53 AM Sami Tolvanen wrote: > > > > Thanks for the patch! I think this would otherwise work, but I also > > need jhash (or a similar hash function), and I can't combine the > &

Re: [PATCH v2 01/19] tools: Add gendwarfksyms

2024-09-05 Thread Sami Tolvanen
Hi, On Thu, Sep 5, 2024 at 2:30 AM Masahiro Yamada wrote: > > On Fri, Aug 16, 2024 at 2:39 AM Sami Tolvanen wrote: > > > > +++ b/scripts/gendwarfksyms/gendwarfksyms.h > > @@ -0,0 +1,78 @@ > > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > > +/* &

Re: [PATCH v2 11/19] gendwarfksyms: Limit structure expansion

2024-09-05 Thread Sami Tolvanen
On Tue, Sep 3, 2024 at 8:15 AM Petr Pavlu wrote: > > On 8/15/24 19:39, Sami Tolvanen wrote: > > Expand each structure type only once per exported symbol. This > > is necessary to support self-referential structures, which would > > otherwise result in infinite recursion,

Re: [PATCH v2 08/19] gendwarfksyms: Expand subroutine_type

2024-09-05 Thread Sami Tolvanen
On Tue, Sep 3, 2024 at 8:11 AM Petr Pavlu wrote: > > On 8/15/24 19:39, Sami Tolvanen wrote: > > > > +static int __process_subroutine_type(struct state *state, struct die > > *cache, > > + Dwarf_Die *die, const char *type) > &

Re: [PATCH v2 06/19] gendwarfksyms: Add a cache for processed DIEs

2024-09-05 Thread Sami Tolvanen
Hi Petr, On Mon, Sep 2, 2024 at 3:05 AM Petr Pavlu wrote: > > On 8/15/24 19:39, Sami Tolvanen wrote: > > +void die_map_free(void) > > +{ > > + struct hlist_node *tmp; > > + unsigned int stats[LAST + 1]; > > + struct die *cd; > > + int

Re: [PATCH v2 02/19] gendwarfksyms: Add symbol list handling

2024-09-04 Thread Sami Tolvanen
On Sun, Sep 1, 2024 at 11:00 AM Masahiro Yamada wrote: > > On Fri, Aug 16, 2024 at 2:39 AM Sami Tolvanen wrote: > > > > /* > > - * Symbol processing > > + * Exported symbol processing > > */ > > static int process_subprogram(struct state *state, D

Re: [PATCH v2 03/19] gendwarfksyms: Add address matching

2024-09-04 Thread Sami Tolvanen
Hi, On Sun, Sep 1, 2024 at 11:11 AM Masahiro Yamada wrote: > > On Fri, Aug 16, 2024 at 2:39 AM Sami Tolvanen wrote: > > > > +static int set_symbol_addr(struct symbol *sym, void *arg) > > +{ > > + struct symbol_addr *addr = arg; > > + > >

Re: [PATCH v2 18/19] x86/asm-prototypes: Include

2024-09-04 Thread Sami Tolvanen
Hi Masahiro, On Sun, Sep 1, 2024 at 10:51 AM Masahiro Yamada wrote: > > On Fri, Aug 16, 2024 at 2:39 AM Sami Tolvanen wrote: > > > > refers to struct pt_regs, make sure it's visible. > > > > Signed-off-by: Sami Tolvanen > > > Then, why don't

Re: [PATCH v2 16/19] gendwarfksyms: Add support for reserved structure fields

2024-08-30 Thread Sami Tolvanen
Hi Miroslav, On Fri, Aug 30, 2024 at 9:34 AM Miroslav Benes wrote: > > yes, this is one of the approaches we use in SLES. We add kabi paddings > to some structures in advance (see [1] as a random example) and then use > it later if needed. > > It is not the only approach. Much more often we do no

Re: [PATCH v2 02/19] gendwarfksyms: Add symbol list handling

2024-08-28 Thread Sami Tolvanen
On Wed, Aug 28, 2024 at 02:35:29PM +0200, Petr Pavlu wrote: > On 8/15/24 19:39, Sami Tolvanen wrote: > > diff --git a/scripts/gendwarfksyms/dwarf.c b/scripts/gendwarfksyms/dwarf.c > > index 65a29d0bd8f4..71cfab0553da 100644 > > --- a/scripts/gendwarfksyms/dwarf.c > >

Re: [PATCH v2 00/19] Implement DWARF modversions

2024-08-28 Thread Sami Tolvanen
Hi Masahiro, On Wed, Aug 28, 2024 at 04:04:09PM +0900, Masahiro Yamada wrote: > On Fri, Aug 16, 2024 at 2:39 AM Sami Tolvanen wrote: > > > > The first 16 patches of this series add a small tool for computing > > > Splitting a new tool into small chunks makes line-by-l

Re: [PATCH v2 06/19] gendwarfksyms: Add a cache for processed DIEs

2024-08-28 Thread Sami Tolvanen
On Thu, Aug 29, 2024 at 03:15:02AM +0900, Masahiro Yamada wrote: > On Fri, Aug 16, 2024 at 2:39 AM Sami Tolvanen wrote: > > +static int append_item(struct die *cd, struct die_fragment **res) > > +{ > > + struct die_fragment *prev; > > + struct die_fragmen

Re: [PATCH v2 05/19] gendwarfksyms: Expand base_type

2024-08-28 Thread Sami Tolvanen
On Wed, Aug 28, 2024 at 02:46:03PM +0200, Petr Pavlu wrote: > > +static int process_fmt(struct state *state, const char *fmt, ...) > > Nit: The state parameter is unused by a number of these process_*() > functions, including the leaf process(). I suggest removing it so it > doesn't need to be pas

Re: [PATCH v2 04/19] gendwarfksyms: Add support for type pointers

2024-08-28 Thread Sami Tolvanen
On Wed, Aug 28, 2024 at 04:15:03PM +0900, Masahiro Yamada wrote: > On Wed, Aug 28, 2024 at 3:50 PM Masahiro Yamada wrote: > > > > On Fri, Aug 16, 2024 at 2:39 AM Sami Tolvanen > > wrote: > > > > > > The compiler may choose not to emit type information in

Re: [PATCH v2 03/19] gendwarfksyms: Add address matching

2024-08-28 Thread Sami Tolvanen
On Thu, Aug 29, 2024 at 03:22:25AM +0900, Masahiro Yamada wrote: > On Fri, Aug 16, 2024 at 2:39 AM Sami Tolvanen wrote: > > int symbol_read_exports(FILE *file) > > @@ -57,13 +93,14 @@ int symbol_read_exports(FILE *file) > >

Re: [PATCH v2 02/19] gendwarfksyms: Add symbol list handling

2024-08-28 Thread Sami Tolvanen
On Thu, Aug 29, 2024 at 03:16:21AM +0900, Masahiro Yamada wrote: > On Fri, Aug 16, 2024 at 2:39 AM Sami Tolvanen wrote: > > @@ -105,6 +105,8 @@ int main(int argc, const char **argv) > > if (parse_options(argc, argv) < 0) > > return usage(

Re: [PATCH v2 01/19] tools: Add gendwarfksyms

2024-08-28 Thread Sami Tolvanen
Hi Masahiro, On Thu, Aug 29, 2024 at 02:45:03AM +0900, Masahiro Yamada wrote: > On Fri, Aug 16, 2024 at 2:39 AM Sami Tolvanen wrote: > > +static int usage(void) > > +{ > > + error("usage: gendwarfksyms [options] elf-object-file ..."); > > > >

Re: [PATCH v2 01/19] tools: Add gendwarfksyms

2024-08-28 Thread Sami Tolvanen
On Wed, Aug 28, 2024 at 02:31:05PM +0200, Petr Pavlu wrote: > On 8/26/24 20:47, Sami Tolvanen wrote: > > How do you propose using the function? This loop goes through multiple > > input files, should we need them, and we iterate through all the CUs > > in process_modules. &

Re: [PATCH v2 03/19] gendwarfksyms: Add address matching

2024-08-27 Thread Sami Tolvanen
Hi Petr, On Tue, Aug 27, 2024 at 12:40 PM Petr Pavlu wrote: > > On 8/15/24 19:39, Sami Tolvanen wrote: > > +static inline u32 symbol_addr_hash(const struct symbol_addr *addr) > > +{ > > + return jhash(addr, sizeof(struct symbol_addr), 0); > > I would be c

Re: [PATCH v2 02/19] gendwarfksyms: Add symbol list handling

2024-08-27 Thread Sami Tolvanen
Hi Petr, On Tue, Aug 27, 2024 at 2:16 AM Petr Pavlu wrote: > > On 8/15/24 19:39, Sami Tolvanen wrote: > > +static bool is_export_symbol(struct state *state, Dwarf_Die *die) > > +{ > > + Dwarf_Die *source = die; > > + Dwarf_Die origin; > > + > &

Re: [PATCH v2 01/19] tools: Add gendwarfksyms

2024-08-27 Thread Sami Tolvanen
Hi Greg, On Fri, Aug 16, 2024 at 12:14 AM Greg Kroah-Hartman wrote: > > On Thu, Aug 15, 2024 at 05:39:05PM +, Sami Tolvanen wrote: > > --- /dev/null > > +++ b/scripts/gendwarfksyms/dwarf.c > > @@ -0,0 +1,87 @@ > > +// SPDX-License-Identifier: GPL-2.0-or-later &g

Re: [PATCH v2 01/19] tools: Add gendwarfksyms

2024-08-26 Thread Sami Tolvanen
Hi Petr, On Mon, Aug 26, 2024 at 10:42 AM Petr Pavlu wrote: > > On 8/15/24 19:39, Sami Tolvanen wrote: > > +static int parse_options(int argc, const char **argv) > > +{ > > + for (int i = 1; i < argc; i++) { > > + bool flag = false; > >

Re: [PATCH v2 16/19] gendwarfksyms: Add support for reserved structure fields

2024-08-23 Thread Sami Tolvanen
On Thu, Aug 22, 2024 at 11:53 PM Greg Kroah-Hartman wrote: > > On Thu, Aug 22, 2024 at 12:00:15PM +, Benno Lossin wrote: > > > Here's one example in the android tree where 4 64bit fields are reserved > > > for future abi changes: > > > > > > https://android.googlesource.com/kernel/common/

Re: [PATCH v8 2/4] kbuild: generate offset range data for builtin modules

2024-08-23 Thread Sami Tolvanen
On Fri, Aug 23, 2024 at 10:06 AM Kris Van Hees wrote: > > On Fri, Aug 23, 2024 at 04:53:29PM +, Sami Tolvanen wrote: > > Hi Kris, > > > > On Thu, Aug 22, 2024 at 02:19:39PM -0400, Kris Van Hees wrote: > > > diff --git a/scripts/generate_bu

Re: [PATCH v8 2/4] kbuild: generate offset range data for builtin modules

2024-08-23 Thread Sami Tolvanen
Hi Kris, On Thu, Aug 22, 2024 at 02:19:39PM -0400, Kris Van Hees wrote: > diff --git a/scripts/generate_builtin_ranges.awk > b/scripts/generate_builtin_ranges.awk > new file mode 100755 > index ..68df05fd3036 > --- /dev/null > +++ b/scripts/generate_builtin_ranges.awk > @@ -0,0 +1,505

Re: [PATCH v2 00/19] Implement DWARF modversions

2024-08-22 Thread Sami Tolvanen
Hi Jon, On Thu, Aug 22, 2024 at 9:43 AM Jonathan Corbet wrote: > > Sami Tolvanen writes: > > > The first 16 patches of this series add a small tool for computing > > symbol versions from DWARF, called gendwarfksyms. When passed a > > list of exported symbols a

Re: [PATCH] MAINTAINERS: scale modules with more reviewers

2024-08-21 Thread Sami Tolvanen
t and C code for modules so we can ensure we get proper > reviews for both parts of the code and so that we can scale. > > Add those who have stepped up to help. > > Signed-off-by: Luis Chamberlain Acked-by: Sami Tolvanen Sami

Re: [PATCH v2 16/19] gendwarfksyms: Add support for reserved structure fields

2024-08-21 Thread Sami Tolvanen
On Wed, Aug 21, 2024 at 4:31 AM Benno Lossin wrote: > > On 20.08.24 22:03, Matthew Maurer wrote: > >>> The way `KAbiReserved` is implemented is via a `union` (maybe a bit > >>> ironic, considering what I said in my other replies, but in this case, > >>> we would provide a safe abstraction over thi

Re: [BUG] tracing: dynamic ftrace selftest detected failures

2024-08-21 Thread Sami Tolvanen
On Tue, Aug 20, 2024 at 5:21 PM Masami Hiramatsu wrote: > > On Wed, 21 Aug 2024 08:43:51 +0900 > Masami Hiramatsu (Google) wrote: > > > On Tue, 20 Aug 2024 18:11:09 -0400 > > Steven Rostedt wrote: > > > > > On Wed, 21 Aug 2024 07:05:39 +0900 > > > Masami Hiramatsu (Google) wrote: > > > > > > >

Re: [PATCH v2 16/19] gendwarfksyms: Add support for reserved structure fields

2024-08-20 Thread Sami Tolvanen
On Mon, Aug 19, 2024 at 10:17 PM Benno Lossin wrote: > > On 19.08.24 21:38, Sami Tolvanen wrote: > > > > This definitely looks cleaner than unions in Rust, but how would this > > scheme be visible in DWARF? You might also need to expand the annotation > > to allo

Re: [BUG] tracing: dynamic ftrace selftest detected failures

2024-08-20 Thread Sami Tolvanen
On Tue, Aug 20, 2024 at 3:48 AM Mark Rutland wrote: > > On Tue, Aug 20, 2024 at 10:03:30AM +0900, Masami Hiramatsu wrote: > > On Mon, 19 Aug 2024 12:02:44 -0400 > > Steven Rostedt wrote: > > > > > On Tue, 20 Aug 2024 00:56:49 +0900 > > > Masami Hiramatsu (Google) wrote: > > > > > > > > > > > > >

Re: [PATCH v2 16/19] gendwarfksyms: Add support for reserved structure fields

2024-08-19 Thread Sami Tolvanen
Hi Benno, On Sat, Aug 17, 2024 at 01:19:55PM +, Benno Lossin wrote: > > For this use-case (the one in the patch), I don't really know if we want > to copy the approach from C. Do we even support exporting kABI from > Rust? If yes, then we I would recommend we tag it in the source code > inste

Re: [PATCH v2 16/19] gendwarfksyms: Add support for reserved structure fields

2024-08-16 Thread Sami Tolvanen
Hi Greg, On Fri, Aug 16, 2024 at 12:20 AM Greg Kroah-Hartman wrote: > > On Thu, Aug 15, 2024 at 05:39:20PM +, Sami Tolvanen wrote: > > Distributions that want to maintain a stable kABI need the ability to > > add reserved fields to kernel data structures that they anti

Re: [PATCH v2 00/19] Implement DWARF modversions

2024-08-15 Thread Sami Tolvanen
Hi Sedat, On Thu, Aug 15, 2024 at 8:14 PM Sedat Dilek wrote: > > so this work is on top of Linux v6.11-rc3 Correct. git format-patch also adds the base commit to the end of the cover letter. > can you tag it as gendwarfksyms-v2? Sure. Here you go: https://github.com/samitolvanen/linux/commits

Re: [PATCH v3 14/16] modules: Support extended MODVERSIONS info

2024-08-15 Thread Sami Tolvanen
Hi Matt, On Tue, Aug 6, 2024 at 9:25 PM Matthew Maurer wrote: > [...] > +void modversion_ext_start(const struct load_info *info, > + struct modversion_info_ext *start) > +{ > + unsigned int crc_idx = info->index.vers_ext_crc; > + unsigned int name_idx = info->i

[PATCH v2 19/19] kbuild: Add gendwarfksyms as an alternative to genksyms

2024-08-15 Thread Sami Tolvanen
When MODVERSIONS is enabled, allow selecting gendwarfksyms as the implementation, but default to genksyms. Signed-off-by: Sami Tolvanen --- kernel/module/Kconfig | 25 - scripts/Makefile | 2 +- scripts/Makefile.build | 34 -- 3

[PATCH v2 18/19] x86/asm-prototypes: Include

2024-08-15 Thread Sami Tolvanen
refers to struct pt_regs, make sure it's visible. Signed-off-by: Sami Tolvanen --- arch/x86/include/asm/asm-prototypes.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/asm-prototypes.h b/arch/x86/include/asm/asm-prototypes.h index 25466c4d2134..c82e68c8b7c2 1

[PATCH v2 17/19] export: Add __gendwarfksyms_ptr_ references to exported symbols

2024-08-15 Thread Sami Tolvanen
igned-off-by: Sami Tolvanen --- include/linux/export.h | 15 +++ 1 file changed, 15 insertions(+) diff --git a/include/linux/export.h b/include/linux/export.h index 0bbd02fd351d..cf71d3202e5b 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -52,9 +52,24 @@

[PATCH v2 16/19] gendwarfksyms: Add support for reserved structure fields

2024-08-15 Thread Sami Tolvanen
g int byte_size(8) encoding(5) data_member_location(0), member base_type long int byte_size(8) encoding(5) data_member_location(8), } byte_size(16); #SYMVER exported 0x67997f89 Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/dwarf.c | 148 +- sc

[PATCH v2 15/19] gendwarfksyms: Add support for declaration-only data structures

2024-08-15 Thread Sami Tolvanen
g --stable, the definition is ignored and we again have the original symbol version: subprogram( formal_parameter pointer_type { structure_type struct0 { } } byte_size(8), ) -> base_type int byte_size(4) encoding(5); #SYMVER func 0x7e8284f9 Signed-off-b

[PATCH v2 14/19] gendwarfksyms: Add symbol versioning

2024-08-15 Thread Sami Tolvanen
Add a basic CRC32 implementation adapted from genksyms, and produce matching output from symtypes strings in type_map. Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/Makefile| 1 + scripts/gendwarfksyms/crc32.c | 69 ++ scripts/gendwarfksyms/crc32.h

[PATCH v2 13/19] gendwarfksyms: Add symtypes output

2024-08-15 Thread Sami Tolvanen
references are wrapped in single quotes. E.g.: s#'core::result::Result' 2. The actual type definition is the simple parsed DWARF format we output with --dump-dies, not the preprocessed C-style format genksyms produces. Signed-off-by: Sami Tolvanen --- scripts/gen

[PATCH v2 12/19] gendwarfksyms: Add die_map debugging

2024-08-15 Thread Sami Tolvanen
. Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/dwarf.c | 19 +-- scripts/gendwarfksyms/gendwarfksyms.c | 9 + scripts/gendwarfksyms/gendwarfksyms.h | 14 ++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/scripts/gendwarfksyms

[PATCH v2 11/19] gendwarfksyms: Limit structure expansion

2024-08-15 Thread Sami Tolvanen
levels. This should be plenty for detecting ABI differences, but it stops us from pulling in half the kernel for types that contain pointers to large kernel data structures, like task_struct, for example. Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/Makefile| 1 + scripts

[PATCH v2 10/19] gendwarfksyms: Expand structure types

2024-08-15 Thread Sami Tolvanen
&str { member pointer_type { base_type u8 byte_size(1) encoding(7) } data_member_location(0), member base_type usize byte_size(8) encoding(7) data_member_location(8), } byte_size(16) alignment(8) }, ) -> base_type void; Signed-off-by: Sami Tolvanen -

[PATCH v2 09/19] gendwarfksyms: Expand array_type

2024-08-15 Thread Sami Tolvanen
(8) }; Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/dwarf.c | 31 +++ 1 file changed, 31 insertions(+) diff --git a/scripts/gendwarfksyms/dwarf.c b/scripts/gendwarfksyms/dwarf.c index c81652426be8..4ec69fce95f3 100644 --- a/scripts/gendwarfksyms/dwarf.c

[PATCH v2 08/19] gendwarfksyms: Expand subroutine_type

2024-08-15 Thread Sami Tolvanen
ype void; Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/dwarf.c | 57 ++- scripts/gendwarfksyms/gendwarfksyms.h | 1 + 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/scripts/gendwarfksyms/dwarf.c b/scripts/gendwarfksyms/dwarf.c in

[PATCH v2 06/19] gendwarfksyms: Add a cache for processed DIEs

2024-08-15 Thread Sami Tolvanen
Basic types in DWARF repeat frequently and traversing the DIEs using libdw is relatively slow. Add a simple hashtable based cache for the processed DIEs. Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/Makefile| 1 + scripts/gendwarfksyms/die.c | 170

[PATCH v2 07/19] gendwarfksyms: Expand type modifiers and typedefs

2024-08-15 Thread Sami Tolvanen
-off-by: Sami Tolvanen --- scripts/gendwarfksyms/die.c | 13 + scripts/gendwarfksyms/dwarf.c | 76 +-- scripts/gendwarfksyms/gendwarfksyms.h | 7 ++- 3 files changed, 92 insertions(+), 4 deletions(-) diff --git a/scripts/gendwarfksyms/die.c b/scripts

[PATCH v2 05/19] gendwarfksyms: Expand base_type

2024-08-15 Thread Sami Tolvanen
base_type unsigned long byte_size(8) encoding(7); ... Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/dwarf.c | 121 +- 1 file changed, 120 insertions(+), 1 deletion(-) diff --git a/scripts/gendwarfksyms/dwarf.c b/scripts/gendwarfksyms/dwarf.c index

[PATCH v2 04/19] gendwarfksyms: Add support for type pointers

2024-08-15 Thread Sami Tolvanen
xternal_symbol); Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/dwarf.c | 26 +- scripts/gendwarfksyms/gendwarfksyms.h | 6 ++ scripts/gendwarfksyms/symbols.c | 16 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/scripts

[PATCH v2 03/19] gendwarfksyms: Add address matching

2024-08-15 Thread Sami Tolvanen
d-off-by: Sami Tolvanen --- scripts/gendwarfksyms/gendwarfksyms.c | 2 + scripts/gendwarfksyms/gendwarfksyms.h | 7 ++ scripts/gendwarfksyms/symbols.c | 161 +- 3 files changed, 165 insertions(+), 5 deletions(-) diff --git a/scripts/gendwarfksyms/gendwarfksyms

[PATCH v2 02/19] gendwarfksyms: Add symbol list handling

2024-08-15 Thread Sami Tolvanen
Add support for passing a list of exported symbols to gendwarfksyms via stdin and filter out non-exported symbols from the output. Signed-off-by: Sami Tolvanen --- scripts/gendwarfksyms/Makefile| 1 + scripts/gendwarfksyms/dwarf.c | 53 ++- scripts/gendwarfksyms

[PATCH v2 01/19] tools: Add gendwarfksyms

2024-08-15 Thread Sami Tolvanen
Add a basic DWARF parser, which uses libdw to traverse the debugging information in an object file and looks for functions and variables. In follow-up patches, this will be expanded to produce symbol versions for CONFIG_MODVERSIONS from DWARF. Signed-off-by: Sami Tolvanen --- kernel/module

[PATCH v2 00/19] Implement DWARF modversions

2024-08-15 Thread Sami Tolvanen
data structure fields and declaration-onl structures. Also added examples for using these features. - Added a GENDWARFKSYMS option and hooked up kbuild support for both C and assembly code. Note that with gendwarfksyms, we have to actually build a temporary .o file for calculating assem

Re: [PATCH v3 0/2] Fix kallsyms with CONFIG_LTO_CLANG

2024-08-13 Thread Sami Tolvanen
anges in the first place, this series looks reasonable to me. Thanks for cleaning this up! Reviewed-by: Sami Tolvanen Sami

Re: [PATCH v2 3/3] tracing/kprobes: Use APIs that matches symbols without .XXX suffix

2024-08-07 Thread Sami Tolvanen
Hi, On Wed, Aug 7, 2024 at 3:08 AM Masami Hiramatsu wrote: > > On Wed, 7 Aug 2024 00:19:20 + > Song Liu wrote: > > > Do you mean we do not want patch 3/3, but would like to keep 1/3 and part > > of 2/3 (remove the _without_suffix APIs)? If this is the case, we are > > undoing the change by S

Re: [PATCH 00/15] Implement MODVERSIONS for Rust

2024-08-01 Thread Sami Tolvanen
Hi Petr, On Thu, Aug 1, 2024 at 4:22 AM Petr Pavlu wrote: > > STG is an interesting tool. I've played with it a bit last year. To be > frank, I was surprised to see a new tool being proposed by Google to > generate modversion CRCs from DWARF instead of potentially extending > your STG project for

Re: [PATCH 00/15] Implement MODVERSIONS for Rust

2024-07-26 Thread Sami Tolvanen
Hi Petr, On Mon, Jul 22, 2024 at 8:20 AM Petr Pavlu wrote: > > From my perspective, I'm okay if gendwarfksyms doesn't provide > functionality to compare a new object file with its reference symtypes > file. > > As mentioned, genksyms has this functionality but I actually think the > way it works

Re: [PATCH] rust: add `module_params` macro

2024-07-24 Thread Sami Tolvanen
Hi Luis, On Thu, Jul 18, 2024 at 5:15 PM Luis Chamberlain wrote: > > On Tue, Jul 09, 2024 at 12:08:16PM +0200, Miguel Ojeda wrote: > > On Mon, Jul 8, 2024 at 11:42 PM Luis Chamberlain wrote: > > > > > > The rationale here is that a rust binding means commitment then also > > > from fresh blood t

Re: [PATCH 00/15] Implement MODVERSIONS for Rust

2024-07-18 Thread Sami Tolvanen
On Tue, Jul 16, 2024 at 12:12 AM Greg Kroah-Hartman wrote: > > > After replacement: > > > > union { > > u64 new_member; > > struct { > > u8 __kabi_reserved_1[8]; > > }; > > } > > Note, such a thing would only be for the distros that w

Re: [PATCH 00/15] Implement MODVERSIONS for Rust

2024-07-15 Thread Sami Tolvanen
Hi Petr, On Wed, Jul 10, 2024 at 7:30 AM Petr Pavlu wrote: > > On 6/17/24 19:58, Sami Tolvanen wrote: > > Hi folks, > > > > This series implements CONFIG_MODVERSIONS for Rust, an important > > feature for distributions like Android that want to ship Rust >

Re: [PATCH] kallsyms, livepatch: Fix livepatch with CONFIG_LTO_CLANG

2024-07-08 Thread Sami Tolvanen
On Mon, Jul 8, 2024 at 2:33 PM Luis Chamberlain wrote: > > Looking at this again its not to me why Masahiro Yamada's suggestion on > that old patch series to just increase the length and put long symbols > names into its own section [0] could not be embraced with a new kconfig > option, so new ker

Re: [PATCH] kallsyms, livepatch: Fix livepatch with CONFIG_LTO_CLANG

2024-06-28 Thread Sami Tolvanen
Hi Luis, On Fri, Jun 28, 2024 at 10:36 AM Luis Chamberlain wrote: > > On Fri, Jun 28, 2024 at 02:23:49PM +0200, Miroslav Benes wrote: > > On Fri, 7 Jun 2024, Song Liu wrote: > > > > > Hi Miroslav, > > > > > > Thanks for reviewing the patch! > > > > > > I think it is possible. Currently, kallsyms_

Re: [PATCH 00/15] Implement MODVERSIONS for Rust

2024-06-18 Thread Sami Tolvanen
Hi Luis, On Tue, Jun 18, 2024 at 12:42:51PM -0700, Luis Chamberlain wrote: > On Mon, Jun 17, 2024 at 05:58:19PM +0000, Sami Tolvanen wrote: > > The first 12 patches of this series add a small tool for computing > > symbol versions from DWARF, called gendwarfksyms. When passe

Re: [PATCH 00/15] Implement MODVERSIONS for Rust

2024-06-18 Thread Sami Tolvanen
On Wed, Jun 19, 2024 at 04:03:45AM +0900, Masahiro Yamada wrote: > On Wed, Jun 19, 2024 at 2:18 AM Greg Kroah-Hartman > wrote: > > > > On Wed, Jun 19, 2024 at 01:50:36AM +0900, Masahiro Yamada wrote: > > > On Wed, Jun 19, 2024 at 1:44 AM Greg Kroah-Hartman > > > wrote: > > > > > > > > That's cool

Re: [PATCH 13/15] modpost: Add support for hashing long symbol names

2024-06-18 Thread Sami Tolvanen
On Wed, Jun 19, 2024 at 01:47:13AM +0900, Masahiro Yamada wrote: > On Tue, Jun 18, 2024 at 2:58 AM Sami Tolvanen wrote: > > > > +#define barrier_data(ptr) __asm__ __volatile__("": :"r"(ptr) :"memory") > > > > > I know this is a copy-

Re: [PATCH 00/15] Implement MODVERSIONS for Rust

2024-06-18 Thread Sami Tolvanen
Hi Masahiro, On Wed, Jun 19, 2024 at 01:28:21AM +0900, Masahiro Yamada wrote: > I am surprised at someone who attempts to add another variant of genksyms. The options are rather limited if we want Rust modules that are compatible with modversions. We either come up with a way to version Rust symb

[PATCH 10/15] gendwarfksyms: Expand structure types

2024-06-17 Thread Sami Tolvanen
e_type void; Signed-off-by: Sami Tolvanen --- tools/gendwarfksyms/gendwarfksyms.h | 5 ++ tools/gendwarfksyms/types.c | 127 +++- 2 files changed, 130 insertions(+), 2 deletions(-) diff --git a/tools/gendwarfksyms/gendwarfksyms.h b/tools/gendwarfksyms/gend

[PATCH 15/15] kbuild: Use gendwarfksyms to generate Rust symbol versions

2024-06-17 Thread Sami Tolvanen
Use gendwarfksyms to generate symbol versions for exported Rust symbols, and allow CONFIG_MODVERSIONS to be enabled with CONFIG_RUST, assuming the debugging information needed by gendwarfksyms is also available. Signed-off-by: Sami Tolvanen --- Makefile | 6 ++ init/Kconfig | 2

[PATCH 14/15] module: Support hashed symbol names when checking modversions

2024-06-17 Thread Sami Tolvanen
When checking modversions for symbol names longer than MODULE_NAME_LEN, look for the hashed symbol name instead. This is needed for Rust modules, which frequently use symbol names longer than the maximum length supported by struct modversion_info. Suggested-by: Matthew Maurer Signed-off-by: Sami

[PATCH 13/15] modpost: Add support for hashing long symbol names

2024-06-17 Thread Sami Tolvanen
if needed. Suggested-by: Matthew Maurer Signed-off-by: Sami Tolvanen --- scripts/mod/Makefile | 4 +- scripts/mod/modpost.c | 20 ++- scripts/mod/modpost.h | 20 +++ scripts/mod/symhash.c | 327 ++ 4 files changed, 364 insertions(+), 7 deletions(-)

[PATCH 12/15] gendwarfksyms: Add inline debugging

2024-06-17 Thread Sami Tolvanen
Understanding the operation and caching of the tool can be somewhat challenging without a debugger. Add inline debugging information with the --inline-debug command, which adds highlighted tags to the --debug output with information about cache states etc. Signed-off-by: Sami Tolvanen --- tools

[PATCH 11/15] gendwarfksyms: Limit structure expansion

2024-06-17 Thread Sami Tolvanen
levels inside the pointer. This should be plenty for catching ABI differences and stops us from pulling in half the kernel for structs that contain pointers to large structs like task_struct. Signed-off-by: Sami Tolvanen --- tools/gendwarfksyms/cache.c | 49 tools

  1   2   3   4   5   6   7   8   9   >