Re: [RFC][PATCH v5 00/51] objtool: Make recordmcount a subcommand

2020-06-23 Thread Matt Helsley
On Thu, Jun 18, 2020 at 01:37:46PM -0700, Matt Helsley wrote: > recordmcount has its own ELF wrapper code and could utilize > objtool's ELF code to more-portably handle architecture variations. > This series makes recordmcount a subcommand of objtool. It very > gradually converts

[RFC][PATCH v5 12/51] objtool: mcount: Walk relocation lists

2020-06-18 Thread Matt Helsley
Rather than walk the section tables using the old recordmcount mapping of the ELF file, walk the section list provided by objtool's ELF code. This removes the last use of of the Elf_r_sym wrapper so we remove that too. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 10

[RFC][PATCH v5 04/51] objtool: recordmcount: Start using objtool's elf wrapper

2020-06-18 Thread Matt Helsley
-- the libelf/objtool way and the old recordmcount wrapper way which avoids these extra data structures by using indices, offsets, and pointers into the mmapped ELF file. Subsequent patches will convert from the old recordmcount accessors to the libelf/objtool accessors. Signed-off-by: Matt Helsley

[RFC][PATCH v5 10/51] objtool: mcount: Walk objtool Elf structs in find_secsym_ndx

2020-06-18 Thread Matt Helsley
the function to something that reads more easily. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 2 + tools/objtool/recordmcount.h | 94 2 files changed, 22 insertions(+), 74 deletions(-) diff --git a/tools/objtool/recordmcount.c b/tools

[RFC][PATCH v5 26/51] objtool: mcount: Remove unused file mapping

2020-06-18 Thread Matt Helsley
data and call instruction offsets. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 99 +++- tools/objtool/recordmcount.h | 4 +- 2 files changed, 9 insertions(+), 94 deletions(-) diff --git a/tools/objtool/recordmcount.c b/tools/objtool

[RFC][PATCH v5 29/51] objtool: mcount: Pre-allocate new ELF sections

2020-06-18 Thread Matt Helsley
Rather than allocating the ELF sections after collecting the mcount locations and building the relocation entries, create the empty sections beforehand. This has the benefit of removing the memcpy() and just using the resulting libelf buffers directly. Signed-off-by: Matt Helsley --- tools

[RFC][PATCH v5 16/51] objtool: mcount: Move is_fake_mcount()

2020-06-18 Thread Matt Helsley
Promote the now-bit-independent is_fake_mcount() out of the old recordmcount ELF wrapper. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 48 +++--- tools/objtool/recordmcount.h | 50 2 files changed, 45 insertions

[RFC][PATCH v5 27/51] objtool: mcount: Reduce usage of _size wrapper

2020-06-18 Thread Matt Helsley
Use a new loc_size parameter to append_func() rather than use the wrapper's _size macro directly. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.h | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/objtool/recordmcount.h b/tools/objtool

[RFC][PATCH v5 03/51] objtool: Make recordmcount into mcount subcmd

2020-06-18 Thread Matt Helsley
recordmcount to be more easily readable and remove recordmcount's crude accessor wrapping code. Signed-off-by: Matt Helsley --- Documentation/dontdiff | 2 +- Documentation/trace/ftrace.rst | 6 ++-- Makefile| 15 -- arch/arm64/include/asm/ftrace.h | 2

[RFC][PATCH v5 02/51] objtool: Prepare to merge recordmcount

2020-06-18 Thread Matt Helsley
Move recordmcount into the objtool directory. We keep this step separate so changes which turn recordmcount into a subcommand of objtool don't get obscured. Signed-off-by: Matt Helsley --- Documentation/trace/ftrace-design.rst | 4 ++-- Documentation/trace/ftrace.rst | 2

[RFC][PATCH v5 07/51] objtool: mcount: Move nhdr into find_symtab()

2020-06-18 Thread Matt Helsley
Since it's no longer needed in the rest of do_func() we can move it to where it's needed rather than pass it as a parameter. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/objtool/recordmcount.h b

[RFC][PATCH v5 28/51] objtool: mcount: Move mcount_adjust out of wrapper

2020-06-18 Thread Matt Helsley
of the variable's type inside the wrapper -- we can just use a regular int. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 11 --- tools/objtool/recordmcount.h | 5 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/objtool/recordmcount.c b/tools/objtool

[RFC][PATCH v5 19/51] objtool: mcount: Restrict using ehdr in append_func()

2020-06-18 Thread Matt Helsley
and those will get replaced later. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.h | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h index eed592954f37..19bff5a7c8ce 100644 --- a/tools/objtool

[RFC][PATCH v5 37/51] objtool: mcount: Simplify mcount name matching

2020-06-18 Thread Matt Helsley
Setting altmcount only when processing ARM ELF files is not necessary -- we can make the code easier to read by always checking for the string. Signed-off-by: Matt Helsley --- tools/objtool/mcount.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/objtool/mcount.c b

[RFC][PATCH v5 30/51] objtool: mcount: Generic location and relocation table types

2020-06-18 Thread Matt Helsley
the recordmcount wrapper. The next patch will move it out of the wrapper. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 44 +++-- tools/objtool/recordmcount.h | 122 ++- 2 files changed, 60 insertions(+), 106 deletions(-) diff --git a/tools/objtool

[RFC][PATCH v5 50/51] objtool: mcount: Remove useless lookup

2020-06-18 Thread Matt Helsley
Since the relocation section's sh_info points back to the text section it applies to and we already have that we can just pass it in and greatly simplify find_section_sym_index(). Signed-off-by: Matt Helsley --- tools/objtool/mcount.c | 39 +++ 1 file changed

[RFC][PATCH v5 13/51] objtool: mcount: Return symbol from mcountsym

2020-06-18 Thread Matt Helsley
to the objtool struct symbol which callers can use as-needed. Reported-by: Kamalesh Babulal Signed-off-by: Matt Helsley Co-developed-by: Kamalesh Babulal Co-developed-by: Peter Zijlstra -- Thanks to Kamalesh Babulal for reporting this problem and suggesting a fix. Thanks to Peter Zijlstra

[RFC][PATCH v5 49/51] objtool: mcount: Remove relocation size check

2020-06-18 Thread Matt Helsley
Rather than use the size of the relocations check the section header type directly to see if the mcount relocations should be rel or rela relocations. Signed-off-by: Matt Helsley --- tools/objtool/elf.c| 4 ++-- tools/objtool/elf.h| 2 +- tools/objtool/mcount.c | 15 +-- 3

[RFC][PATCH v5 45/51] objtool: mcount: Move mcount section test to objtool ELF

2020-06-18 Thread Matt Helsley
. Signed-off-by: Matt Helsley --- tools/objtool/elf.c| 16 tools/objtool/elf.h| 2 +- tools/objtool/mcount.c | 36 +++- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index

[RFC][PATCH v5 14/51] objtool: mcount: Move get_mcountsym

2020-06-18 Thread Matt Helsley
Now that it's been stripped of using the old recordmcount ELF wrapper get_mcountsym() is ready to be promoted out of the double-included wrapper header. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 16 tools/objtool/recordmcount.h | 19 --- 2

[RFC][PATCH v5 09/51] objtool: mcount: Use libelf for section header names

2020-06-18 Thread Matt Helsley
-by: Matt Helsley --- tools/objtool/elf.c | 3 +- tools/objtool/elf.h | 1 + tools/objtool/recordmcount.c | 2 +- tools/objtool/recordmcount.h | 89 ++-- 4 files changed, 37 insertions(+), 58 deletions(-) diff --git a/tools/objtool/elf.c b/tools

[RFC][PATCH v5 38/51] objtool: mcount: mcount symbol name simplification

2020-06-18 Thread Matt Helsley
Remove gpfx -- the recognized prefix for the mcount symbol -- and just recognize any of the prefixes. This allows us to further substitute the various strings directly into the code rather than using variables. Signed-off-by: Matt Helsley --- tools/objtool/mcount.c | 19 --- 1

[RFC][PATCH v5 51/51] objtool: mcount: Remove stale description

2020-06-18 Thread Matt Helsley
The comments at the top no longer reflect how we process the ELF contents. More helpful comments are inline with the code so we don't need the top comments either. Signed-off-by: Matt Helsley --- tools/objtool/mcount.c | 13 - 1 file changed, 13 deletions(-) diff --git a/tools

[RFC][PATCH v5 35/51] objtool: mcount: Remove endian wrappers

2020-06-18 Thread Matt Helsley
Now that they're no longer used we can remove these endian wrappers. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 63 1 file changed, 63 deletions(-) diff --git a/tools/objtool/recordmcount.c b/tools/objtool/recordmcount.c index

[RFC][PATCH v5 46/51] objtool: mcount: Flag mcount relocation sections

2020-06-18 Thread Matt Helsley
Move the check for relocations sections that apply to mcountable text sections into objtool's ELF code. Signed-off-by: Matt Helsley --- tools/objtool/elf.c| 13 + tools/objtool/elf.h| 2 +- tools/objtool/mcount.c | 36 3 files changed

[RFC][PATCH v5 43/51] objtool: check: Use class to recognize kcov calls

2020-06-18 Thread Matt Helsley
Suggested-by: Peter Zijlstra Signed-off-by: Matt Helsley --- tools/objtool/check.c | 3 +-- tools/objtool/elf.c | 7 +++ tools/objtool/elf.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 78375908acda

[RFC][PATCH v5 33/51] objtool: mcount: Remove wrapper for ELF relocation type

2020-06-18 Thread Matt Helsley
Remove the last uses of the Elf_Rela wrapper by passing the size of the relocations we're dealing with as a parameter. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 4 ++-- tools/objtool/recordmcount.h | 7 ++- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git

[RFC][PATCH v5 42/51] objtool: mcount: Move mcount symbol name testing

2020-06-18 Thread Matt Helsley
for individual subcommands. Finally, if we manage to combine subcommands into a single exec of objtool the number of passes through the ELF data could be even further reduced. Suggested-by: Peter Zijlstra Signed-off-by: Matt Helsley --- tools/objtool/elf.c| 18 ++ tools

[RFC][PATCH v5 34/51] objtool: mcount: Remove wrapper double-include trick

2020-06-18 Thread Matt Helsley
the wrapped naming. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 113 -- tools/objtool/recordmcount.h | 132 --- 2 files changed, 107 insertions(+), 138 deletions(-) delete mode 100644 tools/objtool/recordmcount.h diff

[RFC][PATCH v5 40/51] objtool: mcount: const-ify ARM instruction patterns

2020-06-18 Thread Matt Helsley
-by: Matt Helsley --- tools/objtool/mcount.c | 42 +- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tools/objtool/mcount.c b/tools/objtool/mcount.c index 5c59df0df97b..629eb7222ef3 100644 --- a/tools/objtool/mcount.c +++ b/tools/objtool/mcount.c

[RFC][PATCH v5 31/51] objtool: mcount: Use objtool relocation section

2020-06-18 Thread Matt Helsley
difference between this and the old recordmcount code is we didn't set SHF_INFO_LINK so we clear the sh_flags as before. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.h | 18 +- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/tools/objtool/recordmcount.h

[RFC][PATCH v5 48/51] objtool: mcount: Eliminate first pass

2020-06-18 Thread Matt Helsley
Determine the size of the mcount relocations in objtool's ELF reading code. This reduces the number of passes we make through the list of sections (which can become large due to things like -ffunction-sections). Signed-off-by: Matt Helsley --- tools/objtool/elf.c| 2 ++ tools/objtool/elf.h

[RFC][PATCH v5 25/51] objtool: mcount: Use ELF header from objtool

2020-06-18 Thread Matt Helsley
The ELF header is the very first structure in an ELF file. Rather than cast it from the file mapping we use the ELF header extracted via objtool's ELF code. This is the last usage of the open-coded mapping of the ELF file which we will remove in a later step. Signed-off-by: Matt Helsley

[RFC][PATCH v5 41/51] objtool: mcount: Convert nop writes to elf_write_insn()

2020-06-18 Thread Matt Helsley
objtool's elf_write_insn() does extra checking when writing to an instruction so use that rather than a plain memcpy(). Signed-off-by: Matt Helsley --- tools/objtool/mcount.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/objtool/mcount.c b/tools/objtool

[RFC][PATCH v5 47/51] objtool: mcount: Merge section mcount flags

2020-06-18 Thread Matt Helsley
One flag is only for relocation sections and the other only for text (not relocation) sections so we can share the same flag and test the section type when we need to. Signed-off-by: Matt Helsley --- tools/objtool/elf.c| 5 ++--- tools/objtool/elf.h| 2 +- tools/objtool/mcount.c | 9

[RFC][PATCH v5 32/51] objtool: mcount: Move sift_rel_mcount out of wrapper file

2020-06-18 Thread Matt Helsley
Now that this function no longer uses any of the old recordmcount wrapper code we can move it out of the wrapper too. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 47 + tools/objtool/recordmcount.h | 50 2

[RFC][PATCH v5 44/51] objtool: mcount: Keep lists locations and relocations

2020-06-18 Thread Matt Helsley
. Signed-off-by: Matt Helsley --- tools/objtool/mcount.c | 133 +++-- 1 file changed, 75 insertions(+), 58 deletions(-) diff --git a/tools/objtool/mcount.c b/tools/objtool/mcount.c index 7fbde6ce6eb8..7d7843f7cd44 100644 --- a/tools/objtool/mcount.c +++ b/tools

[RFC][PATCH v5 36/51] objtool: mcount: Rename to mcount.c

2020-06-18 Thread Matt Helsley
Now that we've converted recordmcount to a subcommand of objtool rename the .c file in order to follow the convention of the other objtool subcmds. Signed-off-by: Matt Helsley --- tools/objtool/Build| 2 +- tools/objtool/{recordmcount.c => mcount.c} | 0 2 files chan

[RFC][PATCH v5 39/51] objtool: mcount: Verify x86 instruction with memcmp()

2020-06-18 Thread Matt Helsley
Instead of hard-coding what amounts to a memcmp() use memcmp to determine if the instruction we wish to replace matches what we expect. This makes the x86 code more like that of, for instance, ARM. Signed-off-by: Matt Helsley --- tools/objtool/mcount.c | 19 ++- 1 file changed

[RFC][PATCH v5 08/51] objtool: mcount: Remove unused fname parameter

2020-06-18 Thread Matt Helsley
The name of the object file being processed is unused in the wrapper's leaf functions so we no longer need to pass it as a parameter. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 4 ++-- tools/objtool/recordmcount.h | 19 --- 2 files changed, 10 insertions

[RFC][PATCH v5 20/51] objtool: mcount: Use objtool ELF to write

2020-06-18 Thread Matt Helsley
te parameters. Note that this patch does not move the associated parts out of the wrapper file. We postpone that cleanup for later so that it's easier to see the changes to the functions rather than obscuring them with the move. Signed-off-by: Matt Helsley --- tools/objtool/

[RFC][PATCH v5 22/51] objtool: mcount: Move has_rel_mcount() and tot_relsize()

2020-06-18 Thread Matt Helsley
The has_rel_mcount() and tot_relsize() helpers are no longer dependent on the ELF wrapper so we can move them. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 26 ++ tools/objtool/recordmcount.h | 33 - 2 files changed, 26

[RFC][PATCH v5 21/51] objtool: mcount: Move nop_mcount()

2020-06-18 Thread Matt Helsley
if they should be turned into no-ops, then calling the arch-specific code. Since none of these use the recordmcount ELF wrappers anymore we can move it out of the wrapper. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 47 + tools/objtool

[RFC][PATCH v5 15/51] objtool: mcount: Replace MIPS offset types

2020-06-18 Thread Matt Helsley
Replace MIPS is_fake_mcount code using Elf_Addr with unsigned long for the offsets. This is consistent with the way that objtool more generally treats offsets and removes the last use of the Elf_Addr wrapper. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.h | 9 +++-- 1 file

[RFC][PATCH v5 23/51] objtool: mcount: Move relocation entry size detection

2020-06-18 Thread Matt Helsley
Move where we detect the size of relocation entries we wish to use into the first loop over the sections. This will allow us to allocate the mcount location and relocation sections before the next loop that collects them. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 8

[RFC][PATCH v5 24/51] objtool: mcount: Only keep ELF file size

2020-06-18 Thread Matt Helsley
Since we're no longer writing to the ELF file mapping and we're not appending to it we don't need to keep more information from the stat structure. At the same time we can give the smaller global variable a better name. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 9

[RFC][PATCH v5 17/51] objtool: mcount: Stop using ehdr in find_section_sym_index

2020-06-18 Thread Matt Helsley
We can use the objtool GElf_Ehdr structure to access ehdr here. This makes the function completely independent of the old recordmcount ELF wrapper. The next step will be to promote it to the C file. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.h | 13 ++--- 1 file changed

[RFC][PATCH v5 18/51] objtool: mcount: Move find_section_sym_index()

2020-06-18 Thread Matt Helsley
This function is no longer dependent upon the old recordmcount ELF wrapper code -- it doesn't use the wrapper's Elf_* types nor does it call wrapped functions. Move it into the C file. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 42 tools

[RFC][PATCH v5 11/51] objtool: mcount: Use symbol structs to find mcount relocations

2020-06-18 Thread Matt Helsley
Rather than open coding symbol name lookups in get_sym_and_*() we rename the structure and use objtool's lookup function to get the symbol name for a relocation. We also change the name of the function to better reflect its purpose. Signed-off-by: Matt Helsley --- tools/objtool/elf.c

[RFC][PATCH v5 05/51] objtool: recordmcount: Search for __mcount_loc before walking the sections

2020-06-18 Thread Matt Helsley
string pointer trick. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 4 tools/objtool/recordmcount.h | 17 +++-- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/tools/objtool/recordmcount.c b/tools/objtool/recordmcount.c index b2c606eb269b

[RFC][PATCH v5 06/51] objtool: recordmcount: Convert do_func() relhdrs

2020-06-18 Thread Matt Helsley
to modify the ELF file -- it only changes the way we walk the ELF sections and do lookups to find the relocations. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.h | 61 +++- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/tools/objtool

[RFC][PATCH v5 01/51] objtool: Factor out reasons to build objtool

2020-06-18 Thread Matt Helsley
a bunch of per-supported-arch ifdef blocks in tools/objtool/Makefile. Signed-off-by: Matt Helsley --- Makefile | 15 --- arch/Kconfig | 23 +++ arch/x86/Kconfig.debug | 1 + lib/Kconfig.debug | 1 + tools/objtool/Makefile | 5 +++-- 5

[RFC][PATCH v5 00/51] objtool: Make recordmcount a subcommand

2020-06-18 Thread Matt Helsley
801.git.mhels...@vmware.com/ Matt Helsley (51): objtool: Factor out reasons to build objtool objtool: Prepare to merge recordmcount objtool: Make recordmcount into mcount subcmd objtool: recordmcount: Start using objtool's elf wrapper objtool: recordmcount: Search for __mcount_loc b

Re: [RFC][PATCH v4 18/32] objtool: mcount: Move nop_mcount()

2020-06-17 Thread Matt Helsley
On Fri, Jun 12, 2020 at 06:05:34PM +0200, Peter Zijlstra wrote: > On Fri, Jun 12, 2020 at 03:26:57PM +0200, Peter Zijlstra wrote: > > On Tue, Jun 02, 2020 at 12:50:11PM -0700, Matt Helsley wrote: > > > +static int nop_mcount(struct section * const rels, > > > +

[tip: objtool/core] objtool: Rename rela to reloc

2020-06-17 Thread tip-bot2 for Matt Helsley
The following commit has been merged into the objtool/core branch of tip: Commit-ID: f1974222634010486c1692e843af0ab11304dd2c Gitweb: https://git.kernel.org/tip/f1974222634010486c1692e843af0ab11304dd2c Author:Matt Helsley AuthorDate:Fri, 29 May 2020 14:01:13 -07:00

[tip: objtool/core] objtool: Add support for relocations without addends

2020-06-17 Thread tip-bot2 for Matt Helsley
The following commit has been merged into the objtool/core branch of tip: Commit-ID: fb414783b65c880606fbc1463e6849f017e60d46 Gitweb: https://git.kernel.org/tip/fb414783b65c880606fbc1463e6849f017e60d46 Author:Matt Helsley AuthorDate:Fri, 29 May 2020 14:01:14 -07:00

Re: [RFC][PATCH 2/3] objtool: Provide elf_write_{insn,reloc}()

2020-06-16 Thread Matt Helsley
> > Doing the change Matt asked for #1, I realized that sec->changed is only > required if we need to rewrite the section header, neither of these two > changes requires that, they already mark the elf data dirty so > elf_update() DTRT. This is really useful information. As long as you're adding the elf->changed flag it might make sense to add this as a comment in the struct section definition or even rename sec->changed to reflect this (e.g. sec->shdr_changed). Cheers, -Matt Helsley

Re: [RFC][PATCH 1/3] objtool: Clean up elf_write() condition

2020-06-15 Thread Matt Helsley
On Fri, Jun 12, 2020 at 04:30:35PM +0200, Peter Zijlstra wrote: > With there being multiple ways to change the ELF data, let's more > concisely track modification. > > Signed-off-by: Peter Zijlstra (Intel) Would it make sense to set the relocation section's "changed" flag in addition to the elf

Re: [RFC][PATCH 0/3] objtool: KCOV vs noinstr

2020-06-13 Thread Matt Helsley
() into NOPs, similar to what recordmcount does. > > I'm hoping the pending objtool-recordmcount patches can also reuse some of > this. This sounds great to me -- I'll have a look through your series and will try rebasing my work on this. Cheers, -Matt Helsley

Re: [RFC][PATCH v4 18/32] objtool: mcount: Move nop_mcount()

2020-06-13 Thread Matt Helsley
On Fri, Jun 12, 2020 at 03:26:56PM +0200, Peter Zijlstra wrote: > On Tue, Jun 02, 2020 at 12:50:11PM -0700, Matt Helsley wrote: > > +static int nop_mcount(struct section * const rels, > > + const char *const txtname) > > +{ > > + struct reloc *reloc; &

Re: [PATCH] capabilities: Introduce CAP_RESTORE

2020-06-11 Thread Matt Helsley
The parent can then pass the *reserved* pidfd into clone3(). The reserved pidfd seamlessly turns into a pidfd reference to the child if clone3() succeeds. If it fails the eservation is still consumed -- a given pidfd reserved for clone3() can only be passed to clone3() and succeed once. Perhaps this scheme could concentrate the need for CAP_SYS_ADMIN to one process so maybe it would obviate the need for CAP_RESTORE. That said, perhaps there's something that prevents implementing such a pidfd or perhaps I have misunderstood what CRIU is doing and this pidfd idea isn't workable. Cheers, -Matt Helsley

Re: [RFC][PATCH v4 02/32] objtool: Make recordmcount into mcount subcmd

2020-06-09 Thread Matt Helsley
On Tue, Jun 09, 2020 at 02:52:07PM -0400, Steven Rostedt wrote: > On Tue, 9 Jun 2020 11:39:51 -0700 > Matt Helsley wrote: > > > > > +ifeq ($(SRCARCH),sparc) > > > > + SUBCMD_MCOUNT := y > > > > > > Is there some arch for which MC

Re: [RFC][PATCH v4 02/32] objtool: Make recordmcount into mcount subcmd

2020-06-09 Thread Matt Helsley
On Tue, Jun 09, 2020 at 10:00:59AM +0100, Julien Thierry wrote: > Hi Matt, > > On 6/2/20 8:49 PM, Matt Helsley wrote: > > Rather than a standalone executable merge recordmcount as a sub command > > of objtool. This is a small step towards cleaning up recordmcount and > &

Re: [RFC][PATCH v4 27/32] objtool: mcount: Generic location and relocation table types

2020-06-09 Thread Matt Helsley
On Tue, Jun 09, 2020 at 12:11:55PM +0530, Kamalesh Babulal wrote: > On 6/3/20 1:20 AM, Matt Helsley wrote: > > Rather than building the exact ELF section data we need and > > avoiding libelf's conversion step, use more GElf types > > and then libelf's elfxx_xlatetof()

Re: [RFC][PATCH v4 01/32] objtool: Prepare to merge recordmcount

2020-06-09 Thread Matt Helsley
On Tue, Jun 09, 2020 at 09:54:33AM +0100, Julien Thierry wrote: > Hi Matt, > > On 6/2/20 8:49 PM, Matt Helsley wrote: > > Move recordmcount into the objtool directory. We keep this step separate > > so changes which turn recordmcount into a subcommand of objtool d

Re: [PATCH v2 2/4] objtool: Move orc outside of check

2020-06-08 Thread Matt Helsley
On Mon, Jun 08, 2020 at 08:12:01AM +0100, Julien Thierry wrote: > Now that the objtool_file can be obtained outside of the check function, > orc generation builtin no longer requires check to explicitly call its > orc related functions. > > Signed-off-by: Julien Thierry Re

Re: [PATCH v2 1/4] objtool: Move object file loading out of check

2020-06-08 Thread Matt Helsley
on check to do the correct setup for them and > explicitly hand the objtool_file to them. > > Signed-off-by: Julien Thierry Reviewed-by: Matt Helsley > --- > tools/objtool/builtin-check.c | 7 ++- > tools/objtool/builtin-orc.c | 8 +++- >

[RFC][PATCH v4 29/32] objtool: mcount: Remove wrapper for ELF relocation type

2020-06-02 Thread Matt Helsley
Remove the last use of the Elf_Rela wrapper by passing the size of the relocations we're dealing with as a parameter. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 4 ++-- tools/objtool/recordmcount.h | 7 ++- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git

[RFC][PATCH v4 04/32] objtool: recordmcount: Search for __mcount_loc before walking the sections

2020-06-02 Thread Matt Helsley
string pointer trick. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 4 tools/objtool/recordmcount.h | 17 +++-- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/tools/objtool/recordmcount.c b/tools/objtool/recordmcount.c index b2c606eb269b

[RFC][PATCH v4 02/32] objtool: Make recordmcount into mcount subcmd

2020-06-02 Thread Matt Helsley
recordmcount to be more easily readable and remove recordmcount's crude accessor wrapping code. Signed-off-by: Matt Helsley --- Documentation/dontdiff | 2 +- Documentation/trace/ftrace.rst | 6 ++-- Makefile| 9 -- arch/arm64/include/asm/ftrace.h | 2

[RFC][PATCH v4 28/32] objtool: mcount: Move sift_rel_mcount out of wrapper file

2020-06-02 Thread Matt Helsley
Now that this function no longer uses any of the old recordmcount wrapper code we can move it out of the wrapper too. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 47 + tools/objtool/recordmcount.h | 50 2

[RFC][PATCH v4 32/32] objtool: mcount: Rename

2020-06-02 Thread Matt Helsley
Now that we've converted recordmcount to a subcommand of objtool rename the .c file in order to follow the convention of the other objtool subcmds. Signed-off-by: Matt Helsley --- tools/objtool/Build| 2 +- tools/objtool/{recordmcount.c => mcount.c} | 0 2 files chan

[RFC][PATCH v4 31/32] objtool: mcount: Remove endian wrappers

2020-06-02 Thread Matt Helsley
Now that they're no longer used we can remove these endian wrappers. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 63 1 file changed, 63 deletions(-) diff --git a/tools/objtool/recordmcount.c b/tools/objtool/recordmcount.c index

[RFC][PATCH v4 27/32] objtool: mcount: Generic location and relocation table types

2020-06-02 Thread Matt Helsley
the recordmcount wrapper. The next patch will move it out of the wrapper. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 44 +++-- tools/objtool/recordmcount.h | 120 ++- 2 files changed, 59 insertions(+), 105 deletions(-) diff --git a/tools/objtool

[RFC][PATCH v4 06/32] objtool: mcount: Remove unused fname parameter

2020-06-02 Thread Matt Helsley
The name of the object file being processed is unused in the wrapper's leaf functions so we no longer need to pass it as a parameter. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 4 ++-- tools/objtool/recordmcount.h | 19 --- 2 files changed, 10 insertions

[RFC][PATCH v4 08/32] objtool: mcount: Walk objtool Elf structs in find_secsym_ndx

2020-06-02 Thread Matt Helsley
Rather than using indices into raw ELF32/64 tables mapped for the wrapper, use the objtool functions to find the a suitable symbol in the given text section. Also take advantage of this commit to rename the function to something that reads more easily. Signed-off-by: Matt Helsley --- tools

[RFC][PATCH v4 13/32] objtool: mcount: Move is_fake_mcount()

2020-06-02 Thread Matt Helsley
Promote the now-bit-independent is_fake_mcount() out of the old recordmcount ELF wrapper. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 48 +++--- tools/objtool/recordmcount.h | 50 2 files changed, 45 insertions

[RFC][PATCH v4 05/32] objtool: recordmcount: Convert do_func() relhdrs

2020-06-02 Thread Matt Helsley
to modify the ELF file -- it only changes the way we walk the ELF sections and do lookups to find the relocations. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.h | 62 +++- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/tools/objtool

[RFC][PATCH v4 18/32] objtool: mcount: Move nop_mcount()

2020-06-02 Thread Matt Helsley
if they should be turned into no-ops, then calling the arch-specific code. Since none of these use the recordmcount ELF wrappers anymore we can move it out of the wrapper. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 47 + tools/objtool

[RFC][PATCH v4 12/32] objtool: mcount: Replace MIPS offset types

2020-06-02 Thread Matt Helsley
Replace MIPS is_fake_mcount code using Elf_Addr with unsigned long for the offsets. This is consistent with the way that objtool more generally treats offsets and removes the last use of the Elf_Addr wrapper. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.h | 9 +++-- 1 file

[RFC][PATCH v4 17/32] objtool: mcount: Use objtool ELF to write

2020-06-02 Thread Matt Helsley
unctions rather than obscuring them with the move. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 161 --- tools/objtool/recordmcount.h | 132 +--- 2 files changed, 55 insertions(+), 238 deletions(-) diff --git a/tools/objtool/re

[RFC][PATCH v4 21/32] objtool: mcount: Only keep ELF file size

2020-06-02 Thread Matt Helsley
Since we're no longer writing to the ELF file mapping and we're not appending to it we don't need to keep more information from the stat structure. At the same time we can give the smaller global variable a better name. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 9

[RFC][PATCH v4 10/32] objtool: mcount: Walk relocation lists

2020-06-02 Thread Matt Helsley
Rather than walk the section tables using the old recordmcount mapping of the ELF file, walk the section list provided by objtool's ELF code. This removes the last use of of the Elf_r_sym wrapper so we remove that too. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 10

[RFC][PATCH v4 23/32] objtool: mcount: Remove unused file mapping

2020-06-02 Thread Matt Helsley
data and call instruction offsets. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 99 +++- tools/objtool/recordmcount.h | 4 +- 2 files changed, 9 insertions(+), 94 deletions(-) diff --git a/tools/objtool/recordmcount.c b/tools/objtool

[RFC][PATCH v4 19/32] objtool: mcount: Move has_rel_mcount() and tot_relsize()

2020-06-02 Thread Matt Helsley
The has_rel_mcount() and tot_relsize() helpers are no longer dependent on the ELF wrapper so we can move them. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 25 + tools/objtool/recordmcount.h | 33 - 2 files changed, 25

[RFC][PATCH v4 09/32] objtool: mcount: Use symbol structs to find mcount relocations

2020-06-02 Thread Matt Helsley
Rather than open coding symbol name lookups in get_sym_and_*() we rename the structure and use objtool's lookup function to get the symbol name for a relocation. We also change the name of the function to better reflect its purpose. Signed-off-by: Matt Helsley --- tools/objtool/elf.c

[RFC][PATCH v4 24/32] objtool: mcount: Reduce usage of _size wrapper

2020-06-02 Thread Matt Helsley
Use a new loc_size parameter to append_func() rather than use the wrapper's _size macro directly. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.h | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h

[RFC][PATCH v4 25/32] objtool: mcount: Move mcount_adjust out of wrapper

2020-06-02 Thread Matt Helsley
of the variable's type inside the wrapper -- we can just use a regular int. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 12 +--- tools/objtool/recordmcount.h | 5 - 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/objtool/recordmcount.c b/tools/objtool

[RFC][PATCH v4 15/32] objtool: mcount: Move find_section_sym_index()

2020-06-02 Thread Matt Helsley
This function is no longer dependent upon the old recordmcount ELF wrapper code -- it doesn't use the wrapper's Elf_* types nor does it call wrapped functions. Move it into the C file. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 41 tools

[RFC][PATCH v4 20/32] objtool: mcount: Move relocation entry size detection

2020-06-02 Thread Matt Helsley
Move where we detect the size of relocation entries we wish to use into the first loop over the sections. This will allow us to allocate the mcount location and relocation sections before the next loop that collects them. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 8

[RFC][PATCH v4 14/32] objtool: mcount: Stop using ehdr in find_section_sym_index

2020-06-02 Thread Matt Helsley
We can use the objtool GElf_Ehdr structure to access ehdr here. This makes the function completely independent of the old recordmcount ELF wrapper. The next step will be to promote it to the C file. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.h | 13 ++--- 1 file changed

[RFC][PATCH v4 11/32] objtool: mcount: Move get_mcountsym

2020-06-02 Thread Matt Helsley
Now that it's been stripped of using the old recordmcount ELF wrapper get_mcountsym() is ready to be promoted out of the double-included wrapper header. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 16 tools/objtool/recordmcount.h | 19 --- 2

[RFC][PATCH v4 16/32] objtool: mcount: Restrict using ehdr in append_func()

2020-06-02 Thread Matt Helsley
and those will get replaced later. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h index 98cf9eea6074..7ebc617fb3a6 100644 --- a/tools/objtool

[RFC][PATCH v4 26/32] objtool: mcount: Pre-allocate new ELF sections

2020-06-02 Thread Matt Helsley
Rather than allocating the ELF sections after collecting the mcount locations and building the relocation entries, create the empty sections beforehand. This has the benefit of removing the memcpy() and just using the resulting libgelf buffers directly. Signed-off-by: Matt Helsley --- tools

[RFC][PATCH v4 22/32] objtool: mcount: Use ELF header from objtool

2020-06-02 Thread Matt Helsley
The ELF header is the very first structure in an ELF file. Rather than cast it from the file mapping we use the ELF header extracted via objtool's ELF code. This is the last usage of the open-coded mapping of the ELF file which we will remove in a later step. Signed-off-by: Matt Helsley

[RFC][PATCH v4 30/32] objtool: mcount: Remove wrapper double-include trick

2020-06-02 Thread Matt Helsley
the wrapped naming. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 122 -- tools/objtool/recordmcount.h | 142 --- 2 files changed, 116 insertions(+), 148 deletions(-) delete mode 100644 tools/objtool/recordmcount.h diff

[RFC][PATCH v4 00/32] objtool: Make recordmcount a subcommand

2020-06-02 Thread Matt Helsley
ine -rc Matt Helsley (32): objtool: Prepare to merge recordmcount objtool: Make recordmcount into mcount subcmd objtool: recordmcount: Start using objtool's elf wrapper objtool: recordmcount: Search for __mcount_loc before walking the sections objtool: recordmcount: Convert do_f

[RFC][PATCH v4 03/32] objtool: recordmcount: Start using objtool's elf wrapper

2020-06-02 Thread Matt Helsley
-- the libelf/objtool way and the old recordmcount wrapper way which avoids these extra data structures by using indices, offsets, and pointers into the mmapped ELF file. Subsequent patches will convert from the old recordmcount accessors to the libelf/objtool accessors. Signed-off-by: Matt Helsley

[RFC][PATCH v4 01/32] objtool: Prepare to merge recordmcount

2020-06-02 Thread Matt Helsley
Move recordmcount into the objtool directory. We keep this step separate so changes which turn recordmcount into a subcommand of objtool don't get obscured. Signed-off-by: Matt Helsley --- Documentation/trace/ftrace-design.rst | 4 ++-- Documentation/trace/ftrace.rst | 2

[RFC][PATCH v4 07/32] objtool: mcount: Use libelf for section header names

2020-06-02 Thread Matt Helsley
-by: Matt Helsley --- tools/objtool/elf.c | 3 +- tools/objtool/elf.h | 1 + tools/objtool/recordmcount.c | 2 +- tools/objtool/recordmcount.h | 89 ++-- 4 files changed, 37 insertions(+), 58 deletions(-) diff --git a/tools/objtool/elf.c b/tools

  1   2   3   4   >