Commit Graph

24 Commits

Author SHA1 Message Date
Bruno Loreto
4c40c3ff4b Making kpatch-build compatible with custom gcc names
After changing the gcc name in a linux tree to gcc72, kpatch-build failed to
produce hotpatches with the error message "ERROR: no changed objects found."

This is due to a wrapper script called kpatch-gcc, called while kpatch-build
builds the kernel, which checks if the compiler name matches exactly gcc,
failing the check when comparing to gcc72, and thus not producing the expected
file changed_objs containing the list of changed objects.

This commit fixes this issue by loosening the check on the gcc name.

Signed-off-by: Bruno Loreto <loretob@amazon.com>
Reviewed-by: Bjoern Doebel <doebel@amazon.com>
Reviewed-by: Amit Shah <aams@amazon.com>
Reviewed-by: Pawel Wieczorkiewicz <wipawel@amazon.com>
2019-05-09 19:15:11 +02:00
Joe Lawrence
fd9806b152 kpatch-gcc: use relative path when filtering objects to ignore
When building out-of-tree modules, gcc may be passed full source
pathnames (like /home/user/testmod/testmod.c).  Adjust the filepath
filtering in kpatch-gcc to match against files relative to the
KPATCH_GCC_SRCDIR / kpatch-build SRCDIR prefix.

Fixes: #941
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2019-02-15 10:10:24 -05:00
Paul Dagnelie
51a8fad34f Add support for building out-of-tree modules 2018-11-09 08:22:39 -08:00
Joe Lawrence
9f7c76b9c1 kpatch-build: add lib/ files to kpatch-gcc skip-list
None of the lib/* file are built with fentry calls, so we can't patch
them.  Add these files to the list that kpatch-gcc skips.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2018-06-13 13:53:19 -04:00
Artem Savkov
cedcd2314b Prepare for built-in.o -> built-in.a rename
for-next branch of kbuild repo contains a "kbuild: rename built-in.o to
built-in.a" which renames all built-in.o instances. Filter on both .o
and .a in kpatch-gcc/kpatch-build to be prepared for this change.

Fixes #800.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-03-20 10:46:50 +01:00
Juerg Haefliger
757bc71d2b kpatch-build: Add additional debug modes
By specifying -d, --debug multiple times, the following additional
debug modes can be enabled:
  -d -d:       Writes everything that is written to the logfile also to
               stdout.
  -d -d -d:    Same as '-d -d' plus sets 'xtrace' in kpatch-build.
  -d -d -d -d: Same as '-d -d -d' plus sets 'xtrace' in kpatch-gcc.

Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
2017-11-17 15:04:11 +01:00
Juerg Haefliger
862327db3e kpatch-build: Fix indentation
Replace stray spaces with tabs, except in the usage output where tabs
don't make much sense.

Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
2017-11-09 15:03:19 +01:00
Simon Ruderich
08fa04bb0d kpatch, kpatch-build, kpatch-gcc: quote all variables
Without proper quoting kpatch fails if the argument contains spaces, the
other scripts might be affected as well.

Not all new quotes are strictly necessary but they were added for
consistency with the existing code and to prevent copy & paste errors in
the future.

There's one conversion which is not straight-forward:

-       grepname=$grepname\\\.o
+       grepname="$grepname\.o"

There are different quoting rules with and without the double quotes.
2017-10-07 10:12:40 +02:00
chen xiaoguang
ec98604f80 kpatch: fix kpatch-build matching changed object bug
When there is a ".." in the source object path, kpatch-gcc can't handle
it correctly.  kpatch-gcc is called for objects which were recompiled
and writes the changed objects to "changed_objs". But if the path of the
input obj is something like:

  arch/x86/kvm/../../../virt/kvm/.tmp_kvm_main.o

then it will fall into the "*.*.o" branch of the kpatch-gcc case
statement and kpatch-build will report "ERROR: no changed objects
found."

Use Joe's suggestion to revert d526805619 ("kpatch-gcc: update
ignorelist to avoid foo/.lib_exports.o files") and instead add a
"*/.lib_exports.o" pattern.

Fixes #735.

[ cleaned up changelog - jpoimboe@redhat.com ]

Cc: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: chen xiaoguang <xiaoggchen@tencent.com>
2017-09-13 21:08:54 -05:00
Josh Poimboeuf
339938c0a9 kpatch-build: clarify ppc64le comments
Clarify some of the comment wording in the new ppc64le code.
2017-07-27 15:23:26 -05:00
Kamalesh Babulal
c14e6e9118 kpatch-build: Add PPC64le livepatch support
This patch adds support for livepatch hook based module
creation for PPC64le. It introduces PPC64le architecture
bits:
- Add relocation type of R_PPC64_ADDR64 while parsing powerpc ELF.
- Introduce .toc sections mainpulation.
- Skip kpatch specific details for livepatch hook.

Also remove the definition of rela_insn() for powerpc. The only
call site is been guarded by #ifdef x86.

Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2017-07-26 14:40:37 +05:30
Joe Lawrence
d526805619 kpatch-gcc: update ignorelist to avoid foo/.lib_exports.o files
Upstream kernel commit 7f2084fa55e6 ("[kbuild] handle exports in lib-y
objects reliably") (v4.9+) added temporary dummy .lib_exports.o objects
to the kernel build.  As these ephemeral files don't contain any code,
update the kpatch-gcc glob pattern to ignore them.

(glob pattern suggested by flaming-toast)

Fixes #686.
2017-03-10 10:26:06 -05:00
Josh Poimboeuf
1330b4a3e5 kpatch-build: fix 'undefined reference to kpatch_shadow_*' errors
When building the patched version of the kernel, vmlinux has to be
linked with the '--warn-unresolved-symbols' linker flag.  Otherwise the
link will fail if the patch uses kpatch-specific symbols like
kpatch_shadow_alloc() and friends.

As of upstream Linux commit b36fad65d61f ("kbuild: Initialize exported
variables"), LDFLAGS_vmlinux= no longer works from the command line,
resulting in '--warn-unresolved-symbols' no longer getting set.

Instead we can use kpatch-gcc to pass the flag to the linker.

Fixes #627.
2016-12-05 20:22:11 -06:00
Martin Carroll
145d1289dc kpatch-build: do not assume that TEMPDIR is unexported on entry to script
The user's environment might have TEMPDIR exported.  If so, then kpatch-build
dies with a bogus "invalid ancestor" error. If you turn those bogus errors into
warnings, then the script goes on to incorrectly put into the generated .ko file
every single function that was compiled in the *original* kernel build, thereby
producing an immense .ko file with more than 64k sections that the linux kernel
cannot load.  This fix makes sure that TEMPDIR is unexported on the build of the
original kernel.  Actually, this fix uses a separate KPATCH_GCC_TEMPDIR variable,
so that if the kernel build is interrupted, the cleanup function in the kpatch-kbuild
script will still have TEMPDIR set correctly.

Signed-off-by: Martin Carroll <martin.carroll@alcatel-lucent.com>
2016-07-25 11:02:37 -04:00
Josh Poimboeuf
d378b245e5 kpatch-gcc: add libstub to ignore list
The firmware libstub library isn't a part of the proper runtime kernel
and can be safely ignored.

Fixes: #518
2015-10-28 11:39:55 -05:00
Josh Poimboeuf
a1d6b0d00e kpatch-gcc: update vdso location for newer kernels
With recent kernels, the vdso code has moved from arch/x86/vdso to
arch/x86/entry/vdso.

Fixes: #530
2015-10-28 11:27:15 -05:00
Li Bin
ef76bd9cc9 kpatch-build: support adding new files in patch
Geting the changed objects from the patched dir, in order to support
adding new files in patch.

Signed-off-by: Li Bin <huawei.libin@huawei.com>
2015-10-16 17:26:24 +08:00
Jessica Yu
09c39932b1 kpatch-gcc: for module patches, copy module to temp dir
For patches involving modules, copy the original module(s) to
TEMPDIR so that create-diff-object can create the correct lookup
tables
2014-10-06 01:05:36 -07:00
Josh Poimboeuf
f5dbd7816e kpatch-gcc: skip vdso files
vdso files aren't kpatch-compatible, and give errors like the following:

    ERROR: invalid ancestor arch/x86/vdso/vdso32-sysenter.so.dbg for arch/x86/vdso/vdso32/sysenter.o
2014-09-15 11:17:37 -05:00
Josh Poimboeuf
5cce81f49b kpatch-gcc: properly quote arguments
Fixes an error when the following is an argument to gcc:

'-DIPATH_IDSTR="QLogic' kernel.org 'driver"'

gcc: error: kernel.org: No such file or directory
gcc: error: driver": No such file or directory
2014-09-15 11:17:37 -05:00
Josh Poimboeuf
7b4ee86197 kpatch-gcc: fix for .tmp_* objects on RHEL 7
On RHEL 7 I see the following error when trying to patch meminfo.o:

    cp: cannot stat ‘/home/user/.kpatch/obj/fs/proc/.tmp_meminfo.o’: No such file or directory

It turns out that on RHEL 7, a given object foo.o is compiled as
.tmp_foo.o before then being linked as foo.o.  I have no idea why.  The
fix is to record .tmp_foo.o as foo.o in the changed_objs file.
2014-08-12 21:21:53 -05:00
Josh Poimboeuf
1b9868ed33 kpatch-gcc: exclude system_certificates.o
Fixes the following issue when running kpatch-build against the latest
upstream kernel:

    system_certificates.o: no changed functions were found
2014-08-08 14:18:46 -05:00
Josh Poimboeuf
e7cf064c62 kpatch-gcc: split up object exclusion list 2014-08-08 14:18:27 -05:00
Seth Jennings
b98fafcfb2 restructure building process
Right now, we do three build passes: one to build the original tree
(full) build, one to build the patch tree (diff build), then one to
rebuild original objects that where changed by the patch (diff build).

This is going to be a problem when we try to support (near) full tree
rebuilds due to changes in commonly included header files.

This commit changes the build process to intercept calls to gcc by make
using the CROSS_COMPILE environment variable and, during the patched
build phase, copies the original object for any object that is about to
rebuilt due to a change.

This reduces the number of build passes to the minimum possible (two).

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-07 17:25:05 -05:00