Commit Graph

1560 Commits

Author SHA1 Message Date
Kamalesh Babulal
5b690b28bf create-diff-object.c: Extend is_bundleable()
GCC puts the constant variable requiring relocation into .data.rel. or
.data.rel.ro depending upon the bind type of the symbol. Extend
is_bundledable() to check these .data sections too.

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2018-08-06 14:09:43 +05:30
Joe Lawrence
8eb1d23713
Merge pull request #897 from sm00th/mrecord-mcount
create-diff-object: -mcount-record support
2018-07-27 09:14:53 -04:00
Artem Savkov
41f025d392 Include mrecord-mcount unit tests
Update objs-repo pointer to include new unit tests.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-07-26 16:51:28 +02:00
Artem Savkov
19c4b52105 create-diff-object: -mcount-record support
4.18 adds -mcount-record to KBUILD_FLAGS when supported by the compiler.
This results in most of kpatch_create_mcount_sections()'s work being
already done, so we can at least skip the last part of it that updates
the first instruction in patched functions.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-07-26 16:51:24 +02:00
Joe Lawrence
13d8267a0d
Merge pull request #896 from buytenh/ubuntu-fixes
ubuntu fixes
2018-07-25 13:13:59 -04:00
Lennert Buytenhek
9ce3e3c090 readme: explicitly include elfutils dependency for Ubuntu
Without this, kpatch-build bombs out because it cannot find eu-readelf.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
2018-07-25 14:59:56 +03:00
Lennert Buytenhek
932e0377bd kpatch-build: Ubuntu signed/unsigned kernel image package fix
In Ubuntu 18.04 LTS (but not in 16.04 LTS), the "linux" source package
no longer builds the "linux-image-*" binary kernel image packages
directly, but instead, it produces the "linux-image-unsigned-*" binary
packages, and the "linux-signed" source package then produces the
(signed) "linux-image-*" binary packages from the unsigned binaries.

This means that querying the target kernel's linux-image-* package for
its source package will yield a source package that is just a wrapper,
and does not actually contain the kernel source code.

Deal with this by removing the "-signed" substring from the kernel
source package name if it is present.  This makes kpatch-build work
on Ubuntu 18.04.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
2018-07-25 14:59:56 +03:00
Joe Lawrence
b974770197
Merge pull request #881 from sm00th/gcc8-opts
gcc8 fixes
2018-07-18 08:56:54 -04:00
Joe Lawrence
08cc21025a
Merge pull request #894 from jpoimboe/fix-clean-cache
kpatch-build: fix clean_cache
2018-07-18 08:54:35 -04:00
Josh Poimboeuf
0655ca50b8 kpatch-build: fix clean_cache
Commit d86c1113cc ("kpatch-build: less aggressive clean_cache()")
broke clean_cache().  Instead of expanding the wildcard, it tries to
delete a file named '*'.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2018-07-17 15:43:43 -05:00
Artem Savkov
7cb5baccde Include gcc8 unit-tests
Update submodule pointer to include new gcc8 unit tests.

This update also includes unit-test for https://github.com/dynup/kpatch/pull/892

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-07-13 09:39:26 +02:00
Artem Savkov
61839832ed create-diff-object: propagate ignore.functions to children
Add child symbols to .kpatch.ignore.functions in case their parents are
added to the list.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-07-13 09:39:26 +02:00
Artem Savkov
2ac1387701 create-diff-object: add .text.hot to the list of bundleable functions
According to gcc8's man pages gcc can put functions into .text.unlikely
or .text.hot subfunctions during optimization. Add ".text.hot" to the
list of bundleable functions in is_bundleable().

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-07-13 09:39:26 +02:00
Artem Savkov
35cc6ff016 create-diff-object: allow changing subsections
gcc8 can place functions to .text.unlikely and .text.hot subsections
during optimizations. Allow symbols to change subsections instead of
failing.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-07-13 09:39:21 +02:00
Artem Savkov
246c6e2ae7 create-diff-object: propagate child symbol changes
Propagate child symbol changes to it's parent.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-07-13 09:38:15 +02:00
Joe Lawrence
cd352cf8a8
Merge pull request #892 from kamalesh-babulal/addr_align
create-diff-object: Relax sh_addralign check for .text sections
2018-07-11 14:31:47 -04:00
Artem Savkov
73a278c2b6 create-diff-object: child symbol skips
Skip profiling calls checks for child symbols and don't include them in
output or .kpatch.funcs.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-07-11 09:57:54 +02:00
Artem Savkov
bd2589530c create-diff-object: add symbol relations
Add a function that would detect parent/child symbol relations. So far
it only supports .cold.* symbols as children.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-07-11 09:57:31 +02:00
Kamalesh Babulal
09fdb0772d create-diff-object: Relax sh_addralign check for .text sections
.text section addralign value might change between original and
patched .o files, for a loop() such as:

for (i = 0; i < sections_per_block; i++) {
	remove_memory(nid, base, MIN_MEMORY_BLOCK_SIZE);
	base += MIN_MEMORY_BLOCK_SIZE;
}

On ppc64le, which translate to:

  f0:   78 1b 7b 7c     mr      r27,r3
  f4:   6c 00 9d 40     ble     cr7,160 <pseries_remove_memblock+0x158>
  f8:   ff ff 9c 3b     addi    r28,r28,-1
  fc:   38 00 a1 fb     std     r29,56(r1)
 100:   00 01 bf 3f     addis   r29,r31,256
 104:   08 c2 9c 7b     rldic   r28,r28,24,8
 108:   14 ea 9c 7f     add     r28,r28,r29
 10c:   14 00 00 48     b       120 <pseries_remove_memblock+0x118>
 110:   00 00 00 60     nop
 114:   00 00 00 60     nop
 118:   00 00 00 60     nop
 11c:   00 00 00 60     nop
 120:   78 fb e4 7f     mr      r4,r31

.LVL174:
        rldic 28,28,24,8         #, tmp198, tmp196,
        add 28,28,29     # _45, tmp198, base
        .p2align 5,,31

Patch removing such loop, changes the section alignment boundary. Given
that alignment changes to .text section are not fatal, relax the check
for text sections.

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2018-07-04 08:41:00 +05:30
Joe Lawrence
2f3db2abe9
Merge pull request #890 from kamalesh-babulal/readme
readme: Update gcc-plugin-devel dependency
2018-06-28 11:15:03 -04:00
Kamalesh Babulal
acf33455a3 readme: Update gcc-plugin-devel dependency
Update gcc-plugin-devel package dependency for livepatch
modules on ppc64le.

Fixes #888.

Suggested-by: Joe Lawrence <jdl1291@gmail.com>
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2018-06-22 10:07:32 +05:30
Joe Lawrence
7f550f01bd
Merge pull request #858 from joe-lawrence/release-v0.6.1
Patch release v0.6.1
2018-06-21 11:02:17 -04:00
Joe Lawrence
57def40805 Patch release v0.6.1
Create a minor release that includes fixes for:

* increase the transition timeout, helpful for large CPU count systems
* ppc64le WARN macro detection
* .parainstructions-related panic fix
* many, many unit/integration test cleanups and improvements
* properly align .parainstructions sections in patch module
* remove 'immediate' flag support from RHEL-7.6 onward
* initial GCC 8 support bugfixes
* support for RHEL kernel-alt release
* misc kpatch-build fixes and optimizations

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2018-06-20 16:15:09 -04:00
Joe Lawrence
2639b8441a
Merge pull request #889 from joe-lawrence/kpatch-build-misc2
Kpatch build misc fixes, round 2
2018-06-20 14:44:00 -04:00
Joe Lawrence
4d1ee7f80a kpatch-build: fix RHEL-ALT kernel version detection
kpatch-build detects RHEL-ALT kernel support by looking for a ".el7a."
substring in the kernel release string.  Look for that substring in the
unchanged $ARCHVERSION instead of $KVER, which may not have the
trailing '.' character that our regex expects.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2018-06-20 10:37:05 -04:00
Joe Lawrence
bc28b576ed kpatch-build: drop architecture spec from source rpm request
Source RPMs don't have an architecture associated with them, so to avoid
confusion, drop that part of the kernel release string when calling
yumdownloader.

Fixes #887.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2018-06-20 10:15:49 -04:00
Joe Lawrence
7dc6e5f215
Merge pull request #886 from sm00th/safe_cleancache
kpatch-build: less aggressive clean_cache()
2018-06-19 09:30:07 -04:00
Joe Lawrence
d3ed66a103
Merge pull request #885 from rudis/shellcheck
kpatch-build: fix shellcheck warnings
2018-06-19 09:29:47 -04:00
Joe Lawrence
d0ced9760d
Merge pull request #884 from rudis/master
create-diff-object: prevent "'toc_data1' may be used uninitialized" warning
2018-06-19 09:29:24 -04:00
Joe Lawrence
123e7d5603
Merge pull request #883 from sm00th/awkfix
kpatch-build: fix find_special_section_data with blank AWK_OPTIONS
2018-06-19 09:29:02 -04:00
Joe Lawrence
89257f937e
Merge pull request #882 from joe-lawrence/kpatch-build-misc
kpatch-build misc fixups
2018-06-19 09:28:20 -04:00
Artem Savkov
d86c1113cc kpatch-build: less aggressive clean_cache()
Some of the provisioned machines I sometimes use don't have enough
diskspace for a full kpatch-patch build in home partition. I usually
solve this by symlinking .kpatch(and .ccache) dirs to a different
partition, however this only works with -s option because of
clean_cache().

clean_cache() currently removes .kpatch directory completely, recreating
it from scratch, change it to only remove the contents of the directory
instead.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-06-18 18:15:05 +02:00
Simon Ruderich
0acc62e1ce create-diff-object: prevent "'toc_data1' may be used uninitialized" warning
Building with GCC 7.3.0 on Debian sid fails with the following error:

    gcc -g -O2 -fdebug-prefix-map=/build/kpatch-0.6.0=. -fstack-protector-strong -Wformat -Werror=format-security -MMD -MP -I../kmod/patch -Iinsn -Wall -Wsign-compare -g -Werror -Wdate-time -D_FORTIFY_SOURCE=2  -c -c
    create-diff-object.c: In function 'kpatch_compare_correlated_rela_section':
    create-diff-object.c:316:20: error: 'toc_data1' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    return toc_data1 == toc_data2;
           ~~~~~~~~~~^~~~~~~~~~~~
    create-diff-object.c:256:16: note: 'toc_data1' was declared here
    unsigned long toc_data1, toc_data2;
                  ^~~~~~~~~
    cc1: all warnings being treated as errors

This is a false positive as the code only compares those two values
after initializing them. But lets keep GCC happy.

Signed-off-by: Simon Ruderich <simon@ruderich.org>
2018-06-18 09:13:18 +02:00
Simon Ruderich
865a9e2c71 kpatch-build: fix shellcheck warnings
shellcheck 0.4.7 reported the following errors:

    [  "$1" = "$(echo -e "$1\n$2" | sort -rV | head -n1)" ]
                            ^-- SC1117: Backslash is literal in "\n". Prefer explicit escaping: "\\n".

    grepname="$grepname\.o"
                       ^-- SC1117: Backslash is literal in "\.". Prefer explicit escaping: "\\.".

    grep "undefined reference" "$LOGFILE" | sed -r "s/^.*\`(.*)'$/\1/" \
                                                                  ^-- SC1117: Backslash is literal in "\1". Prefer explicit escaping: "\\1".

Signed-off-by: Simon Ruderich <simon@ruderich.org>
2018-06-16 21:01:07 +02:00
Artem Savkov
fda7c87a70 kpatch-build: fix find_special_section_data with blank AWK_OPTIONS
If $AWK_OPTIONS are blank gawk would treat "" as a blank script
resulting in none of the special struct being detected.

Fixes: 1330dcc "create-diff-object: add ORC section support"
Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-06-15 14:19:11 +02:00
Joe Lawrence
1f4551a49e kpatch-build: add exit status enum
Convert magic exit status values into a common enum for clarity.

Suggested-by: Artem Savkov <asavkov@redhat.com>
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2018-06-15 07:11:48 -04: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
Joe Lawrence
dc6530f11c kpatch-build: clarify symbol-not-found msg find_local_syms()
Add a little more context ("in the vmlinux symbol table") to the
symbol-not-found message in find_local_syms().

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2018-06-13 13:53:19 -04:00
Joe Lawrence
391c9875ee kpatch-build: change FILE symbol not found to warning
Change the "FILE symbol not found in base. Stripped?" (fatal) error
message into a warning.  These crop up whenever a change is made to an
assembly file.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2018-06-13 13:52:34 -04:00
Joe Lawrence
63582367f4
Merge pull request #879 from jpoimboe/orc
create-diff-object: add ORC section support
2018-06-12 11:04:46 -04:00
Josh Poimboeuf
1330dcc43d create-diff-object: add ORC section support
Finally add support for processing the ORC unwinder sections.

The ORC unwinder sections are more special than the other special
sections, so they need their own dedicated function to process them,
though the code is similar to kpatch_regenerate_special_sections().

BTW, upstream livepatch still doesn't support the ORC unwinder.  That
change will be coming soon (probably Linux 4.19).

Fixes #785.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2018-06-11 17:41:54 -05:00
Joe Lawrence
b47ab2ecec
Merge pull request #878 from bsingharora/master
trivial: __powerpc__ should be __powerpc64__
2018-06-11 17:18:58 -04:00
Balbir singh
8ef31a0e92 trivial: __powerpc__ should be __powerpc64__
Since the codeset supports just the 64 bit variant, lets move
to __powerpc64__ and use it. I checked the ABI doc as well
and the kernel/gcc.

Signed-off-by: Balbir singh <bsingharora@gmail.com>
2018-06-07 17:33:06 +10:00
Joe Lawrence
a8133b1dc3
Merge pull request #873 from jpoimboe/detect-truncated-Module.symvers
kpatch-build: detect truncated Module.symvers
2018-06-04 16:07:42 -04:00
Joe Lawrence
37e4ae0c88
Merge pull request #875 from sm00th/unit-clean
unittests: skip clean if objdir is not present
2018-06-04 13:59:59 -04:00
Joe Lawrence
014a7dd48d
Merge pull request #871 from jpoimboe/symtab-fix
lookup: don't add undefined symbols to the lookup table
2018-06-04 13:59:07 -04:00
Joe Lawrence
9bc7776b0f
Merge pull request #868 from joe-lawrence/kpatch-test-names
testing: kpatch-build should set all module names
2018-06-04 13:58:32 -04:00
Joe Lawrence
5bf7798061
Merge pull request #874 from jpoimboe/mrproper
get rid of "make mrproper"
2018-06-04 13:57:14 -04:00
Joe Lawrence
5d265e33df
Merge pull request #870 from jpoimboe/rhel-alt
kpatch-build: RHEL kernel-alt support
2018-06-04 13:55:42 -04:00
Artem Savkov
b10e0b7d82 unittests: skip clean if objdir is not present
Don't try to call unittest clean if objfile dir is non-existant (e.g.
when objfile submodule wasn't cloned). Another solution would be to make
clean target dependant on objdir but that would mean downloading a lot
of unneeded data for users who don't run unit-tests.

Fixes: #872

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-06-04 13:14:28 +02:00