Commit Graph

867 Commits

Author SHA1 Message Date
Josh Poimboeuf
e27ffadce1 make "descriptor" a special static local variable
The "descriptor" static local variables and their containing __verbose
section are used for dynamic debug printks.  They should be considered
as special static local variable symbols because they have the same
requirements: they should never be correlated and they should only be
included if referenced by an included function.
2014-10-01 11:11:54 -05:00
Josh Poimboeuf
b295c8686e test: improve macro-hooks patch
Restore aio_max_nr to its original value when unloading.

Also move the location of the patch hunk to be not at the end of the
file.  Otherwise we hit a weird combinediff bug which results in the
diff's context being removed.
2014-10-01 11:11:54 -05:00
Seth Jennings
e5dd825f15 Merge pull request #435 from jpoimboe/rhel7-optional-repo
readme: enable RHEL 7 optional repo
2014-09-30 14:15:04 -05:00
Josh Poimboeuf
bd2b499509 readme: get ccache from EPEL for RHEL 7 2014-09-29 21:32:27 -05:00
Josh Poimboeuf
2203cf5b7d readme: enable RHEL 7 optional repo
needed for pesign, newt-devel, pciutils-devel, asciidoc
2014-09-29 21:21:43 -05:00
Josh Poimboeuf
cca211067c Merge pull request #434 from useidel/master
added missing options -v, -t and -d
2014-09-26 23:43:15 -05:00
Udo Seidel
6c73bc3652 added missing options -v, -t and -d 2014-09-26 19:12:45 +02:00
Josh Poimboeuf
f69d258c0b Merge pull request #433 from spartacus06/fixup-makefile
improve kpatch-build Makefile
2014-09-24 22:04:48 -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
88aae05894 Merge pull request #428 from jpoimboe/full-tree-recompile
full tree recompilation support
2014-09-15 21:22:08 -05:00
Josh Poimboeuf
a20940892a code review fixes 2014-09-15 21:11:13 -05:00
Josh Poimboeuf
46ba72b339 Merge pull request #429 from spartacus06/fix-srpm-regression
fix regression in user-specified source RPM
2014-09-15 21:08:51 -05:00
Seth Jennings
85d7b071ba Merge pull request #427 from jpoimboe/replace-unbundled-references
replace all unbundled section references with symbols
2014-09-15 17:02:19 -05:00
Seth Jennings
18d9e4daa9 fix regression in user-specified source RPM
A recent commit 74316588e is unconditionally setting the SRCRPM path
overwriting a user specified path.

Only set SRCRPM if SRCRPM is not already set.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-09-15 16:58:22 -05:00
Josh Poimboeuf
1ee3ae669f test: add slow test for rebuilding entire tree
Only gets run with the slow integration tests, not "make quick".
2014-09-15 14:54:59 -05:00
Josh Poimboeuf
33cd945b14 new .fixup group size algorithm
The fixup_group_size() function assumes that all .fixup rela groups end
with a jmpq instruction.  That assumption turns out to be false when you
take into account the ____kvm_handle_fault_on_reboot() macro which is
used by kvm.

This is a new, more reliable method.  It turns out that each .fixup
group is referenced by the __ex_table section.  The new algorithm goes
through the __ex_table relas to figure out the size of each .fixup
group.

Also the .fixup section is now processed before __ex_table, because it
needs to access the original __ex_table relas before the unused ones
have been stripped.

Fixes the following error:

  ERROR: vmx.o: fixup_group_size: 1554: can't find jump instruction in .fixup section
2014-09-15 14:54:57 -05:00
Josh Poimboeuf
dbecef6e91 replace all unbundled section references with symbols
Currently we're checking for several special cases when deciding whether
to convert unbundled section references to their corresponding symbol
references.  We do it for all unbundled text sections as well as three
specific data sections.

There's no reason I can think of for why we shouldn't just do it for
_all_ unbundled sections.
2014-09-15 12:01:34 -05:00
Seth Jennings
a042dc1bbc Merge pull request #426 from jpoimboe/rename-objname-var
rename global "objname" variable to "childobj"
2014-09-15 11:48:39 -05:00
Josh Poimboeuf
bfe7fca5bd rename global "objname" variable to "childobj"
There are two distinct usages of "objname" as a variable name:

- the parent object being patched (e.g. vmlinux)
- the child object being analyzed (e.g. meminfo.o)

The name of the global objname variable conflicts with several
functions' usage of a local objname variable, resulting in some error
messages of e.g., "ERROR: vmlinux:" instead of "ERROR: meminfo.o:".

Rename the global objname variable to childobj.
2014-09-15 11:36:02 -05:00
Josh Poimboeuf
ba7c905b3a process special sections after checking for changes
There's no need to process special sections if we're returning due to no
functions changing.

Also this means we don't have to deal with extra-special usage of the
.fixup section (here's looking at you arch/x86/lib/copy_user_64.S -- we
can't patch functions in .S files anyway).
2014-09-15 11:17:37 -05:00
Josh Poimboeuf
218011b268 kpatch-build: allow two parents unless the object changes
With some obscure drivers, the same object file can be linked into
multiple parent objects.  Only call this out as an error if the object
has changed, otherwise it doesn't matter.

Fixes the following issue:

    ERROR: two parent matches for drivers/media/radio/si470x/radio-si470x-common.o.
2014-09-15 11:17:37 -05:00
Josh Poimboeuf
f5dbd7816e kpatch-gcc: skip vdso files
vdso files aren't kpatch-compatible, and give errors like the following:

    ERROR: invalid ancestor arch/x86/vdso/vdso32-sysenter.so.dbg for arch/x86/vdso/vdso32/sysenter.o
2014-09-15 11:17:37 -05:00
Josh Poimboeuf
8c2792af6c kpatch-build: deep find performance improvement
If we have to do a deep find (e.g. search the entire tree) to find a
parent object, first try searching in the last successful deep find
directory.  This is a performance improvement in the case of a full tree
rebuild, because deep finds are very expensive, and it's not uncommon
for there to be multiple objects in a directory being linked into an
object in another directory.
2014-09-15 11:17:37 -05:00
Josh Poimboeuf
a851517165 kpatch-build: add more ancestors for vmlinux
There are a few more valid ancestors for vmlinux other than built-in.o.
This fixes errors similar to the following:

    ERROR: invalid ancestor arch/x86/lib/lib.a for arch/x86/lib/usercopy_64.o
2014-09-15 11:17:37 -05:00
Josh Poimboeuf
5cce81f49b kpatch-gcc: properly quote arguments
Fixes an error when the following is an argument to gcc:

'-DIPATH_IDSTR="QLogic' kernel.org 'driver"'

gcc: error: kernel.org: No such file or directory
gcc: error: driver": No such file or directory
2014-09-15 11:17:37 -05:00
Seth Jennings
43ca05e5b1 Merge pull request #425 from jpoimboe/fedora-src-rpm-koji-2
kpatch-build: download fedora src rpms from koji
2014-09-15 11:15:46 -05:00
Josh Poimboeuf
d254d3d0f2 fix review comments
Use the wget -P option.
2014-09-15 11:12:11 -05:00
Josh Poimboeuf
74316588e8 kpatch-build: download fedora src rpms from koji
yumdownloader is problematic because it doesn't allow you to download
anything but the latest released kernel.  It can also be slow at times.
Instead, for Fedora, download the RPMs from koji.
2014-09-15 11:12:11 -05:00
Josh Poimboeuf
6176353f8d kpatch-build: add KVER and KREL variables
Add KVER and KREL variables, and use them where appropriate.  Also
remove the setting of ARCHVERSION in the '-s' case, since it's not
actually used anywhere in that case.
2014-09-15 11:11:25 -05:00
Seth Jennings
29551bd9b5 Merge pull request #424 from jpoimboe/readme-openssl
readme: add openssl to F20 dependencies
2014-09-15 10:56:23 -05:00
Josh Poimboeuf
3b8361333a readme: add openssl to F20 dependencies 2014-09-15 10:47:43 -05:00
Seth Jennings
89edbb2e41 Merge pull request #420 from jpoimboe/special-sections-later
process special sections after inclusion logic
2014-09-12 21:52:29 -05:00
Josh Poimboeuf
d41365fc0e process special sections after inclusion logic
The special sections should be processed after all the other inclusion
logic has run, so that should_keep_rela_group() can work properly.
Otherwise it might remove a needed rela group from a special section.
2014-09-12 14:03:10 -05:00
Josh Poimboeuf
fc3a63bb25 Merge pull request #419 from jpoimboe/fix-integration-tests
fix test conflict
2014-09-12 13:13:34 -05:00
Josh Poimboeuf
dacdfcfd22 fix test conflict
I accidentally added two tests which both create a non-static
kpatch_foo() function, which breaks the combined integration test kernel
build.
2014-09-12 13:12:36 -05:00
Josh Poimboeuf
114b21c7e5 Merge pull request #417 from spartacus06/fix-376
check ARCHVERSION for hyphen before creating localversion
2014-09-11 15:53:43 -05:00
Seth Jennings
fef7a6ede5 check ARCHVERSION for hyphen before creating localversion
If hyphen doesn't exist in uname -r (ARCHVERSION), then it is probably a
non-distro kernel and we don't need to create the localversion file.

Fixes #376

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-09-11 15:38:05 -05:00
Seth Jennings
93398c21ca Merge pull request #412 from jpoimboe/key-warned
support for__key and __warned special static local vars
2014-09-11 14:24:49 -05:00
Seth Jennings
a82b3d8fa0 Merge pull request #415 from jpoimboe/mangled-strcmp
fix the mangled function strcmp
2014-09-11 13:30:17 -05:00
Seth Jennings
671a30fb99 Merge pull request #413 from jpoimboe/static-fix
skip data sections when looking for users of static locals
2014-09-11 13:22:51 -05:00
Josh Poimboeuf
1553764be6 add other users of kpatch_mangled_strcmp 2014-09-11 08:27:09 -05:00
Josh Poimboeuf
0da57e8807 fix the mangled function strcmp
Fix the mangled function strcmp so that it compares all of the string
except for the numbered parts.  foo.isra.35 should match foo.isra.1, but
not foo.isra.35.part.36.

Fixes #352.
2014-09-10 21:25:30 -05:00
Seth Jennings
d60e88bb88 Merge pull request #416 from jpoimboe/patch-function-rename
patch module function/variable renaming
2014-09-10 21:21:25 -05:00
Josh Poimboeuf
a224d2470c patch module function/variable renaming
Make the kpatch-patch-hook.c function and variable names consistent by
prefixing them all with 'patch_'.  This makes it easier to distinguish
the patch hook sections from the patched sections when looking at the
ELF section data.
2014-09-10 21:14:23 -05:00
Seth Jennings
aac8b03f44 Merge pull request #414 from jpoimboe/ignore-rela-section
allow the user to ignore a rela section
2014-09-10 17:06:00 -05:00
Josh Poimboeuf
24ea032f9f allow the user to ignore a rela section
If the user specifies KPATCH_IGNORE_SECTION for a rela section, ignore
the corresponding text section instead of corrupting memory.

Fixes #381.
2014-09-10 17:05:17 -05:00
Josh Poimboeuf
b2f47f9ef3 add another user of is_text_section 2014-09-09 15:11:09 -05:00
Josh Poimboeuf
0537ff6a6f skip data sections when looking for users of static locals
It's possible for a static local variable's data section to have
a relocation which refers to the variable symbol itself.  Fix the logic
which searches for the user of a static local variable by only looking
in text sections (i.e. functions).

Fixes #411.
2014-09-09 14:43:42 -05:00
Josh Poimboeuf
db91697542 don't convert section references to syms for debug sections
This fixes a seg fault in the test suite caused by a debug section
referencing an un-included unbundled symbol (though its section was
included).  The symbol was a __warned symbol and the section was
.data.unlikely.

For debug sections, there is no need to replace section references with
symbols because we don't compare debug sections.
2014-09-09 13:36:23 -05:00
Josh Poimboeuf
2982962549 support for__key and __warned special static local vars
Add support for the __key and __warned "special" static local variables.
I'm calling them that for lack of a better term, analagous to the
kernel's special sections that we have to deal with.

__warned: Used by WARN_ONCE et al as an indicator as to whether a
message has already been printed.  I think it makes sense (and is much
easier) to reset this counter for a given function when replacing the
function, since the user may expect the new function to warn again.

__key: Used by lockdep as an identifier for a given lock initialization
code path (see http://lwn.net/Articles/185666/ for more info).  I think
it makes sense (and is much easier) to create a new key for a given
function when replacing the function, because the locking semantics may
have changed, so it makes sense for lockdep to use a new key to validate
the new locking behavior.

So for both __warned and __key static variables, the new version of the
variable should be used when referenced by an included function.

Made the following changes to support these special variables:

- Ignore their suffixes when comparing them in rela_equal, so that gcc
  renaming them will not result in a function being marked as changed
  just because it referenced a renamed static local

- Don't ever correlate them, so that their new versions will be included
  if a changed or new function uses their corresponding symbols

Fixes #402.
2014-09-09 13:36:20 -05:00