Commit Graph

57 Commits

Author SHA1 Message Date
Josh Poimboeuf
c164649d4e kmod/core: rename some variables
For the sake of consistency and readability, rename some variables.
Also change func->old_addr_end to func->old_size.
2014-03-14 20:23:12 -05:00
Seth Jennings
5e5f3a76f9 Merge pull request #61 from jpoimboe/patch-compile-fail-log
kpatch-build: add patch compile failure output to log
2014-03-14 17:14:33 -05:00
Josh Poimboeuf
2aef7d7c41 kpatch-build: add patch compile failure output to log
If the patch doesn't compile, make sure the LOGFILE has the error
output.
2014-03-14 11:12:40 -05:00
Josh Poimboeuf
d4363e0c9b kpatch-build: fix SCRIPTDIR for bash -x
More adventures in bash-land.  Running "bash -x kpatch-build foo.patch"
causes SCRIPTDIR to not get set properly.  This fixes that.
2014-03-14 11:09:29 -05:00
Seth Jennings
c83141be90 Merge pull request #56 from jpoimboe/patch-error-handling
Improve source patch error handling
2014-03-13 17:13:35 -05:00
Seth Jennings
26397afeaf Merge pull request #57 from jpoimboe/no-changed-objects
properly detect no changed objects
2014-03-13 17:06:33 -05:00
Seth Jennings
eb87ccf5fb Merge pull request #58 from jpoimboe/changed-function-output
make the changed function output more readable
2014-03-13 17:04:34 -05:00
Josh Poimboeuf
840a1b3e44 compile tools with -g for debug symbols 2014-03-13 12:28:35 -05:00
Josh Poimboeuf
72af45502f make the changed function output more readable
This makes it much easier to spot which functions have changed,
especially when there are more than one of them.
2014-03-13 12:22:01 -05:00
Josh Poimboeuf
c4ea0ea4ef properly detect no changed objects
The current solution doesn't work because "$?" will always be 0, even if
there were no "CC" lines in the build log.  Instead, just make sure the
changed_objs file isn't empty.
2014-03-13 12:20:13 -05:00
Josh Poimboeuf
72b5f3b4fb try source patch before compiling kernel
Add a patch testing step before compiling the kernel, so that users
don't have to wait for the kernel to compile before seeing if the patch
applies cleanly.

Also allow the printing of the patch command's stdout/stderr to make it
clear what files are being patched and whether there's any fuzz.
2014-03-13 12:08:25 -05:00
Josh Poimboeuf
a611185dce better patch file cleanup
If the patch file fails to apply, it "corrupts" the cache by leaving the
old applied-patch file around.  Fix that by always cleaning up after
ourselves.
2014-03-13 11:53:44 -05:00
Josh Poimboeuf
5ab497a2b3 kpatch-build --sourcedir option
Allow the user to supply a custom kernel source directory.  This copies
the directory to ~/.kpatch/src instead of using it in place.  Otherwise
the "make mrproper" (which is needed for compiling objects in a separate
tree) would modify the original source tree and remove its .config file.

There's currently no caching support for this option.  If needed, we
could implement that pretty easily by calculating an md5sum of the
original source directory.
2014-03-11 10:43:48 -05:00
Josh Poimboeuf
2d728c4f0d make kpatch-build a first class script
kpatch-build is outgrowing the kpatch script and probably is a better
fit as its own utility instead of being wrapped by kpatch.  Install
kpatch-build into /usr/local/bin, remove the kpatch wrapper around it,
and update the README accordingly.
2014-03-11 10:43:48 -05:00
Seth Jennings
e8fb5b1c9f fixup comment
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-03-10 15:11:23 -05:00
Seth Jennings
8b9de30581 add error for sym value != 0
For a local object or function symbol, we expect that
the section offset, sym.st_value, be 0 because we used
-ffunction-sections and -fdata-section during compile.

If value != 0, it undermines assumptions we make and
should return an error.  Exceptions should be handled
on a case by case basis, like __ksymtab_strings.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-03-10 15:11:23 -05:00
Seth Jennings
582f2b27e0 add comment for __ksymtab_strings case
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-03-10 14:49:56 -05:00
Josh Poimboeuf
942fbdf37a kpatch-build: show changed functions
Pipe create-diff-object output to both stdout and the log file, so the
user can see which functions have changed.
2014-03-10 11:18:18 -05:00
Seth Jennings
8eafea114a add inventory file creation to create-object-diff
In preparation for adding an automated test framework,
add an ability to create-object-diff that will create
a human readable list of included sections and symbols
with type and bind information so that the test framework
can compare against a known-good reference list with the
expected set of sections and symbols.

The file is created when the -i/--inventory option is
used.  The inventory filename is the user supplied output
file name suffixed by .inventory

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-03-07 17:02:45 -06:00
Seth Jennings
6550dd74f6 replace DEBUG compiler define with -d/--debug runtime option
I'm tired of setting CFLAGS and people shouldn't have to
recompile to get debug output.  This lays the foundations
proper option handling and logging levels.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-03-07 16:06:32 -06:00
Seth Jennings
159214a4fc fixup printf formats with -DDEBUG
Fix -Wformat warnings for printf formats with -DDEBUG

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-03-07 12:07:56 -06:00
Seth Jennings
e33695be27 remove dead code
refactoring.  A couple of comment touchups too.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-03-05 11:26:02 -06:00
Josh Poimboeuf
693426b5ef enable gcc warnings and fix all warnings 2014-03-05 09:46:10 -06:00
Josh Poimboeuf
81cc4a3542 Merge pull request #37 from spartacus06/fixes
refactor and fix multiple issues
2014-03-05 09:42:22 -06:00
Josh Poimboeuf
330a08dd0d add GPLv2 headers to source files 2014-03-04 21:34:19 -06:00
Seth Jennings
f6efd53541 refactor and fix multiple issues
- Fixup debug messages
- Remove dead code
- No more DEPENDENCY state
- Reachability test is now the "Inclusion tree" for determining
  which syms/sections will be included in the output
- 'reachable' field is now and 'include' and is the sole
  consideration in including sections/symbols (no more complex
  conditional checks)
- Order LOCAL before GLOBAL in the symbol table.  Apparently, after
  a FILE sym, all LOCAL symbols should precede GLOBAL syms or readelf
  shows <corrupt>
- Handle __ksymtab_strings section and __ksymtab_* syms

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-03-04 15:56:41 -06:00
Seth Jennings
d62798fde8 put localversions file in SRCDIR, not OBJDIR
The kernel Makefile look for localversion in the source tree,
not the object tree.  The absense from the source tree results
in a patch module that will not load because the kernel versions
don't match.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-03-02 19:47:23 -06:00
Josh Poimboeuf
5352d8b01a build objects in separate directory to fix caching
Setting KCFLAGS="-ffunction-sections -fdata-sections" causes make to
invalidate all the kernel objects, resulting in all the objects getting
rebuilt on the next pass, thus no build caching.

To fix that, build the objects in a separate directory (obj) for normal
builds, and another separate directory (obj2) for the builds with added
cflags.
2014-02-20 14:52:21 -06:00
Seth Jennings
084cbeaa80 iterate the iterator
It works better this way.  Trust me.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-02-18 16:17:21 -06:00
Josh Poimboeuf
f7da3ea207 only allow one cache at a time
This will prevent the ~/.kpatch cache directory from filling up with old
caches.
2014-02-18 16:05:18 -06:00
Seth Jennings
7d747e86fd remove compressed cache
The compression of the cache during initial build time and
the removal and (re)decompression of the cache for subsequent
builds takes a large amount of time and causes significant I/O.

This commit removes the compressed cache and, instead, keeps
the cache uncompressed and maintained in a known state.  If
the "applied-patch" file does not exist, then the cache is
in the unpatched state.  If the file does exist, the cache is
in a patched state and can be returned to an unpatched state
with "patch -R -p1 < applied-patch".

The if cache is detected and is in the patched state, the patch
is removed and vmlinux is rebuilt to obtain the base vmlinux.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-02-18 15:25:11 -06:00
Josh Poimboeuf
f0ce3443b5 Merge pull request #25 from spartacus06/fixes
remove quotes around for loop elements
2014-02-18 14:19:50 -06:00
Seth Jennings
a6154ca400 remove quotes around for loop elements
Right now kpatch-build fails when more than one object
file has changed because the quotes around the for loop
arrays cause the for loop to execute only once for all
elements in a single string.

Remove the quotes around the for loop arrays so that the
for loop is execute for each element.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-02-18 13:37:46 -06:00
Seth Jennings
2fb629e958 Merge pull request #23 from jpoimboe/cleanup-cleanup
cleanup the cleanup handling
2014-02-18 11:23:42 -06:00
Josh Poimboeuf
052f2d8b25 fix calling of kpatch-build from git dir
When calling kpatch-build from the git directory, the patch kmod build
fails because it can't find kpatch.h because the symlink is broken.
Copy the kpatch.h file (instead of the symlink) to TEMPDIR.
2014-02-18 11:11:51 -06:00
Josh Poimboeuf
aed73433a7 cleanup the cleanup handling
- always remove TEMPDIR, otherwise /tmp can fill up if you get multiple
  build errors
- always remove KSRCDIR
- only remove the log file on success
2014-02-18 10:56:16 -06:00
Josh Poimboeuf
d8cdaa7a57 fix STRIPCMD use
bash gets confused when a command and its args are quoted:

  /usr/local/libexec/kpatch/kpatch-build: line 131: strip -d --keep-file-symbols: command not found
2014-02-18 10:37:49 -06:00
Josh Poimboeuf
12065851f3 don't copy core kmod source files to tempdir
No need to copy them anymore now that the core kmod is getting
built elsewhere.
2014-02-18 10:12:42 -06:00
Seth Jennings
b373d6e331 Merge pull request #18 from jpoimboe/logfile-error
kpatch-build: fix logfile error message
2014-02-18 09:29:27 -06:00
Josh Poimboeuf
f4791d0cce kpatch-build: fix logfile error message 2014-02-18 08:15:55 -06:00
Josh Poimboeuf
8085d0402b build and install core module with make
Build and install the kpatch core module with make and make install,
rather than building it every time with kpatch build.

The only downside to this approach is that the user has to make and make
install kpatch every time they get a new kernel.  But this is only
temporary, until the kpatch module is delivered in an RPM.
2014-02-18 07:44:33 -06:00
Seth Jennings
062355a186 retain source tree directory structure with objects
The source tree directory structure should be maintained
in the TEMPDIR while building the hotpatch module so that
changed objects in different directories with the same
name don't collide during the build process.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-02-17 16:00:11 -06:00
Seth Jennings
4f2d5d209c variablize strip command and add --keep-file-symbols
We need to keep the file symbols around for add-patches-section
and link-vmlinux-syms to resolve ambigous symbols in vmlinux.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-02-17 15:24:11 -06:00
Seth Jennings
6eafd1648f Merge pull request #9 from jpoimboe/kpatch-script-improvements
kpatch script improvements
2014-02-17 14:47:03 -06:00
Seth Jennings
62bb62f409 s/sybmols/symbols/ in create-diff-object
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-02-17 13:30:30 -06:00
Seth Jennings
8656355291 append to CFLAGS instead of overwrite
Honor user set CFLAGS

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-02-17 11:45:48 -06:00
Josh Poimboeuf
af17774865 kpatch-build: allow building as non-root
Allowing the user to build without needing to be root.  If the needed
packages aren't installed, the error messages will tell the user what to
install.
2014-02-14 16:53:27 -06:00
Josh Poimboeuf
4c74203366 kpatch-build: log to /tmp 2014-02-14 16:48:27 -06:00
Josh Poimboeuf
9c674f52be kpatch-build: put rpm in temp directory 2014-02-14 16:48:27 -06:00
Josh Poimboeuf
833a76b9df kpatch: use relative paths for finding tools/data
Use relative paths so that kpatch and kpatch-build will find the tools
and data they need, regardless of the installation prefix.  Also add
support for running them straight from the git repo.
2014-02-14 16:48:27 -06:00