From: Frediano Ziglio <frediano.ziglio@cloud.com>
To: xen-devel@lists.xenproject.org
Cc: "Frediano Ziglio" <frediano.ziglio@cloud.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Alejandro Vallejo" <alejandro.vallejo@cloud.com>
Subject: [PATCH] Avoid additional relocations in trampoline code
Date: Thu, 22 Aug 2024 16:29:51 +0100 [thread overview]
Message-ID: <20240822152953.489136-1-frediano.ziglio@cloud.com> (raw)
The trampoline could have "manual" relocation entries (created
by assembly macros and some code to use them) and (in case of PE)
normal executable relocations.
Remove all normal executable ones. In this way we don't have to
worry about applying both correctly (they need proper order
which is hard to spot looking at the code).
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
---
xen/arch/x86/boot/trampoline.S | 4 ++--
xen/arch/x86/boot/wakeup.S | 6 +++---
xen/arch/x86/xen.lds.S | 7 ++++++-
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S
index b8ab0ffdcb..0724c953e2 100644
--- a/xen/arch/x86/boot/trampoline.S
+++ b/xen/arch/x86/boot/trampoline.S
@@ -73,7 +73,7 @@ trampoline_protmode_entry:
mov %ecx,%cr4
/* Load pagetable base register. */
- mov $sym_offs(idle_pg_table),%eax
+ mov $idle_pg_table_pa, %eax
add bootsym_rel(trampoline_xen_phys_start,4,%eax)
mov %eax,%cr3
@@ -113,7 +113,7 @@ trampoline_protmode_entry:
.code64
start64:
/* Jump to high mappings. */
- movabs $__high_start, %rdi
+ movabs $__high_start_pa + __XEN_VIRT_START, %rdi
jmpq *%rdi
#include "video.h"
diff --git a/xen/arch/x86/boot/wakeup.S b/xen/arch/x86/boot/wakeup.S
index 08447e1934..ebe72e1fdd 100644
--- a/xen/arch/x86/boot/wakeup.S
+++ b/xen/arch/x86/boot/wakeup.S
@@ -99,7 +99,7 @@ wakeup_32:
mov $bootsym_rel(wakeup_stack, 4, %esp)
# check saved magic again
- mov $sym_offs(saved_magic),%eax
+ mov $saved_magic_pa, %eax
add bootsym_rel(trampoline_xen_phys_start, 4, %eax)
mov (%eax), %eax
cmp $0x9abcdef0, %eax
@@ -112,7 +112,7 @@ wakeup_32:
mov %ecx, %cr4
/* Load pagetable base register */
- mov $sym_offs(idle_pg_table),%eax
+ mov $idle_pg_table_pa ,%eax
add bootsym_rel(trampoline_xen_phys_start,4,%eax)
mov %eax,%cr3
@@ -156,7 +156,7 @@ wakeup_32:
.code64
wakeup_64:
/* Jump to high mappings and the higher-level wakeup code. */
- movabs $s3_resume, %rbx
+ movabs $s3_resume_pa + __XEN_VIRT_START, %rbx
jmp *%rbx
bogus_saved_magic:
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 9a1dfe1b34..8e604dde48 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -71,7 +71,12 @@ SECTIONS
__2M_text_start = .; /* Start of 2M superpages, mapped RX. */
#endif
- start_pa = ABSOLUTE(start - __XEN_VIRT_START);
+#define DEFINE_PA_ADDRESS(sym) sym ## _pa = ABSOLUTE(sym - __XEN_VIRT_START)
+ DEFINE_PA_ADDRESS(start);
+ DEFINE_PA_ADDRESS(saved_magic);
+ DEFINE_PA_ADDRESS(idle_pg_table);
+ DEFINE_PA_ADDRESS(__high_start);
+ DEFINE_PA_ADDRESS(s3_resume);
. = __XEN_VIRT_START + XEN_IMG_OFFSET;
_start = .;
--
2.46.0
next reply other threads:[~2024-08-22 15:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-22 15:29 Frediano Ziglio [this message]
2024-08-26 8:21 ` [PATCH] Avoid additional relocations in trampoline code Jan Beulich
2024-08-27 13:56 ` Frediano Ziglio
2024-08-27 15:50 ` Jan Beulich
2024-08-28 7:51 ` 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=20240822152953.489136-1-frediano.ziglio@cloud.com \
--to=frediano.ziglio@cloud.com \
--cc=alejandro.vallejo@cloud.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=roger.pau@citrix.com \
--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.