All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frediano Ziglio <freddy77@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: "Frediano Ziglio" <freddy77@gmail.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger@xenproject.org>,
	"Teddy Astie" <teddy.astie@vates.tech>,
	"Daniel P. Smith" <dpsmith@apertussolutions.com>,
	"Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>,
	"Anthony PERARD" <anthony.perard@vates.tech>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Julien Grall" <julien@xen.org>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Bertrand Marquis" <bertrand.marquis@arm.com>,
	"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
	"Lukasz Hawrylko" <lukasz@hawrylko.pl>,
	"Mateusz Mówka" <mateusz.mowka@intel.com>
Subject: [PATCH 00/11] x86/boot: Improve trampoline code
Date: Fri,  4 Dec 2026 20:50:33 +0000	[thread overview]
Message-ID: <20261204205045.596093-1-freddy77@gmail.com> (raw)

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



             reply	other threads:[~2026-12-04 20:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 20:50 Frediano Ziglio [this message]
2026-12-04 20:50 ` [PATCH 01/11] x86/boot: Prevent some possible firmware misbehaviour Frediano Ziglio
2026-12-04 20:50 ` [PATCH 02/11] x86/boot: Avoid PE relocations in the trampoline Frediano Ziglio
2026-12-04 20:50 ` [PATCH 03/11] x86/boot: Check at build time that the trampoline needs no relocations Frediano Ziglio
2026-12-04 20:50 ` [PATCH 04/11] x86/boot: Reduce relocations in the trampoline Frediano Ziglio
2026-12-04 20:50 ` [PATCH 05/11] x86/boot: Share the switch to 64-bit mode between SIPI and S3 paths Frediano Ziglio
2026-12-04 20:50 ` [PATCH 06/11] x86/boot: Use stack to remove a relocation from trampoline code Frediano Ziglio
2026-12-04 20:50 ` [PATCH 07/11] x86/boot: Apply relocations in the trampoline after the copy Frediano Ziglio
2026-12-04 20:50 ` [PATCH 08/11] x86/boot: Group trampoline code and data using subsections Frediano Ziglio
2026-12-04 20:50 ` [PATCH 09/11] x86/boot: Use a writable copy of the trampoline data Frediano Ziglio
2026-12-04 20:50 ` [PATCH 10/11] x86/boot: Assemble the trampoline separately from head.S Frediano Ziglio
2026-12-04 20:50 ` [PATCH 11/11] x86/boot: Check the kind of symbols passed to the bootsym helpers Frediano Ziglio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204205045.596093-1-freddy77@gmail.com \
    --to=freddy77@gmail.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=bertrand.marquis@arm.com \
    --cc=dpsmith@apertussolutions.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=lukasz@hawrylko.pl \
    --cc=marmarek@invisiblethingslab.com \
    --cc=mateusz.mowka@intel.com \
    --cc=michal.orzel@amd.com \
    --cc=roger@xenproject.org \
    --cc=sstabellini@kernel.org \
    --cc=teddy.astie@vates.tech \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.