Commit Graph

1591 Commits

Author SHA1 Message Date
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
Josh Poimboeuf
f32363e634 kpatch-build: don't do "make mrproper" on every build
As discussed in #848, there is no known reason to do "make mrproper" on
every build.  It seems to be an artifact from previous iterations (we
used to use 'O=' to build the kernel in a separate object tree.

It has many downsides:

- massive performance degradation
- breaks the '-t' option
- prevents the user from manually saving/restoring ~/.kpatch

Only do it where it's really needed, which is after first extracting the
source from an RPM.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2018-06-02 16:08:38 -05:00
Josh Poimboeuf
30c37847e1 kpatch-build: detect truncated Module.symvers
"make mrproper" combined with the '-t' flag is dangerous, as it results
in the Module.symvers file getting truncated, which causes
create-diff-object to create some funky dynrelas.  Detect this condition
in kpatch-build and error out.

We will hopefully also be removing "make mrproper" soon, which will make
'-t' even more useful.

Fixes #589.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2018-06-02 16:04:30 -05:00
Josh Poimboeuf
a310e9e82e kpatch-build: get Fedora .config from configs dir
In recent versions of Fedora, when building from a source RPM,
kpatch-build fails because it can't find the .config file.  Get the file
from the canonical location: the configs subdirectory.

This also works with older versions of Fedora and RHEL, and ensures we
always have the right config file for the arch we're building for.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2018-06-02 15:22:39 -05:00
Josh Poimboeuf
1ad9cefbcf lookup: don't add undefined symbols to the lookup table
Before we were adding the undefined symbols to the lookup table, but we
were skipping them by setting the sym.skip flag.

With 3aa5abb807 ("kpatch-build: use symbol table instead of kobject"),
the skip flag was removed but the undefined symbol check was removed
with it.

The skip flag can remain gone.  Instead of adding undefined symbols to
the table and skipping them when iterating the table, just don't add
them to start with.

Also make the sscanf conditional lines identical, to ease maintenance.

Fixes #869.

Fixes: 3aa5abb807 ("kpatch-build: use symbol table instead of kobject")
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2018-06-02 13:37:37 -05:00
Josh Poimboeuf
d04f5723bc kpatch-build: RHEL kernel-alt support
Deal with a few RHEL kernel-alt quirks for ppc64le:

- The RPM and spec names are "kernel-alt".

- 7.6 ALT is based on 4.14 but it doesn't have the 'immediate' flag.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2018-06-01 22:15:52 -05:00
Joe Lawrence
7646c68b59 testing: kpatch-build should set all module names
Since c0105ea467 ("kpatch-build: set default module prefix
accordingly") kpatch-build has automatically named resulting patch
modules with a "kpatch-" or "livepatch-" prefix (depending on its type).

To avoid naming confusion, have kpatch-test name all of its patch
modules with a "test-" prefix.

Fixes #867.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2018-06-01 16:59:08 -04:00
Joe Lawrence
74392002de
Merge pull request #864 from sm00th/rhel-immediate-fix
livepatch-patch-hook: fix non-rhel builds
2018-05-31 13:19:32 -04:00
Josh Poimboeuf
a7c413d4e9
Merge pull request #856 from sm00th/unlikely-cold
create-diff-object: ignore .cold.* suffixes in is_bundleable()
2018-05-31 09:25:28 -05:00
Artem Savkov
6c58f09cc7 test/unit: update objects to include cold testcase
Update unit test objects subrepo to include x86_64 gcc-constprop-cold
testcase.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-05-31 15:29:06 +02:00
Artem Savkov
355927287d livepatch-patch-hook: fix non-rhel builds
Preprocessor doesn't stop unwinding macroses in #if clauses if one of
the conditions is false resulting in the following error when trying to
build on non-rhel system:

patch/livepatch-patch-hook.c:53:48: error: missing binary operator before token "("
       RHEL_RELEASE_CODE <= RHEL_RELEASE_VERSION(7, 5))

Fix by using 2 levels of #ifs instead of &&. The same way HAVE_CALLBACKS
does.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-05-31 12:28:03 +02:00
Joe Lawrence
27accf46ee
Merge pull request #857 from joe-lawrence/local-symbols
create-klp-module: group .kpatch.symbols with like-scope
2018-05-30 14:16:40 -04:00
Joe Lawrence
ace1e2cbf6
Merge pull request #849 from sm00th/cdo-symtab
create-diff-object symtab
2018-05-30 14:15:43 -04:00
Joe Lawrence
a879d1f3ea
Merge pull request #859 from jpoimboe/ppc-TOC
create-diff-object: don't convert .TOC. references to dynrelas
2018-05-30 14:09:02 -04:00
Joe Lawrence
9d0a2105ef
Merge pull request #861 from kamalesh-babulal/gcc_plugin
gcc-plugin: Include additional header for GCC 8
2018-05-30 14:06:32 -04:00
Joe Lawrence
b387dffab6
Merge pull request #863 from jpoimboe/unit-submodule-root-dir
test/unit: run submodule command from base git directory
2018-05-30 14:04:41 -04:00
Artem Savkov
019c029830 Add .cold. to mangled functions check
gcc8 introduces ".cold." optimization symbols that have arbitrary
trainling numbers in their names just like ".isra." and others.
Add ".cold." to a condition in kpatch_rename_mangled_functions()

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-05-30 19:20:18 +02:00
Josh Poimboeuf
5736f18d83 test/unit: run submodule command from base git directory
This fixes the following error with an older version of git
(1.8.3.1):

  make -C test/unit
  make[1]: Entering directory `/root/kpatch/test/unit'
  git submodule update --init --rebase
  You need to run this command from the toplevel of the working tree.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2018-05-30 10:54:24 -05:00
Joe Lawrence
c2f6d4d0fb
Merge pull request #860 from jpoimboe/rhel-immediate
livepatch-patch-hook: add RHEL immediate check
2018-05-30 11:37:53 -04:00
Kamalesh Babulal
3ba9a145e9 gcc-plugin: Include additional header for GCC 8
plugin compilation fails on GCC 8:

In file included from gcc-plugins/gcc-common.h:100,
                 from gcc-plugins/ppc64le-plugin.c:1:
/usr/lib/gcc/powerpc64le-linux-gnu/8/plugin/include/attribs.h: In function ‘tree_node* canonicalize_attr_name(tree)’:
/usr/lib/gcc/powerpc64le-linux-gnu/8/plugin/include/attribs.h:118:11: error: ‘get_identifier_with_length’ was not declared in this scope
    return get_identifier_with_length (s + 2, l - 4);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/powerpc64le-linux-gnu/8/plugin/include/attribs.h:118:11: note: suggested alternative: ‘get_attr_min_length’
    return get_identifier_with_length (s + 2, l - 4);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~
           get_attr_min_length
Makefile:34: recipe for target 'gcc-plugins/ppc64le-plugin.so' failed

get_identifier_with_length() is defined under stringpool.h, include this
header file for GCC 8, before including attribs.h

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2018-05-30 19:39:48 +05:30