[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 00/11] x86/boot: Improve trampoline code



This series collect different attempts and idea to improve trampoline
code.

Most of the changes improve relocation handling:
- binary relocations on the final binary causes issues with PE format
  (used for EFI firmwares) as our code need to relocate from loader
  position to final one. To fix that use absolute symbols generated by
  the linker script. Checks are added to avoid adding back other
  relocations;
- apply relocations after the copy to lower memory. This avoids writing
  into code section;
- use a copy of the data section inside the trampoline in the final binary
  executable to avoid changing the original trampoline;
- trampoline code is back in the final binary code section for EFI builds.

General improvements:
- add some checks and cleanup in the code handling S3 resume;
- reuse code to switch to 64 bit, almost identical besides useless
  differences.

Added safety:
- assembly bootsym macro now assure symbols are in the same section;
- C bootsym* macros check for symbol type;
- check there are no relocation inside the trampoline in the final
  binary (mentioned above);
- compile trampoline in a separate object to avoid head.S to access
  unwanted symbols in the trampoline.

Frediano Ziglio (11):
  x86/boot: Prevent some possible firmware misbehaviour
  x86/boot: Avoid PE relocations in the trampoline
  x86/boot: Check at build time that the trampoline needs no relocations
  x86/boot: Reduce relocations in the trampoline
  x86/boot: Share the switch to 64-bit mode between SIPI and S3 paths
  x86/boot: Use stack to remove a relocation from trampoline code
  x86/boot: Apply relocations in the trampoline after the copy
  x86/boot: Group trampoline code and data using subsections
  x86/boot: Use a writable copy of the trampoline data
  x86/boot: Assemble the trampoline separately from head.S
  x86/boot: Check the kind of symbols passed to the bootsym helpers

 xen/arch/arm/efi/efi-boot.h             |   4 +
 xen/arch/x86/Makefile                   |   5 +-
 xen/arch/x86/boot/.gitignore            |   1 +
 xen/arch/x86/boot/Makefile              |  20 +-
 xen/arch/x86/boot/boot.h                |  26 +++
 xen/arch/x86/boot/build32.lds.S         |   8 +-
 xen/arch/x86/boot/cmdline.c             |   2 +-
 xen/arch/x86/boot/copy-trampoline.c     |  67 +++++++
 xen/arch/x86/boot/edd.S                 |  26 +--
 xen/arch/x86/boot/head.S                |  52 +----
 xen/arch/x86/boot/mem.S                 |  12 +-
 xen/arch/x86/boot/reloc-trampoline.c    |  34 ----
 xen/arch/x86/boot/trampoline.S          | 242 +++++++++++++++++++-----
 xen/arch/x86/boot/video.S               |  24 ++-
 xen/arch/x86/boot/wakeup.S              | 114 ++++-------
 xen/arch/x86/efi/efi-boot.h             |  21 +-
 xen/arch/x86/efi/mbi2.c                 |   4 +
 xen/arch/x86/include/asm/boot-helpers.h |   3 +-
 xen/arch/x86/include/asm/trampoline.h   |  51 ++++-
 xen/arch/x86/setup.c                    |   6 +-
 xen/arch/x86/tboot.c                    |   2 +-
 xen/arch/x86/xen.lds.S                  |  33 +++-
 xen/common/efi/boot.c                   |   1 +
 xen/tools/check-abs-symbols.sh          |  50 +++++
 xen/tools/check-trampoline-relocs.sh    |  47 +++++
 25 files changed, 604 insertions(+), 251 deletions(-)
 create mode 100644 xen/arch/x86/boot/boot.h
 create mode 100644 xen/arch/x86/boot/copy-trampoline.c
 delete mode 100644 xen/arch/x86/boot/reloc-trampoline.c
 create mode 100755 xen/tools/check-abs-symbols.sh
 create mode 100755 xen/tools/check-trampoline-relocs.sh

-- 
2.43.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.