Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-22 Thread Chen Zhongjin
On 2024/9/12 0:20, Josh Poimboeuf wrote: ... Do not get me wrong. I do not expect that the upstream variant would be feature complete from the beginning. I just want to get a picture how far it is. The code will be maintained only when it would have users. And it would have users only when it

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-17 Thread Petr Mladek
On Wed 2024-09-11 09:20:05, Josh Poimboeuf wrote: > Hi Petr, > > Thank you for trying it out and doing the research to compare it with > kpatch-build. > > On Wed, Sep 11, 2024 at 03:27:27PM +0200, Petr Mladek wrote: > > Without -ffunction-sections -fdata-sections: > > > > $> time make -j8 >

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-13 Thread Josh Poimboeuf
On Fri, Sep 13, 2024 at 10:39:18AM -0400, Joe Lawrence wrote: > and now a happy kernel build and boot. Thanks! > A klp-build of the usual cmdline.patch succeeds, however it generates > some strange relocations: > > Relocation section '.rela.text' at offset 0x238 contains 6 entries: > Off

Re: [External] Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-13 Thread A K M Fazla Mehrab .
Hi Josh, On Thu, Sep 12, 2024 at 9:06 AM Song Liu wrote: [...] > > Red Hat (and Meta?) will start using it as soon as x86 support is ready, > > because IBT/LTO support is needed, which kpatch-build can't handle. > > While we (Meta) do have a workaround in kpatch to build livepatch for > kernels b

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-13 Thread Joe Lawrence
On Thu, Sep 12, 2024 at 09:44:04AM -0400, Joe Lawrence wrote: > On Wed, Sep 11, 2024 at 12:39:42AM -0700, Josh Poimboeuf wrote: > > On Mon, Sep 02, 2024 at 08:59:43PM -0700, Josh Poimboeuf wrote: > > > Hi, > > > > > > Here's a new way to build livepatch modules called klp-build. > > > > > > I sta

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-12 Thread Song Liu
Hi Josh, On Wed, Sep 11, 2024 at 9:20 AM Josh Poimboeuf wrote: [...] > > Do not get me wrong. I do not expect that the upstream variant would > > be feature complete from the beginning. I just want to get a picture > > how far it is. The code will be maintained only when it would have > > users.

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-12 Thread Joe Lawrence
On Wed, Sep 11, 2024 at 12:39:42AM -0700, Josh Poimboeuf wrote: > On Mon, Sep 02, 2024 at 08:59:43PM -0700, Josh Poimboeuf wrote: > > Hi, > > > > Here's a new way to build livepatch modules called klp-build. > > > > I started working on it when I realized that objtool already does 99% of > > the

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-11 Thread Josh Poimboeuf
Hi Petr, Thank you for trying it out and doing the research to compare it with kpatch-build. On Wed, Sep 11, 2024 at 03:27:27PM +0200, Petr Mladek wrote: > Without -ffunction-sections -fdata-sections: > > $> time make -j8 > real0m58.719s > user3m25.925s > sys

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-11 Thread Petr Mladek
On Mon 2024-09-02 20:59:43, Josh Poimboeuf wrote: > Hi, > > Here's a new way to build livepatch modules called klp-build. > > I started working on it when I realized that objtool already does 99% of > the work needed for detecting function changes. > > This is similar in concept to kpatch-build,

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-11 Thread Josh Poimboeuf
On Mon, Sep 02, 2024 at 08:59:43PM -0700, Josh Poimboeuf wrote: > Hi, > > Here's a new way to build livepatch modules called klp-build. > > I started working on it when I realized that objtool already does 99% of > the work needed for detecting function changes. > > This is similar in concept to

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-09 Thread Song Liu
On Mon, Sep 9, 2024 at 2:19 PM Josh Poimboeuf wrote: > > On Sat, Sep 07, 2024 at 10:04:25PM -0700, Song Liu wrote: > > I think gcc doesn't complain, but clang does: > > > > $ cat ttt.c > > static inline void ret(void) > > { > > return; > > } > > > > int main(void) > > { > > return 0; > > } > >

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-09 Thread Josh Poimboeuf
On Sat, Sep 07, 2024 at 10:04:25PM -0700, Song Liu wrote: > I think gcc doesn't complain, but clang does: > > $ cat ttt.c > static inline void ret(void) > { > return; > } > > int main(void) > { > return 0; > } Ah... That's probably why the kernel adds "__maybe_unused" to its inline macro (w

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-07 Thread Song Liu
On Sat, Sep 7, 2024 at 1:14 PM Josh Poimboeuf wrote: > > On Sat, Sep 07, 2024 at 10:43:10AM -0700, Song Liu wrote: > > clang gives the following: > > > > elf.c:102:1: error: unused function '__sym_remove' > > [-Werror,-Wunused-function] > > 102 | INTERVAL_TREE_DEFINE(struct symbol, node, unsign

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-07 Thread Josh Poimboeuf
On Sat, Sep 07, 2024 at 10:43:10AM -0700, Song Liu wrote: > clang gives the following: > > elf.c:102:1: error: unused function '__sym_remove' [-Werror,-Wunused-function] > 102 | INTERVAL_TREE_DEFINE(struct symbol, node, unsigned long, > __subtree_last, > | > ^

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-07 Thread Song Liu
On Fri, Sep 6, 2024 at 11:46 PM Josh Poimboeuf wrote: > > On Tue, Sep 03, 2024 at 10:32:00AM -0700, Song Liu wrote: > > +++ w/tools/objtool/elf.c > > @@ -468,10 +468,8 @@ static void elf_add_symbol(struct elf *elf, > > struct symbol *sym) > > * > > * TODO: is this still true? > >

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-07 Thread Joe Lawrence
On Fri, Sep 06, 2024 at 06:47:06PM -0700, Josh Poimboeuf wrote: > > Normally I build objtool with > > make tools/objtool > > or just > > make > > Those use the objtool Makefile without all the extra kernel flags. > > How do you normally build objtool? > Usually as part of the kernel buil

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-06 Thread Josh Poimboeuf
On Tue, Sep 03, 2024 at 10:32:00AM -0700, Song Liu wrote: > +++ w/tools/objtool/elf.c > @@ -468,10 +468,8 @@ static void elf_add_symbol(struct elf *elf, > struct symbol *sym) > * > * TODO: is this still true? > */ > -#if 0 > - if (sym->type == STT_NOTYPE && !sym->le

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-06 Thread Josh Poimboeuf
On Fri, Sep 06, 2024 at 09:56:06AM -0400, Joe Lawrence wrote: > A few minor build complaints on my system: > > $ make tools/objtool/check.o > CALLscripts/checksyscalls.sh > DESCEND objtool > INSTALL libsubcmd_headers > CC /home/jolawren/src/linux/tools/objtool/check.o >

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-06 Thread Josh Poimboeuf
On Fri, Sep 06, 2024 at 05:01:51PM -0400, Joe Lawrence wrote: > On Fri, Sep 06, 2024 at 10:00:08AM -0700, Josh Poimboeuf wrote: > > On Fri, Sep 06, 2024 at 09:56:06AM -0400, Joe Lawrence wrote: > > > In the case of klp-diff.c, adding #include will provide the > > > memmem prototype. For both file

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-06 Thread Joe Lawrence
On Fri, Sep 06, 2024 at 10:00:08AM -0700, Josh Poimboeuf wrote: > On Fri, Sep 06, 2024 at 09:56:06AM -0400, Joe Lawrence wrote: > > In the case of klp-diff.c, adding #include will provide the > > memmem prototype. For both files, I needed to #define _GNU_SOURCE for > > that prototype though. > >

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-06 Thread Josh Poimboeuf
On Fri, Sep 06, 2024 at 09:56:06AM -0400, Joe Lawrence wrote: > In the case of klp-diff.c, adding #include will provide the > memmem prototype. For both files, I needed to #define _GNU_SOURCE for > that prototype though. > > For the other complaint, I just set struct instruction *dest_insn = NUL

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-05 Thread Song Liu
On Thu, Sep 5, 2024 at 12:13 AM Josh Poimboeuf wrote: > > On Wed, Sep 04, 2024 at 09:14:00PM -0700, Josh Poimboeuf wrote: > > > + if (!!nr_objs) { > ^^ > oops > > Fixed version: The fixed version works for the following cases with gcc-12: 1. no BTF, no IBT; 2. with BT

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-05 Thread Josh Poimboeuf
On Wed, Sep 04, 2024 at 09:14:00PM -0700, Josh Poimboeuf wrote: > + if (!!nr_objs) { ^^ oops Fixed version: diff --git a/scripts/livepatch/module.c b/scripts/livepatch/module.c index 101cabf6b2f1..2908999efa21 100644 --- a/scripts/livepatch/module.c +++ b/scripts/live

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-04 Thread Josh Poimboeuf
On Wed, Sep 04, 2024 at 01:59:51PM -0700, Josh Poimboeuf wrote: > On Wed, Sep 04, 2024 at 01:23:55PM -0700, Song Liu wrote: > > [ 7285.260195] livepatch: nothing to patch! This seems to be tripping up on an awful hack I had for silencing modpost warnings. Apparently it doesn't work with your conf

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-04 Thread Song Liu
On Wed, Sep 4, 2024 at 1:59 PM Josh Poimboeuf wrote: > > On Wed, Sep 04, 2024 at 01:23:55PM -0700, Song Liu wrote: > > Hi Josh, > > > > Thanks for the fix! The gcc kernel now compiles. > > > > I am now testing with the attached config file (where I disabled > > CONFIG_DEBUG_INFO_BTF), with the att

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-04 Thread Josh Poimboeuf
On Wed, Sep 04, 2024 at 01:23:55PM -0700, Song Liu wrote: > Hi Josh, > > Thanks for the fix! The gcc kernel now compiles. > > I am now testing with the attached config file (where I disabled > CONFIG_DEBUG_INFO_BTF), with the attached patch. Probably a good idea to disable BTF as I think it's ca

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-04 Thread Josh Poimboeuf
On Tue, Sep 03, 2024 at 11:37:39PM -0700, Josh Poimboeuf wrote: > On Tue, Sep 03, 2024 at 10:26:02PM -0700, Song Liu wrote: > > Hi Josh, > > > > I have attached the config I used for LLVM and gcc. > > !IBT is triggering the ORC bug. This should fix it: Also a CONFIG_MODVERSIONS fix: diff --git

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-03 Thread Josh Poimboeuf
On Tue, Sep 03, 2024 at 10:26:02PM -0700, Song Liu wrote: > Hi Josh, > > I have attached the config I used for LLVM and gcc. !IBT is triggering the ORC bug. This should fix it: diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 518c70b8db50..643bfba65d48 100755 --- a/scripts/l

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-03 Thread Josh Poimboeuf
On Tue, Sep 03, 2024 at 10:32:00AM -0700, Song Liu wrote: > Hi Josh, > > Thanks for the patchset! We really need this work so that we can undo our > hack for LTO enabled kernels. > > On Mon, Sep 2, 2024 at 9:00 PM Josh Poimboeuf wrote: > > > > Hi, > > > > Here's a new way to build livepatch modu

Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

2024-09-03 Thread Song Liu
Hi Josh, Thanks for the patchset! We really need this work so that we can undo our hack for LTO enabled kernels. On Mon, Sep 2, 2024 at 9:00 PM Josh Poimboeuf wrote: > > Hi, > > Here's a new way to build livepatch modules called klp-build. > > I started working on it when I realized that objtool