]> xenbits.xensource.com Git - livepatch-build-tools.git/log
livepatch-build-tools.git
5 years agolivepatch: Identify the object file create-diff-object dislikes
Andrew Cooper [Tue, 27 Aug 2019 15:38:39 +0000 (16:38 +0100)]
livepatch: Identify the object file create-diff-object dislikes

... rather than leaving the user with no hint as to where to debug next.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
5 years agocreate-diff-object: Strip all undefined entries of known size
Pawel Wieczorkiewicz [Wed, 21 Aug 2019 08:20:49 +0000 (08:20 +0000)]
create-diff-object: Strip all undefined entries of known size

The patched ELF object file contains all sections and symbols as
resulted from the compilation. However, certain symbols may not be
copied over to the resulting object file, due to being unchanged or
not included for other reasons.
In such situation the resulting object file has the entire sections
copied along (with all their entries unchanged), while some of the
corresponding symbols are not copied along at all.
This leads to having incorrect undefined (STN_UNDEF) entries in the
final hotpatch ELF file.

The newly added function livepatch_strip_undefined_elements() detects
and removes all undefined RELA entries as well as their corresponding
PROGBITS section entries.
Since the sections may contain elements of unknown size (sh.sh_entsize
== 0), perform the strip only on sections with well defined entry
sizes.

After replacing the stripped rela list, it is assumed that the next
invocation of the kpatch_rebuild_rela_section_data() will adjust all
section header parameters according to the current state.

The livepatch_strip_undefined_elements() is a superset of the
kpatch_regenerate_special_section() in both scope (covers all RELA
sections instead of just special sections) and granularity (checks
all entries instead of whole groups) modulo the entries validity
predicate.
Unifying the functions results in a complicated code, which is hard
to reason about. Thus, the kpatch_regenerate_special_section() is
kept separate with its own predicate for special sections only, and
livepatch_strip_undefined_elements() follows for all sections with
the undefined symbol detecting predicate.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Martin Pohlack <mpohlack@amazon.de>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
5 years agocreate-diff-object: Extend patchability verification: STN_UNDEF
Pawel Wieczorkiewicz [Wed, 21 Aug 2019 08:20:48 +0000 (08:20 +0000)]
create-diff-object: Extend patchability verification: STN_UNDEF

During verification check if all sections do not contain any entries
with undefined symbols (STN_UNDEF). This situation can happen when a
section is copied over from its original object to a patched object,
but various symbols related to the section are not copied along.
This scenario happens typically during stacked hotpatches creation
(between 2 different hotpatch modules).

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Martin Pohlack <mpohlack@amazon.de>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
5 years agocreate-diff-object: Do not create empty .livepatch.funcs section
Pawel Wieczorkiewicz [Wed, 21 Aug 2019 08:20:47 +0000 (08:20 +0000)]
create-diff-object: Do not create empty .livepatch.funcs section

When there is no changed function in the generated payload, do not
create an empty .livepatch.funcs section. Hypervisor code considers
such payloads as broken and rejects to load them.

Such payloads without any changed functions may appear when only
hooks are specified.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Martin Mazein <amazein@amazon.de>
Reviewed-by: Martin Pohlack <mpohlack@amazon.de>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
5 years agocreate-diff-object: Do not include all .rodata sections
Pawel Wieczorkiewicz [Wed, 21 Aug 2019 08:20:46 +0000 (08:20 +0000)]
create-diff-object: Do not include all .rodata sections

Older versions of GCC did not split .rodata.str sections by function.
Because of that, the entire section was always included.
The livepatch-build-tools commit [1] fixed patch creation and kept
including all .rodata.str sections, in order to maintain existing
behavior for GCC 6.1+.
This means all .rodata.str sections are always included by default,
regardless of whether they are needed or not.

During stacked hotpatch builds it leads to unnecessary accumulation of
the .rodata.str sections as each and every consecutive hotpatch module
contains all the .rodata.str sections of previous modules.

To prevent this situation, mark the .rodata.str sections for inclusion
only if they are referenced by any of the current hotpatch symbols (or
a corresponding RELA section).

Extend patchability verification to detect all non-standard, non-rela,
non-debug and non-special sections that are not referenced by any of
the symbols or RELA sections.

Rename should_include_str_section() to is_rodata_str_section().

[1] 2af6f1aa6233 Fix patch creation with GCC 6.1+

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
5 years agocreate-diff-object: Add new entries to special sections array
Pawel Wieczorkiewicz [Wed, 21 Aug 2019 08:20:45 +0000 (08:20 +0000)]
create-diff-object: Add new entries to special sections array

Handle .livepatch.hooks* and .altinstr_replacement sections as the
special sections with assigned group_size resolution function.
By default each .livepatch.hooks* sections' entry is 8 bytes long (a
pointer). The .altinstr_replacement section has undefined group_size.

Allow to specify different .livepatch.hooks* section entry size using
shell environment variable HOOK_STRUCT_SIZE.

Add an explicit check to kpatch_regenerate_special_section() skipping
regeneration of special sections, whose group_size is 0.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
5 years agolivepatch-build: detect special section group sizes
Pawel Wieczorkiewicz [Wed, 21 Aug 2019 08:20:44 +0000 (08:20 +0000)]
livepatch-build: detect special section group sizes

Hard-coding the special section group sizes is unreliable. Instead,
determine them dynamically by finding the related struct definitions
in the DWARF metadata.

This is a livepatch backport of kpatch upstream commit [1]:
kpatch-build: detect special section group sizes 170449847136a48b19fc

Xen only deals with alt_instr, bug_frame and exception_table_entry
structures, so sizes of these structures are obtained from xen-syms.

This change is needed since with recent Xen the alt_instr structure
has changed size from 12 to 14 bytes.

[1] https://github.com/jpoimboe/kpatch/commit/170449847136a48b19fcceb19c1d4d257d386b56

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Martin Mazein <amazein@amazon.de>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
5 years agocreate-diff-object: Add is_special_section() helper function
Pawel Wieczorkiewicz [Wed, 21 Aug 2019 08:20:43 +0000 (08:20 +0000)]
create-diff-object: Add is_special_section() helper function

This function determines, based on the given section name, if the
sections belongs to the special sections category.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
5 years agocommon: Add is_referenced_section() helper function
Pawel Wieczorkiewicz [Wed, 21 Aug 2019 08:20:42 +0000 (08:20 +0000)]
common: Add is_referenced_section() helper function

This function checks if given section has an included corresponding
RELA section and/or any of the symbols table symbols references the
section. Section associated symbols are ignored here as there is
always such a symbol for every section.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
5 years agocommon: Add is_standard_section() helper function
Pawel Wieczorkiewicz [Wed, 21 Aug 2019 08:20:41 +0000 (08:20 +0000)]
common: Add is_standard_section() helper function

Detect standard (always to be included) sections via their section
header type. The standard sections: ".shstrtab", ".symtab", ".strtab"
are either of type SHT_SYMTAB or SHT_STRTAB.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
5 years agolivepatch-build: Handle newly created object files
Pawel Wieczorkiewicz [Wed, 21 Aug 2019 08:20:40 +0000 (08:20 +0000)]
livepatch-build: Handle newly created object files

Up to now the livepatch-build ignores newly created object files.
When patch applies new .c file and augments its Makefile to build it
the resulting object file is not taken into account for final linking
step.

Such newly created object files can be detected by comparing patched/
and original/ directories and copied over to the output directory for
the final linking step.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
5 years agolivepatch-build: Do not follow every symlink for patch file
Pawel Wieczorkiewicz [Wed, 21 Aug 2019 08:20:39 +0000 (08:20 +0000)]
livepatch-build: Do not follow every symlink for patch file

In some build systems symlinks might be used for patch file names
to point from target directories to actual patches. Following those
symlinks breaks naming convention as the resulting built modules
would be named after the actual hardlink insteads of the symlink.

Livepatch-build obtains hotpatch name from the patch file, so it
should not canonicalize the file path resolving all the symlinks to
not lose the original symlink name.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Martin Pohlack <mpohlack@amazon.de>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
5 years agolivepatch-gcc: Ignore built_in.o and prelink.o object files
Pawel Wieczorkiewicz [Wed, 21 Aug 2019 08:20:38 +0000 (08:20 +0000)]
livepatch-gcc: Ignore built_in.o and prelink.o object files

Do not copy over the built_in.o and prelink.o object files when they
get rebuilt as they are used for transient linking by Xen's build
system.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Martin Pohlack <mpohlack@amazon.de>
Reviewed-by: Petre Eftime <epetre@amazon.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
5 years agolivepatch-gcc: Allow toolchain command with versions
Pawel Wieczorkiewicz [Wed, 21 Aug 2019 08:20:37 +0000 (08:20 +0000)]
livepatch-gcc: Allow toolchain command with versions

Xen build system may enforce particular gcc version (e.g. gcc72).
Make sure the livepatch-gcc script accepts all input toolchain gcc
commands with or without version specified.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Martin Mazein <amazein@amazon.de>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
5 years agoIntroduce a MAINTAINERS file
Lars Kurth [Thu, 15 Aug 2019 18:16:27 +0000 (19:16 +0100)]
Introduce a MAINTAINERS file

Rationale: this will allow us to use get_maintainer.pl /
add_maintainers.pl scripts from xen.git

Signed-off-by: Lars Kurth <lars.kurth@citrix.com>
7 years agoRemove section alignment requirement
Ross Lagerwall [Mon, 24 Apr 2017 12:57:57 +0000 (13:57 +0100)]
Remove section alignment requirement

Remove the requirement that section twins (i.e. functions) have the same
alignment. The section alignment of the patched section is respected by
the loader in Xen so it shouldn't matter if the original section
alignment was different.

This was discovered when building a live patch for XSA-213. For reasons
known only to the compiler, the alignment of arch_do_multicall_call()
changed from 1 to 16. This should not prevent the build tools from
generating a live patch.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
7 years agoIgnore .discard sections
Ross Lagerwall [Mon, 24 Apr 2017 11:52:43 +0000 (12:52 +0100)]
Ignore .discard sections

Ignore differences in discard sections. They are not included in the final xen
binary so there is no need to include them in the live patch.

This was discovered when building a live patch for XSA-213. Before this
commit, it failed with 'changed section .discard not selected for
inclusion'.

Reported-by: Sarah Newman <srn@prgmr.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
8 years agoFix patch creation with GCC 6.1+
Ross Lagerwall [Thu, 10 Nov 2016 10:58:45 +0000 (10:58 +0000)]
Fix patch creation with GCC 6.1+

GCC 6.1+ fixed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=192 which
means that .rodata.str1.[0-9]+ sections are now split by function.  We
could probably be smarter about including just the sections we need, but
for now, simply include the string sections for all functions as is done
for previous versions of GCC.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reported-by: M A Young <m.a.young@durham.ac.uk>
8 years agocreate-diff-object: Update fixup offsets in .rela.ex_table
Ross Lagerwall [Thu, 10 Nov 2016 14:37:39 +0000 (14:37 +0000)]
create-diff-object: Update fixup offsets in .rela.ex_table

When pruning entries from the fixup table, update the offsets in
.rela.ex_table otherwise the relas might point to the wrong fixup entry
or even out of the .fixup section.

This is a port of kpatch's commit 13d61012f9b2 ("create-diff-object:
Update fixup offsets in .rela__ex_table").

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
8 years agoPrevent spurious rebuilding
Ross Lagerwall [Wed, 20 Jul 2016 14:42:17 +0000 (15:42 +0100)]
Prevent spurious rebuilding

Don't change the timestamp of arch/x86/Makefile when editing it since it
forces much of the Xen tree to be rebuilt and then requires many
invocations of create-diff-tool.

This is safe since the Makefile change only changes the final link rule,
and xen will be relinked anyway.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
8 years agoFix getopt parsing of long options
Ross Lagerwall [Wed, 20 Jul 2016 14:41:41 +0000 (15:41 +0100)]
Fix getopt parsing of long options

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
8 years agoSupport "make install"
Ross Lagerwall [Thu, 14 Jul 2016 08:34:26 +0000 (09:34 +0100)]
Support "make install"

Add rules to support using "make install".

Use "make install DESTDIR=... PREFIX=..." to customize the installation
path.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
8 years agoCheck .config for CONFIG_DEBUG. If not found use --xen-debug (if specified)
Konrad Rzeszutek Wilk [Fri, 15 Jul 2016 13:36:23 +0000 (09:36 -0400)]
Check .config for CONFIG_DEBUG. If not found use --xen-debug (if specified)

Xen 4.8 ditched the 'debug=y' and now has CONFIG_DEBUG in the
.config. To still support 4.7 lets just poke the .config
file and see.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Ross Lagerwall <ross.lagerwall@citrix.com>
8 years agoUpdate README.md
Ross Lagerwall [Thu, 14 Jul 2016 08:04:42 +0000 (09:04 +0100)]
Update README.md

Update the example and project status. Add Contributing and Maintainers
sections.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
8 years agoUpdate to use a .config file
Ross Lagerwall [Thu, 14 Jul 2016 08:04:40 +0000 (09:04 +0100)]
Update to use a .config file

Require the user to pass a .config file matching the original build's
.config to ensure that the build configuration is identical.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
8 years agoEFI build with -ffunction-sections fails.
Konrad Rzeszutek Wilk [Wed, 13 Jul 2016 20:05:26 +0000 (16:05 -0400)]
EFI build with -ffunction-sections fails.

When we build Xen with the Rules.mk modified we end up:

ld -mi386pep --subsystem=10 --image-base=0xffff82d080000000 --stack=0,0 --heap=0,0 --strip-debug --section-alignment=0x200000 --file-alignment=0x20 --major-image-version=4 --minor-image-version=8 --major-os-version=2 --minor-os-version=0 --major-subsystem-version=2 --minor-subsystem-version=0 -T efi.lds -N prelink-efi.o efi/relocs-dummy.o /home/konrad/xen/xen/common/symbols-dummy.o -o /home/konrad/xen/xen/.xen.efi.0xffff82d080000000.0 &&   ld -mi386pep --subsystem=10 --image-base=0xffff82d0c0000000 --stack=0,0 --heap=0,0 --strip-debug --section-alignment=0x200000 --file-alignment=0x20 --major-image-version=4 --minor-image-version=8 --major-os-version=2 --minor-os-version=0 --major-subsystem-version=2 --minor-subsystem-version=0 -T efi.lds -N prelink-efi.o efi/relocs-dummy.o /home/konrad/xen/xen/common/symbols-dummy.o -o /home/konrad/xen/xen/.xen.efi.0xffff82d0c0000000.0 && :
ld: Xen image overlaps stubs area
prelink-efi.o: In function `__high_start':
/home/konrad/xen/xen/arch/x86/boot/x86_64.S:6:(.text+0x23): relocation truncated to fit: R_X86_64_PC32 against `gdt_descr'
/home/konrad/xen/xen/arch/x86/boot/x86_64.S:18:(.text+0x43): relocation truncated to fit: R_X86_64_PC32 against `stack_start'
/home/konrad/xen/xen/arch/x86/boot/x86_64.S:35:(.text+0x6a): relocation truncated to fit: R_X86_64_PC32 against `.data'
/home/konrad/xen/xen/arch/x86/boot/x86_64.S:36:(.text+0x6f): relocation truncated to fit: R_X86_64_PC32 against `__start_xen'
.. and more.

Re-running it with -M on a build (the giant ld -mi386pep..) with the -ffunction-sections and without it
makes it obvious what the problem is:

With: -ffunction-sections -fdata-sections:

.data           0xffff82d291e18000       0xf8 prelink-efi.o
                0xffff82d291e18006                gdt_descr

*(.text)
.text           0xffff82d0c0100000     0x27e4 prelink-efi.o
                0xffff82d0c0100000                start
                0xffff82d0c0100020                __high_start

distance is 0x1D1D18000

Normal build:

.data           0xffff82d0c0818000     0x12e8 prelink-efi.o
                0xffff82d0c0818006                gdt_descr

.text           0xffff82d0c0100000   0x14b000
                0xffff82d0c0100000                _stext = .
 *(.text)
 .text          0xffff82d0c0100000   0x149243 prelink-efi.o
                0xffff82d0c0100000                start
                0xffff82d0c0100020                __high_start

where the distance is 0x718000

The 0x1D1D18000 is most certainly over the 32-bit limit and leads to the truncation.

Now if we look more closely at the map we can see that each
.text section is:

.text.domain_kill
                0xffff82d0cd200000      0x140
 .text.domain_kill
                0xffff82d0cd200000      0x139 prelink-efi.o
                0xffff82d0cd200000                domain_kill

.text.domain_create
                0xffff82d0cd400000      0x520
 .text.domain_create
                0xffff82d0cd400000      0x502 prelink-efi.o
                0xffff82d0cd400000                domain_create

.. seperated by 2MB!

A bit of grepping showed that the issue is with:

 --section-alignment=0x200000

which is used on the linker command line and this fix
replaces the --section-alignment to be 4KB which allows the build
to complete.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
8 years agoDon't accept fuzz when patching
Ross Lagerwall [Fri, 10 Jun 2016 09:42:06 +0000 (10:42 +0100)]
Don't accept fuzz when patching

When testing and applying patches, set fuzz=0 so that patches must apply
exactly.  Also set "-f" to avoid interactive questions, and reorder so
that patches are tested before the output directory is created.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
8 years agoRename of xSplice to LivePatch.
Konrad Rzeszutek Wilk [Thu, 2 Jun 2016 20:27:27 +0000 (16:27 -0400)]
Rename of xSplice to LivePatch.

s/xsplice/livepatch/
s/XSPLICE/LIVEPATCH/
s/xSplice/LivePatch/

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
8 years agoxsplice-build-tools: replace realpath with readlink in xsplice-build
Dongli Zhang [Sat, 28 May 2016 01:16:58 +0000 (09:16 +0800)]
xsplice-build-tools: replace realpath with readlink in xsplice-build

Replace realpath with readlink since '-m' option is not supported by realpath.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
8 years agoRequire --depends
Ross Lagerwall [Tue, 10 May 2016 12:58:14 +0000 (13:58 +0100)]
Require --depends

WIth the version of xSplice in Xen 4.7, the build-id dependency is required,
so require the option.

8 years agoUpdate the layout of xsplice_patch_func
Ross Lagerwall [Mon, 9 May 2016 10:21:22 +0000 (11:21 +0100)]
Update the layout of xsplice_patch_func

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
8 years agoFix patching functions which use __func__
Ross Lagerwall [Mon, 9 May 2016 10:19:54 +0000 (11:19 +0100)]
Fix patching functions which use __func__

If __func__ is used, it generates a symbol like __func__.5432
Since this is always included (see is_special_static), it will generate
duplicate symbol conflicts if GCC happens to use the same number (which
happens quite often since it doesn't appear to be random). To work
around this, rename the symbol to use a completely random number.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
8 years agoUpdate format of .xsplice.depends section
Ross Lagerwall [Mon, 9 May 2016 09:08:02 +0000 (10:08 +0100)]
Update format of .xsplice.depends section

.xsplice.depends is expected to contain an ELF note, not a plain binary
checksum.

9 years agoUpdate xsplice_patch_func layout
Ross Lagerwall [Wed, 20 Jan 2016 14:11:36 +0000 (14:11 +0000)]
Update xsplice_patch_func layout

Update the structure layout to match the most recent hypervisor version.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
9 years agoRevert "Add 64 bytes of padding to xsplice_patch_funcs structure"
Ross Lagerwall [Wed, 20 Jan 2016 13:48:46 +0000 (13:48 +0000)]
Revert "Add 64 bytes of padding to xsplice_patch_funcs structure"

This reverts commit be95e2474439fbdddcd347e7ea1bd3a842927351.
It doesn't match the hypervisor structure layout in the latest xsplice
code.

9 years agoBackport "handle reference to end of section"
Ross Lagerwall [Tue, 17 Nov 2015 08:06:41 +0000 (08:06 +0000)]
Backport "handle reference to end of section"

Backport fffbb85b811e21d92f4517e78ead5fb3373185e6:
    create-diff-object: handle reference to end of section
from upstream.

Also edit it to work with Xen's code because it is compiled with -fpic.

9 years agoBackport static variable correlation work from upstream
Ross Lagerwall [Fri, 13 Nov 2015 14:39:30 +0000 (14:39 +0000)]
Backport static variable correlation work from upstream

Backport 7c88c41cfe3d ("create-diff-object: rewrite static local
variable correlation logic") from kpatch.

9 years agoAdd more sections to be bundleable
Ross Lagerwall [Fri, 13 Nov 2015 14:39:04 +0000 (14:39 +0000)]
Add more sections to be bundleable

9 years agoRename xsplice back to kpatch for functions coming from kpatch
Ross Lagerwall [Fri, 13 Nov 2015 08:50:31 +0000 (08:50 +0000)]
Rename xsplice back to kpatch for functions coming from kpatch

To ease porting changes from kpatch, only use xsplice for the special
section names and for newly written functions but use the kpatch
namespace for ported functions.

9 years agoFor Xen, treat PLT32 relocations like PC32
Ross Lagerwall [Fri, 13 Nov 2015 08:33:44 +0000 (08:33 +0000)]
For Xen, treat PLT32 relocations like PC32

PLT32 relocations are only used because gcc doesn't support symbol
visibility for builtins like memcpy.

9 years agoBundle .data.rel.ro. and .data.rel.ro.local. sections
Ross Lagerwall [Fri, 13 Nov 2015 08:27:02 +0000 (08:27 +0000)]
Bundle .data.rel.ro. and .data.rel.ro.local. sections

.data.rel.ro(.local). sections are (local) read only data sections with
relocations.

For example:
static const struct hvm_mmio_handler *const
hvm_mmio_handlers[HVM_MMIO_HANDLER_NR] =
{
    &hpet_mmio_handler,
    &vlapic_mmio_handler,
    &vioapic_mmio_handler,
    &msixtbl_mmio_handler,
    &iommu_mmio_handler
};

Allow these sections to be bundled so that section symbols can be
replaced with normal symbols, preventing them from being needlessly
included.

9 years agoAdd support for signing payloads
Ross Lagerwall [Tue, 10 Nov 2015 10:31:55 +0000 (10:31 +0000)]
Add support for signing payloads

Use the module signing infrastructure from Linux 4.3-rc6 to allow
signing payloads.

Example:
$ cd sign
$ make
$ ./sign-file-wrapper /path/to/payload.xsplice

9 years agoMangle local symbols to match Xen's mangling
Ross Lagerwall [Mon, 9 Nov 2015 15:23:33 +0000 (15:23 +0000)]
Mangle local symbols to match Xen's mangling

9 years agoImplement run-time linking
Ross Lagerwall [Fri, 6 Nov 2015 12:55:25 +0000 (12:55 +0000)]
Implement run-time linking

Implement run-time linking and link at run-time by default. Still keep
the option to link at compile time.

9 years agoAllow specifying a build-id dependency
Ross Lagerwall [Thu, 5 Nov 2015 14:10:17 +0000 (14:10 +0000)]
Allow specifying a build-id dependency

Allow including a build-id on which the created patch module depends.
This will then be verified by the hypervisor during patch apply.

9 years agoAdd 64 bytes of padding to xsplice_patch_funcs structure
Ross Lagerwall [Tue, 3 Nov 2015 14:44:49 +0000 (14:44 +0000)]
Add 64 bytes of padding to xsplice_patch_funcs structure

This gives the hypervisor scratch space for undo buffers and possibly
other uses.

9 years agoInclude a build id in xsplice modules
Ross Lagerwall [Mon, 2 Nov 2015 13:36:43 +0000 (13:36 +0000)]
Include a build id in xsplice modules

The build id will in future be used to uniquely identify a module and
for module dependencies.

9 years agoAdd support for hooks and ignore functions and sections
Ross Lagerwall [Fri, 23 Oct 2015 11:31:47 +0000 (12:31 +0100)]
Add support for hooks and ignore functions and sections

9 years agoFix logging from common.c
Ross Lagerwall [Fri, 23 Oct 2015 09:56:11 +0000 (10:56 +0100)]
Fix logging from common.c

9 years agoAdd prelink tool
Ross Lagerwall [Tue, 20 Oct 2015 15:51:37 +0000 (16:51 +0100)]
Add prelink tool

To simplify matters, prelink against a xen-syms file at compile time to
avoid having to resolve symbols at runtime. Create a prelink tool to do
this. Split out the elf loading and saving code of create-diff-object.c
into a common file which is shared by create-diff-object and prelink.

9 years agoClean up code a bit
Ross Lagerwall [Tue, 20 Oct 2015 11:14:10 +0000 (12:14 +0100)]
Clean up code a bit

Make functions and variables static.
Remove trailing whitespace.
Remove unused functions.

9 years agoAdd space for reverting the each applied function
Ross Lagerwall [Tue, 20 Oct 2015 11:12:16 +0000 (12:12 +0100)]
Add space for reverting the each applied function

Add an undo buffer to each xsplice_patch_func object to making reverting
functions easy.

9 years agoFail if the function is too small to patch
Ross Lagerwall [Tue, 20 Oct 2015 10:52:20 +0000 (11:52 +0100)]
Fail if the function is too small to patch

9 years agoAdd support for specifying the path to xen-syms
Ross Lagerwall [Tue, 20 Oct 2015 09:55:16 +0000 (10:55 +0100)]
Add support for specifying the path to xen-syms

This allows linking against a different xen-syms from the original
built. This may be useful if the compile environment or source code is
slightly different.

9 years agoDon't create "reverse" patch modules
Ross Lagerwall [Tue, 13 Oct 2015 13:41:07 +0000 (14:41 +0100)]
Don't create "reverse" patch modules

9 years agoAdd project files
Ross Lagerwall [Mon, 12 Oct 2015 11:25:14 +0000 (12:25 +0100)]
Add project files

xsplice-build can build live patches for most XSAs. It is, however,
still prototype code.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>