Commit Graph

32 Commits

Author SHA1 Message Date
Kamalesh Babulal a0c608de70 kpatch-build/Makefile: Skip build insn/plugin with -Wconversion
Skip building insn/* on x86 and gcc-plugin on Power with -Wconversion,
-Wno-sign-converion flags.

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2020-01-23 12:59:38 +05:30
Kamalesh Babulal 4e4a8d99da kpatch-build: add -Wconversion/-Wno-sign-conversion CFLAGS
Add -Wconversion and -Wno-sign-conversion to CFLAGS.  The first flag
should catch any implicit conversions like the one seen with #1065 and
the second flag suppress the warnings between signed and unsigned
integers.

Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2020-01-23 12:59:31 +05:30
Artem Savkov a4241797fb ppc64le: fix gcc-plugin installation
Because $PLUGIN variable is a part of $TARGETS we are trying to install
gcc-plugins twice which is treated as an error by install command:

/usr/bin/install create-diff-object create-klp-module create-kpatch-module gcc-plugins/ppc64le-plugin.so kpatch-gcc gcc-plugins/ppc64le-plugin.so /usr/local/libexec/kpatch
/usr/bin/install: will not overwrite just-created '/usr/local/libexec/kpatch/ppc64le-plugin.so' with 'gcc-plugins/ppc64le-plugin.so'

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-04-19 10:16:37 +02:00
Artem Savkov a39eace756 kpatch-build: add -Wsign-compare to CFLAGS
Add -Wsign-compare to kpatch-build CFLAGS to make sure something like #826
never happens again.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-04-13 16:27:23 +02:00
Josh Poimboeuf 63a94b8323 gcc-plugin: create a ppc64le GCC plugin which inserts nops after local calls
This is in response to an upstream discussion for the following patch:

  https://lkml.kernel.org/r/1508217523-18885-1-git-send-email-kamalesh@linux.vnet.ibm.com

This should hopefully make it a lot easier for the ppc64le kernel module
code to support klp relocations.

The gcc-common.h and gcc-generate-rtl-pass.h header files are copied
from the upstream Linux source tree.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2017-11-10 09:17:00 -06:00
Juerg Haefliger b6ba60f740 kpatch-build: Fix clean rule (remove insn/*.o)
Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
2017-11-07 13:18:42 +01:00
Simon Ruderich 8ab170d402 kpatch-build: use implicit make rules
This removes duplicate code which is already handled by make internally
and also respects CPPFLAGS.

LDFLAGS are general linker flags, LDLIBS should be used for the
libraries itself. Therefore switch to LDLIBS which is put after the
object files in the command line (which is not true for LDFLAGS).
2017-08-22 03:21:00 +02:00
Kamalesh Babulal dde4e95fa4 kpatch-build: Build with insn support only on x86_64
kpatch-build/insn provides x86 instruction analysis, disable
the analyzer support when build on powerpc.

Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2017-07-26 14:40:25 +05:30
Jessica Yu 0cc693ba36 create-kpatch-module: add new program that creates kpatch modules
Add new program create-kpatch-module, that, given an intermediate object
outputted by create-diff-object, outputs an object (.o) that contains the
.kpatch.dynrelas section required by kpatch.
2017-01-23 12:43:34 -08:00
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