Commit Graph

23 Commits

Author SHA1 Message Date
Jessica Yu 09d2af5cb4 create-klp-module: add new program that creates patch modules that have klp elements
Add a new program, create-klp-module, that, given a built module (.ko),
will create a patch module with klp rela sections, klp arch sections, and
klp symbols.
2017-01-23 12:43:31 -08:00
Jessica Yu adcd4581cc kpatch-elf: introduce a common kpatch-elf and logging interface
Introduce a common kpatch elf api by moving all functions and struct
declarations related to manipulating kpatch_elf objects from
create-diff-object to kpatch-elf.{h,c}. Move logging macros to a separate
file log.h, and have kpatch-elf.h include it. These changes will generalize
the kpatch-elf and logging api and make it available to other kpatch-build
tools.
2016-07-12 14:45:16 -07:00
Chris J Arges 053622b902 kpatch-build: allow external LDFLAGS
When building binaries such as create-diff-object it would be useful
to be able to pass LDFLAGS when running make from the command line.
2016-01-11 14:26:50 -06:00
Josh Poimboeuf 2899b5c23c create-diff-object: make all warnings into errors 2015-10-27 11:29:38 -05:00
Seth Jennings 8b1ae48d7c improve kpatch-build Makefile
Right now, the makefile has one target, create-diff-object, which
contains all the source/headers as one long list and all the source
files compiled in one command to make create-diff-object.

This doesn't scale well and doesn't accurately portray the dependencies
of each object that contribute to the final binary.

This commit renames create-diff-object.c to main.c so that it can be
compiled and linked seperately and cleanly in Make and autogenerates
dependencies for each .o. This should make it easier to add additional
object files, or refactor the very large main.o into seperate object
file, later.
2014-09-23 09:45:04 -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
Josh Poimboeuf cba7fd1f49 insn: get it to compile in create-diff-object 2014-05-30 15:19:57 -05:00
Seth Jennings 170c8b1ba1 fix review comments
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-20 12:44:31 -05:00
Seth Jennings 21fc274448 dynrelas support, obsoleting link-vmlinux-syms
This adds dynamic linking support for the patch modules.  It is the
first step toward supporting patching module code and relocatable
kernels.

Rela entries that reference non-included local and non-exported global
symbols are converted to "dynrelas".  These dynrelas are relocations
that are done by the core module, not the kernel module linker.  This
allows the core module to apply offsets to the base addresses found
in the base vmlinux or module.

Signed-off-by: Seth Jennings <sjenning@redhat.com>

Conflicts:
	kpatch-build/kpatch-build
2014-05-20 12:44:31 -05:00
Seth Jennings 6b7d576341 merge add-patches-section functionality into create-obj-diff
In preparation for dynamic symbol linking, the symbol lookup logic
is going to move into create-diff-obj anyway.  We might as well
minimize the code duplication and pull this into create-diff-obj.
This avoids having to re-parse the ELF file modify it in-place.

Signed-off-by: Seth Jennings <sjenning@redhat.com>

Conflicts:
	kpatch-build/kpatch-build
2014-05-20 12:44:30 -05:00
Josh Poimboeuf 5e25365244 Revert #186 (add dynamic symbol linking support)
We merged PR #186 a little too hastily.  It seg faults with the new
parainstructions-section.patch in the integration test suite.  Reverting
it for now until we get it figured out.

This reverts commit e1177e3a03.
This reverts commit 880e271841.
This reverts commit 2de5f6cbfb.
This reverts commit 38b7ac74ad.
This reverts commit 108cd9f95e.
2014-05-15 17:34:16 -05:00
Seth Jennings e1177e3a03 fix review comments
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-15 13:42:27 -05:00
Seth Jennings 880e271841 dynrelas support, obsoleting link-vmlinux-syms
This adds dynamic linking support for the patch modules.  It is the
first step toward supporting patching module code and relocatable
kernels.

Rela entries that reference non-included local and non-exported global
symbols are converted to "dynrelas".  These dynrelas are relocations
that are done by the core module, not the kernel module linker.  This
allows the core module to apply offsets to the base addresses found
in the base vmlinux or module.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-15 13:29:15 -05:00
Seth Jennings 38b7ac74ad merge add-patches-section functionality into create-obj-diff
In preparation for dynamic symbol linking, the symbol lookup logic
is going to move into create-diff-obj anyway.  We might as well
minimize the code duplication and pull this into create-diff-obj.
This avoids having to re-parse the ELF file modify it in-place.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-15 13:26:41 -05:00
Seth Jennings 5d36dd1c32 convert from arrays to linked-lists
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-07 10:06:41 -05:00
Seth Jennings 5932f0d083 add uninstall target
Make it easy to clean up an install

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-03-20 11:29:25 -05:00
Josh Poimboeuf bfad3b1880 kmod/core: update API and use hash table
My apologies for the size of this commit.  I combined these two features
(updating API and using a hash table) into a single commit because their
implementations are tightly coupled and I didn't want to have to add
support for the old kpatch_funcs array with the new API just for the
sake of splitting up the commit :-)

- Update the core module API to get a more clear separation between core
  module and patch module.  This is cleaner and will help our case for
  getting the core module merged upstream into the kernel.
- Convert the old kpatch_funcs array into a hash table.  This is so much
  nicer performance-wise and everything-else-wise than that ugly old
  array.
- Do the incremental patching in stop machine.  This ensures that the
  funcs hash is up to date and we don't miss anything.
- Disable preemption in the ftrace handler when accessing the func hash.
  That way we don't get conflicts with the stop_machine handler updating
  the hash.
2014-03-18 13:34:15 -05:00
Josh Poimboeuf 840a1b3e44 compile tools with -g for debug symbols 2014-03-13 12:28:35 -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
Josh Poimboeuf 693426b5ef enable gcc warnings and fix all warnings 2014-03-05 09:46:10 -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 62de820aab proper makefile support
- setup the makefiles to support "make" and "make install", which builds
  the kpatch-build tools and installs everything in /usr/local.
- update kpatch-build to support new paths
- add "kpatch build" wrapper around kpatch-build
2014-02-13 16:02:10 -06:00
Josh Poimboeuf 4f27b9ae31 functional reorganization
Organize the files functionally:
- kmod/core: core kmod source
- kmod/patch: patch kmod source
- kpatch: kpatch script
- kpatch-build: kpatch build script and supporting tools
- contrib: distro-related files
2014-02-13 11:00:06 -06:00