All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6] xSplice v1 design and implementation.
@ 2016-04-07  3:49 Konrad Rzeszutek Wilk
  2016-04-07  3:49 ` [PATCH v6 01/24] xsplice: Design document Konrad Rzeszutek Wilk
                   ` (23 more replies)
  0 siblings, 24 replies; 85+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-04-07  3:49 UTC (permalink / raw)
  To: xen-devel, konrad, ross.lagerwall, mpohlack, sasha.levin, andrew.cooper3

Hey!

Changelog:
v5: http://lists.xen.org/archives/html/xen-devel/2016-03/msg03286.html
 - Acked on ALL comments from Jan, mentioned which ones this one
   does not have (ran out of time).
    - test on 8 socket machine with tons of patches
    - check the ELF types, not just the names,
    - improve the symbol lookup - don't do linear lookup,
    - handle multiple same sections (same names) or maybe not?
    - resolve whether ELF Note should be in .note or .rodata by default
    - figure out why EFI build with --all-symbols spews errors
v4: http://lists.xen.org/archives/html/xen-devel/2016-03/msg01776.html
 - Lots of review. Lots of rework. Some patches checked in.
v3: http://www.gossamer-threads.com/lists/xen/devel/418262
    and 
    http://lists.xenproject.org/archives/html/xen-devel/2016-02/msg04106.html
 - Act on all reviews.
 - Redo the flow of patches
v2: http://lists.xen.org/archives/html/xen-devel/2016-01/msg01597.html
 - Updated code/docs/design with review comments.
 - Make xen also have an PT_NOTE
 - Added more of Ross's patches
 - Combined build-id patchset with this.
(since the RFC and the Seattle Xen presentation)
 - Finished off some of the work around the build-id.
 - Settled on the preemption mechanism.
 - Cleaned the patches a lot up, broke them up to easy
   review for maintainers.
v1: http://lists.xenproject.org/archives/html/xen-devel/2015-09/msg02116.html
  - Put all the design comments in the code
Prototype: http://lists.xenproject.org/archives/html/xen-devel/2015-10/msg02595.html
[Posting by Ross]
 - Took all reviews into account.
 - Redid the patches


*Tools Maintainers*

All patches acked and have not changed since v5 posting.

*Hypervisor Maintainers*

All the XSM parts have been Acked.

The patch related to VERSION_build_id has been Acked:
 HYPERCALL_version_op: Add VERSION_build_id to retrieve build-id.

The rest of the patches need Acks.

There are two ARM related patches:
  arm/x86: Use struct virtual_region to do bug, symbol, and (x86) exception tables lookup.
  arm/x86/vmap: Add vmalloc_type and vm_init_type

Patchset has been tested on ARM (tweaking the Kconfig to build xSplice and then
booting and using it under ARM CubieTruck), ARM64 (only built it), and x86
(legacy, my EFI box has issues)

*What is xSplice?*

A mechanism to binarily patch the running hypervisor with new
opcodes that have come about due to primarily security updates.

*What will this patchset do once I've it*

Patch the hypervisor.

*Why are you emailing me?*

Please please review as many patches as possible.

*OK, what do you have?*

They are located at a git tree:
  git://xenbits.xen.org/people/konradwilk/xen.git xsplice.v6

(Copying from Ross's email):

Much of the work is implementing a basic version of the Linux kernel module
loader. The code:
* Loading of xSplice ELF payloads.
* Copying allocated sections into a new executable region of memory.
* Resolving symbols.
* Applying relocations.
* Patching of altinstructions.
* Special handling of bug frames and exception tables.
* Unloading of xSplice ELF payloads.
* Compiling a sample xSplice ELF payload
* Resolving symbols
* Using build-id dependencies
* Support for shadow variable framework
* Support for executing ELF payload functions on load/unload.

The other main bit of this work is applying and reverting the patches safely.
As implemented, the code is patched with each CPU waiting in the
return-to-guest path (i.e. with no stack) or on the cpu-idle path
which appears to be the safest way of patching. While it is safe we should
still (in the next wave of patches) to verify to not patch cetain critical
sections (say the code doing the patching)

All of the following should work:
* Applying patches safely.
* Reverting patches safely.
* Replacing patches safely (e.g. reverting any applied patches and applying
   a new patch).
* Bug frames as part of modules. This means adding or
  changing WARN, ASSERT, BUG, and run_in_exception_handler works correctly.
  Line number only changes _are ignored_.
* Exception tables as part of modules. E.g. wrmsr_safe and copy_to_user work
  correctly when used in a patch module.
* Stacking of patches on top of each other
* Resolving symbols (even of patches)

*Limitations*

The above is enough to fully implement an update system where multiple source
patches are combined (using combinediff) and built into a single binary
which then atomically replaces any existing loaded patches
(this is why Ross added a REPLACE operation). This is the approach used
by kPatch and kGraft.

Multiple completely independent patches can also be loaded but unexpected
interactions may occur.

As it stands, the patches are statically linked which means that independent
patches cannot be linked against one another (e.g. if one introduces a
new symbol). Using the combinediff approach above fixes this.

Backtraces containing functions from a patch module do not show the symbol name.

There is no checking that a patch which is loaded is built for the
correct hypervisor (need to use build-id).

Binary patching works at the function level.

*Testing*

You can use the example code included in this patchset:

# xl info | grep extra
xen_extra              : -unstable
# xen-xsplice load /usr/lib/debug/xen_hello_world.xsplice
Uploading /usr/lib/debug/xen_hello_world.xsplice (2071 bytes)
Performing check: completed
Performing apply:. completed
# xl info | grep extra
xen_extra              : Hello World
# xen-xsplice revert xen_hello_world
Performing revert:. completed
# xen-xsplice unload xen_hello_world
Performing unload: completed
# xl info | grep extra
xen_extra              : -unstable

Or you can use git://xenbits.xen.org/people/konradwilk/xsplice-build-tools.git
which generates the ELF payloads.

This link has a nice description of how to use the tool:
http://lists.xenproject.org/archives/html/xen-devel/2015-10/msg02595.html

 .gitignore                                   |    5 +
 Config.mk                                    |   12 +
 MAINTAINERS                                  |   10 +
 docs/misc/xsplice.markdown                   | 1108 +++++++++++++++++++
 tools/flask/policy/policy/modules/xen/xen.te |    2 +
 tools/libxc/include/xenctrl.h                |   62 ++
 tools/libxc/xc_misc.c                        |  337 ++++++
 tools/libxl/libxl.c                          |   18 +-
 tools/libxl/libxl.h                          |    6 +
 tools/libxl/libxl_types.idl                  |    1 +
 tools/libxl/xl_cmdimpl.c                     |    1 +
 tools/misc/Makefile                          |    4 +
 tools/misc/xen-xsplice.c                     |  463 ++++++++
 xen/Makefile                                 |    8 +-
 xen/arch/arm/Makefile                        |    5 +-
 xen/arch/arm/kernel.c                        |    2 +-
 xen/arch/arm/mm.c                            |    2 +-
 xen/arch/arm/setup.c                         |    4 +
 xen/arch/arm/traps.c                         |   39 +-
 xen/arch/arm/xen.lds.S                       |   16 +-
 xen/arch/arm/xsplice.c                       |   88 ++
 xen/arch/x86/Makefile                        |   53 +-
 xen/arch/x86/alternative.c                   |   37 +-
 xen/arch/x86/boot/mkelf32.c                  |  129 ++-
 xen/arch/x86/domain.c                        |    2 +
 xen/arch/x86/extable.c                       |   41 +-
 xen/arch/x86/mm.c                            |    2 +-
 xen/arch/x86/setup.c                         |    6 +
 xen/arch/x86/test/Makefile                   |   81 ++
 xen/arch/x86/test/xen_bye_world.c            |   35 +
 xen/arch/x86/test/xen_bye_world_func.c       |   24 +
 xen/arch/x86/test/xen_hello_world.c          |   33 +
 xen/arch/x86/test/xen_hello_world_func.c     |   38 +
 xen/arch/x86/test/xen_replace_world.c        |   34 +
 xen/arch/x86/test/xen_replace_world_func.c   |   24 +
 xen/arch/x86/traps.c                         |   51 +-
 xen/arch/x86/xen.lds.S                       |   27 +
 xen/arch/x86/xsplice.c                       |  274 +++++
 xen/common/Kconfig                           |   16 +
 xen/common/Makefile                          |    3 +
 xen/common/kernel.c                          |    4 +
 xen/common/symbols.c                         |   43 +-
 xen/common/sysctl.c                          |    7 +
 xen/common/version.c                         |   70 ++
 xen/common/virtual_region.c                  |  148 +++
 xen/common/vmap.c                            |  160 +--
 xen/common/vsprintf.c                        |   19 +-
 xen/common/xsplice.c                         | 1530 ++++++++++++++++++++++++++
 xen/common/xsplice_elf.c                     |  480 ++++++++
 xen/drivers/acpi/osl.c                       |    2 +-
 xen/include/asm-x86/alternative.h            |    4 +
 xen/include/asm-x86/current.h                |   10 +-
 xen/include/asm-x86/nmi.h                    |    4 +-
 xen/include/asm-x86/uaccess.h                |    2 +
 xen/include/public/sysctl.h                  |  166 +++
 xen/include/public/version.h                 |    3 +
 xen/include/xen/symbols.h                    |   11 +
 xen/include/xen/version.h                    |    6 +
 xen/include/xen/virtual_region.h             |   47 +
 xen/include/xen/vmap.h                       |   47 +-
 xen/include/xen/xsplice.h                    |  138 +++
 xen/include/xen/xsplice_elf.h                |   56 +
 xen/include/xen/xsplice_patch.h              |   25 +
 xen/xsm/flask/hooks.c                        |    9 +
 xen/xsm/flask/policy/access_vectors          |    4 +
 65 files changed, 5915 insertions(+), 183 deletions(-)

Konrad Rzeszutek Wilk (15):
      xsplice: Design document
      xen/xsplice: Hypervisor implementation of XEN_XSPLICE_op
      libxc: Implementation of XEN_XSPLICE_op in libxc
      xen-xsplice: Tool to manipulate xsplice payloads
      arm/x86: Use struct virtual_region to do bug, symbol, and (x86) exception tables lookup.
      x86: Alter nmi_callback_t typedef
      arm/x86/vmap: Add vmalloc_type and vm_init_type
      x86/xen_hello_world.xsplice: Test payload for patching 'xen_extra_version'.
      build_id: Provide ld-embedded build-ids
      HYPERCALL_version_op: Add VERSION_build_id to retrieve build-id.
      libxl: info: Display build_id of the hypervisor using XEN_VERSION_build_id
      xsplice: Print build_id in keyhandler and on bootup.
      xsplice: Stacking build-id dependency checking.
      xsplice/xen_replace_world: Test-case for XSPLICE_ACTION_REPLACE
      MAINTAINERS/xsplice: Add myself and Ross as the maintainers.

Ross Lagerwall (9):
      xsplice: Add helper elf routines
      xsplice: Implement payload loading
      xsplice: Implement support for applying/reverting/replacing patches.
      xsplice,symbols: Implement symbol name resolution on address.
      x86, xsplice: Print payload's symbol name and payload name in backtraces
      xsplice: Add support for bug frames.
      xsplice: Add support for exception tables.
      xsplice: Add support for alternatives
      xsplice: Prevent duplicate payloads from being loaded.


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 85+ messages in thread

end of thread, other threads:[~2016-04-11 18:57 UTC | newest]

Thread overview: 85+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-07  3:49 [PATCH v6] xSplice v1 design and implementation Konrad Rzeszutek Wilk
2016-04-07  3:49 ` [PATCH v6 01/24] xsplice: Design document Konrad Rzeszutek Wilk
2016-04-07 16:34   ` Ian Jackson
2016-04-07  3:49 ` [PATCH v6 02/24] xen/xsplice: Hypervisor implementation of XEN_XSPLICE_op Konrad Rzeszutek Wilk
2016-04-07 14:47   ` Andrew Cooper
2016-04-08 18:30   ` Konrad Rzeszutek Wilk
2016-04-07  3:49 ` [PATCH v6 03/24] libxc: Implementation of XEN_XSPLICE_op in libxc Konrad Rzeszutek Wilk
2016-04-07 19:53   ` Andrew Cooper
2016-04-07  3:49 ` [PATCH v6 04/24] xen-xsplice: Tool to manipulate xsplice payloads Konrad Rzeszutek Wilk
2016-04-07  3:49 ` [PATCH v6 05/24] arm/x86: Use struct virtual_region to do bug, symbol, and (x86) exception tables lookup Konrad Rzeszutek Wilk
2016-04-07 20:12   ` Andrew Cooper
2016-04-08 15:30   ` Julien Grall
2016-04-07  3:49 ` [PATCH v6 06/24] x86: Alter nmi_callback_t typedef Konrad Rzeszutek Wilk
2016-04-07 16:35   ` Ian Jackson
2016-04-07 20:13   ` Andrew Cooper
2016-04-08 20:44     ` Konrad Rzeszutek Wilk
2016-04-07  3:49 ` [PATCH v6 07/24] arm/x86/vmap: Add vmalloc_type and vm_init_type Konrad Rzeszutek Wilk
2016-04-08 14:22   ` Andrew Cooper
2016-04-08 17:19     ` Jan Beulich
2016-04-09  1:10       ` Konrad Rzeszutek Wilk
2016-04-08 15:32   ` Julien Grall
2016-04-07  3:49 ` [PATCH v6 08/24] xsplice: Add helper elf routines Konrad Rzeszutek Wilk
2016-04-07 16:19   ` Ian Jackson
2016-04-07 17:23     ` Jan Beulich
2016-04-07 20:32     ` Andrew Cooper
2016-04-08 13:26       ` Ian Jackson
2016-04-07 20:43     ` Konrad Rzeszutek Wilk
2016-04-08 14:53   ` Andrew Cooper
2016-04-08 21:26     ` Konrad Rzeszutek Wilk
2016-04-08 22:10       ` Andrew Cooper
2016-04-08 22:48         ` Jan Beulich
2016-04-07  3:49 ` [PATCH v6 09/24] xsplice: Implement payload loading Konrad Rzeszutek Wilk
2016-04-08 15:31   ` Andrew Cooper
2016-04-08 21:10     ` Konrad Rzeszutek Wilk
2016-04-08 21:18       ` Jan Beulich
2016-04-08 22:45         ` Konrad Rzeszutek Wilk
2016-04-08 22:50           ` Jan Beulich
2016-04-09  0:37             ` Konrad Rzeszutek Wilk
2016-04-09 11:48               ` Konrad Rzeszutek Wilk
2016-04-11 15:53               ` Jan Beulich
2016-04-11 16:03                 ` Konrad Rzeszutek Wilk
2016-04-11 16:34                   ` Konrad Rzeszutek Wilk
2016-04-11 16:55                     ` Jan Beulich
2016-04-11 17:08                       ` Konrad Rzeszutek Wilk
2016-04-11 17:26                         ` Jan Beulich
2016-04-11 18:21                           ` Konrad Rzeszutek Wilk
2016-04-11 18:57                             ` Konrad Rzeszutek Wilk
2016-04-08 15:35   ` Julien Grall
2016-04-07  3:49 ` [PATCH v6 10/24] xsplice: Implement support for applying/reverting/replacing patches Konrad Rzeszutek Wilk
2016-04-08 15:36   ` Julien Grall
2016-04-08 16:33   ` Andrew Cooper
2016-04-07  3:49 ` [PATCH v6 11/24] x86/xen_hello_world.xsplice: Test payload for patching 'xen_extra_version' Konrad Rzeszutek Wilk
2016-04-08 15:37   ` Julien Grall
2016-04-08 16:38   ` Andrew Cooper
2016-04-09  0:45   ` Konrad Rzeszutek Wilk
2016-04-07  3:49 ` [PATCH v6 12/24] xsplice, symbols: Implement symbol name resolution on address Konrad Rzeszutek Wilk
2016-04-08 16:55   ` Andrew Cooper
2016-04-07  3:49 ` [PATCH v6 13/24] x86, xsplice: Print payload's symbol name and payload name in backtraces Konrad Rzeszutek Wilk
2016-04-08 17:00   ` Andrew Cooper
2016-04-07  3:49 ` [PATCH v6 14/24] xsplice: Add support for bug frames Konrad Rzeszutek Wilk
2016-04-08 17:03   ` Andrew Cooper
2016-04-07  3:49 ` [PATCH v6 15/24] xsplice: Add support for exception tables Konrad Rzeszutek Wilk
2016-04-08 17:16   ` Andrew Cooper
2016-04-07  3:49 ` [PATCH v6 16/24] xsplice: Add support for alternatives Konrad Rzeszutek Wilk
2016-04-08 17:34   ` Andrew Cooper
2016-04-08 17:57     ` Jan Beulich
2016-04-07  3:49 ` [PATCH v6 17/24] build_id: Provide ld-embedded build-ids Konrad Rzeszutek Wilk
2016-04-08 15:39   ` Julien Grall
2016-04-08 18:07   ` Andrew Cooper
2016-04-08 19:34     ` Konrad Rzeszutek Wilk
2016-04-07  3:49 ` [PATCH v6 18/24] HYPERCALL_version_op: Add VERSION_build_id to retrieve build-id Konrad Rzeszutek Wilk
2016-04-08 18:07   ` Andrew Cooper
2016-04-07  3:49 ` [PATCH v6 19/24] libxl: info: Display build_id of the hypervisor using XEN_VERSION_build_id Konrad Rzeszutek Wilk
2016-04-07  3:49 ` [PATCH v6 20/24] xsplice: Print build_id in keyhandler and on bootup Konrad Rzeszutek Wilk
2016-04-08 18:12   ` Andrew Cooper
2016-04-07  3:49 ` [PATCH v6 21/24] xsplice: Stacking build-id dependency checking Konrad Rzeszutek Wilk
2016-04-08 18:19   ` Andrew Cooper
2016-04-09  1:43     ` Konrad Rzeszutek Wilk
2016-04-07  3:49 ` [PATCH v6 22/24] xsplice/xen_replace_world: Test-case for XSPLICE_ACTION_REPLACE Konrad Rzeszutek Wilk
2016-04-08 18:20   ` Andrew Cooper
2016-04-07  3:49 ` [PATCH v6 23/24] xsplice: Prevent duplicate payloads from being loaded Konrad Rzeszutek Wilk
2016-04-07 16:36   ` Ian Jackson
2016-04-08 18:21   ` Andrew Cooper
2016-04-07  3:49 ` [PATCH v6 24/24] MAINTAINERS/xsplice: Add myself and Ross as the maintainers Konrad Rzeszutek Wilk
2016-04-08 18:21   ` Andrew Cooper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.