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>
Subject: [PATCH 06/11] x86/boot: Use stack to remove a relocation from trampoline code
Date: Fri, 4 Dec 2026 20:50:39 +0000 [thread overview]
Message-ID: <20261204205045.596093-7-freddy77@gmail.com> (raw)
In-Reply-To: <20261204205045.596093-1-freddy77@gmail.com>
The destination selector is computed from a GDT entry.
The stack is setup anyway to allow calling real mode interrupts.
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
---
xen/arch/x86/boot/trampoline.S | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S
index c52c27795d..faa5bb9e30 100644
--- a/xen/arch/x86/boot/trampoline.S
+++ b/xen/arch/x86/boot/trampoline.S
@@ -27,13 +27,6 @@
.long 111b - (off) - .; \
.popsection
-#define bootsym_segrel(sym, off) \
- $0,$bootsym(sym); \
-111:; \
- .pushsection .trampoline_seg, "a"; \
- .long 111b - (off) - .; \
- .popsection
-
/* Start of the permanent trampoline code. */
.code16
@@ -210,6 +203,9 @@ trampoline_boot_cpu_entry:
mov %eax,%gs
mov %eax,%ss
+ /* Initialise stack pointer. */
+ xor %esp, %esp
+
/* Switch to pseudo-rm CS, enter real mode, and flush insn queue. */
mov %cr0,%eax
dec %eax
@@ -218,14 +214,16 @@ trampoline_boot_cpu_entry:
1: mov %eax,%cr0 # CR0.PE = 0 (leave protected mode)
/* Load proper real-mode values into %cs, %ds, %es and %ss. */
- ljmp bootsym_segrel(1f,2)
-1: mov %cs,%ax
- mov %ax,%ds
+ mov bootsym(trampoline_gdt)+BOOT_PSEUDORM_DS+3, %ax
+ shl $4, %ax
+ pushw %ax
+ pushw $bootsym(1f)
+ lretw
+1: mov %ax,%ds
mov %ax,%es
mov %ax,%ss
- /* Initialise stack pointer and IDT, and enable irqs. */
- xor %esp,%esp
+ /* Initialise IDT, and enable irqs. */
lidt bootsym(rm_idt)
sti
--
2.43.0
next prev parent 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 [PATCH 00/11] x86/boot: Improve trampoline code Frediano Ziglio
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 ` Frediano Ziglio [this message]
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-7-freddy77@gmail.com \
--to=freddy77@gmail.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=roger@xenproject.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.