diff mbox series

[v2,2/2] x86/boot: Avoid relocations in trampoline code to virtual addresses

Message ID 20240828091956.127760-2-frediano.ziglio@cloud.com (mailing list archive)
State New
Headers show
Series [v2,1/2] x86/boot: Avoid relocations in trampoline code to physical addresses | expand

Commit Message

Frediano Ziglio Aug. 28, 2024, 9:19 a.m. UTC
Add virt_addr macro to make more clear the address we want and making
symbol search easier.
We don't generate direct absolute symbols to virtual addresses to avoid
linker warnings.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
---
 xen/arch/x86/boot/trampoline.S | 3 ++-
 xen/arch/x86/boot/wakeup.S     | 2 +-
 xen/arch/x86/xen.lds.S         | 2 ++
 3 files changed, 5 insertions(+), 2 deletions(-)

Comments

Jan Beulich Sept. 14, 2024, 6:43 a.m. UTC | #1
On 28.08.2024 11:19, Frediano Ziglio wrote:
> Add virt_addr macro to make more clear the address we want and making
> symbol search easier.

This is not good enough a reason to make this change, especially in light
of the address space randomization aspect mentioned in reply to patch 1.
While there it only _may_ get in the way, here I'm sure it _will_. Which
isn't to say we can't go this route, just that it needs proper weighing
(and hence a better justification to start from).

Jan
diff mbox series

Patch

diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S
index 3a6eb942a7..02c713af91 100644
--- a/xen/arch/x86/boot/trampoline.S
+++ b/xen/arch/x86/boot/trampoline.S
@@ -40,6 +40,7 @@ 
         .popsection
 
 #define phys_addr(sym) sym ## _PA
+#define virt_addr(sym) (sym ## _PA + __XEN_VIRT_START)
 
 /* Start of the permanent trampoline code. */
 
@@ -120,7 +121,7 @@  trampoline_protmode_entry:
         .code64
 start64:
         /* Jump to high mappings. */
-        movabs  $__high_start, %rdi
+        movabs  $virt_addr(__high_start), %rdi
         jmpq    *%rdi
 
 #include "video.h"
diff --git a/xen/arch/x86/boot/wakeup.S b/xen/arch/x86/boot/wakeup.S
index ae4dd5eb40..5ac8ba1fb6 100644
--- a/xen/arch/x86/boot/wakeup.S
+++ b/xen/arch/x86/boot/wakeup.S
@@ -156,7 +156,7 @@  wakeup_32:
         .code64
 wakeup_64:
         /* Jump to high mappings and the higher-level wakeup code. */
-        movabs  $s3_resume, %rbx
+        movabs  $virt_addr(s3_resume), %rbx
         jmp     *%rbx
 
 bogus_saved_magic:
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 5cfbd2524a..b200606278 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -77,6 +77,8 @@  SECTIONS
   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 = .;