Use ordinary RIP-relative references to make the code compatible with
running the linker in PIE mode.
Note that wakeup_long64() runs in the kernel's ordinary virtual mapping
so there is no need to record the address of .Lresume_point in a global
variable. And fix the comment while at it.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/x86/kernel/acpi/wakeup_64.S | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S
index 04f561f75e99..15233a4e1c95 100644
--- a/arch/x86/kernel/acpi/wakeup_64.S
+++ b/arch/x86/kernel/acpi/wakeup_64.S
@@ -14,7 +14,7 @@
.code64
/*
- * Hooray, we are in Long 64-bit mode (but still running in low memory)
+ * Hooray, we are in Long 64-bit mode
*/
SYM_FUNC_START(wakeup_long64)
ANNOTATE_NOENDBR
@@ -41,7 +41,7 @@ SYM_FUNC_START(wakeup_long64)
movq saved_rsi(%rip), %rsi
movq saved_rbp(%rip), %rbp
- movq saved_rip(%rip), %rax
+ leaq .Lresume_point(%rip), %rax
ANNOTATE_RETPOLINE_SAFE
jmp *%rax
SYM_FUNC_END(wakeup_long64)
@@ -52,7 +52,7 @@ SYM_FUNC_START(do_suspend_lowlevel)
xorl %eax, %eax
call save_processor_state
- movq $saved_context, %rax
+ leaq saved_context(%rip), %rax
movq %rsp, pt_regs_sp(%rax)
movq %rbp, pt_regs_bp(%rax)
movq %rsi, pt_regs_si(%rax)
@@ -71,8 +71,6 @@ SYM_FUNC_START(do_suspend_lowlevel)
pushfq
popq pt_regs_flags(%rax)
- movq $.Lresume_point, saved_rip(%rip)
-
movq %rsp, saved_rsp(%rip)
movq %rbp, saved_rbp(%rip)
movq %rbx, saved_rbx(%rip)
@@ -90,7 +88,7 @@ SYM_FUNC_START(do_suspend_lowlevel)
.Lresume_point:
ANNOTATE_NOENDBR
/* We don't restore %rax, it must be 0 anyway */
- movq $saved_context, %rax
+ leaq saved_context(%rip), %rax
movq saved_context_cr4(%rax), %rbx
movq %rbx, %cr4
movq saved_context_cr3(%rax), %rbx
@@ -139,7 +137,6 @@ saved_rsi: .quad 0
saved_rdi: .quad 0
saved_rbx: .quad 0
-saved_rip: .quad 0
saved_rsp: .quad 0
SYM_DATA(saved_magic, .quad 0)
--
2.47.3
On Thu, Jan 8, 2026 at 4:28 AM Ard Biesheuvel <ardb@kernel.org> wrote: > > Use ordinary RIP-relative references to make the code compatible with > running the linker in PIE mode. > > Note that wakeup_long64() runs in the kernel's ordinary virtual mapping > so there is no need to record the address of .Lresume_point in a global > variable. And fix the comment while at it. > > Signed-off-by: Ard Biesheuvel <ardb@kernel.org> > --- > arch/x86/kernel/acpi/wakeup_64.S | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S > index 04f561f75e99..15233a4e1c95 100644 > --- a/arch/x86/kernel/acpi/wakeup_64.S > +++ b/arch/x86/kernel/acpi/wakeup_64.S > @@ -14,7 +14,7 @@ > > .code64 > /* > - * Hooray, we are in Long 64-bit mode (but still running in low memory) > + * Hooray, we are in Long 64-bit mode > */ > SYM_FUNC_START(wakeup_long64) > ANNOTATE_NOENDBR > @@ -41,7 +41,7 @@ SYM_FUNC_START(wakeup_long64) > movq saved_rsi(%rip), %rsi > movq saved_rbp(%rip), %rbp > > - movq saved_rip(%rip), %rax > + leaq .Lresume_point(%rip), %rax > ANNOTATE_RETPOLINE_SAFE > jmp *%rax If this is already running on the virtual mapping, this can simply be changed to a direct jump. Brian Gerst
On Fri, 9 Jan 2026 at 06:01, Brian Gerst <brgerst@gmail.com> wrote: > > On Thu, Jan 8, 2026 at 4:28 AM Ard Biesheuvel <ardb@kernel.org> wrote: > > > > Use ordinary RIP-relative references to make the code compatible with > > running the linker in PIE mode. > > > > Note that wakeup_long64() runs in the kernel's ordinary virtual mapping > > so there is no need to record the address of .Lresume_point in a global > > variable. And fix the comment while at it. > > > > Signed-off-by: Ard Biesheuvel <ardb@kernel.org> > > --- > > arch/x86/kernel/acpi/wakeup_64.S | 11 ++++------- > > 1 file changed, 4 insertions(+), 7 deletions(-) > > > > diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S > > index 04f561f75e99..15233a4e1c95 100644 > > --- a/arch/x86/kernel/acpi/wakeup_64.S > > +++ b/arch/x86/kernel/acpi/wakeup_64.S > > @@ -14,7 +14,7 @@ > > > > .code64 > > /* > > - * Hooray, we are in Long 64-bit mode (but still running in low memory) > > + * Hooray, we are in Long 64-bit mode > > */ > > SYM_FUNC_START(wakeup_long64) > > ANNOTATE_NOENDBR > > @@ -41,7 +41,7 @@ SYM_FUNC_START(wakeup_long64) > > movq saved_rsi(%rip), %rsi > > movq saved_rbp(%rip), %rbp > > > > - movq saved_rip(%rip), %rax > > + leaq .Lresume_point(%rip), %rax > > ANNOTATE_RETPOLINE_SAFE > > jmp *%rax > > If this is already running on the virtual mapping, this can simply be > changed to a direct jump. > Indeed, but I couldn't figure out how to do so without making objtool unhappy.
On Fri, Jan 9, 2026 at 2:59 AM Ard Biesheuvel <ardb@kernel.org> wrote: > > On Fri, 9 Jan 2026 at 06:01, Brian Gerst <brgerst@gmail.com> wrote: > > > > On Thu, Jan 8, 2026 at 4:28 AM Ard Biesheuvel <ardb@kernel.org> wrote: > > > > > > Use ordinary RIP-relative references to make the code compatible with > > > running the linker in PIE mode. > > > > > > Note that wakeup_long64() runs in the kernel's ordinary virtual mapping > > > so there is no need to record the address of .Lresume_point in a global > > > variable. And fix the comment while at it. > > > > > > Signed-off-by: Ard Biesheuvel <ardb@kernel.org> > > > --- > > > arch/x86/kernel/acpi/wakeup_64.S | 11 ++++------- > > > 1 file changed, 4 insertions(+), 7 deletions(-) > > > > > > diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S > > > index 04f561f75e99..15233a4e1c95 100644 > > > --- a/arch/x86/kernel/acpi/wakeup_64.S > > > +++ b/arch/x86/kernel/acpi/wakeup_64.S > > > @@ -14,7 +14,7 @@ > > > > > > .code64 > > > /* > > > - * Hooray, we are in Long 64-bit mode (but still running in low memory) > > > + * Hooray, we are in Long 64-bit mode > > > */ > > > SYM_FUNC_START(wakeup_long64) > > > ANNOTATE_NOENDBR > > > @@ -41,7 +41,7 @@ SYM_FUNC_START(wakeup_long64) > > > movq saved_rsi(%rip), %rsi > > > movq saved_rbp(%rip), %rbp > > > > > > - movq saved_rip(%rip), %rax > > > + leaq .Lresume_point(%rip), %rax > > > ANNOTATE_RETPOLINE_SAFE > > > jmp *%rax > > > > If this is already running on the virtual mapping, this can simply be > > changed to a direct jump. > > > > Indeed, but I couldn't figure out how to do so without making objtool unhappy. I replaced it with a simple "jmp .Lresume_point" and objtool seemed fine with it on a defconfig build. What error did you see?
On Fri, 9 Jan 2026 at 12:46, Brian Gerst <brgerst@gmail.com> wrote: > > On Fri, Jan 9, 2026 at 2:59 AM Ard Biesheuvel <ardb@kernel.org> wrote: > > > > On Fri, 9 Jan 2026 at 06:01, Brian Gerst <brgerst@gmail.com> wrote: > > > > > > On Thu, Jan 8, 2026 at 4:28 AM Ard Biesheuvel <ardb@kernel.org> wrote: > > > > > > > > Use ordinary RIP-relative references to make the code compatible with > > > > running the linker in PIE mode. > > > > > > > > Note that wakeup_long64() runs in the kernel's ordinary virtual mapping > > > > so there is no need to record the address of .Lresume_point in a global > > > > variable. And fix the comment while at it. > > > > > > > > Signed-off-by: Ard Biesheuvel <ardb@kernel.org> > > > > --- > > > > arch/x86/kernel/acpi/wakeup_64.S | 11 ++++------- > > > > 1 file changed, 4 insertions(+), 7 deletions(-) > > > > > > > > diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S > > > > index 04f561f75e99..15233a4e1c95 100644 > > > > --- a/arch/x86/kernel/acpi/wakeup_64.S > > > > +++ b/arch/x86/kernel/acpi/wakeup_64.S > > > > @@ -14,7 +14,7 @@ > > > > > > > > .code64 > > > > /* > > > > - * Hooray, we are in Long 64-bit mode (but still running in low memory) > > > > + * Hooray, we are in Long 64-bit mode > > > > */ > > > > SYM_FUNC_START(wakeup_long64) > > > > ANNOTATE_NOENDBR > > > > @@ -41,7 +41,7 @@ SYM_FUNC_START(wakeup_long64) > > > > movq saved_rsi(%rip), %rsi > > > > movq saved_rbp(%rip), %rbp > > > > > > > > - movq saved_rip(%rip), %rax > > > > + leaq .Lresume_point(%rip), %rax > > > > ANNOTATE_RETPOLINE_SAFE > > > > jmp *%rax > > > > > > If this is already running on the virtual mapping, this can simply be > > > changed to a direct jump. > > > > > > > Indeed, but I couldn't figure out how to do so without making objtool unhappy. > > I replaced it with a simple "jmp .Lresume_point" and objtool seemed > fine with it on a defconfig build. What error did you see? arch/x86/kernel/acpi/wakeup_64.o: warning: objtool: wakeup_long64() falls through to next function do_suspend_lowlevel()
On Fri, 9 Jan 2026 at 13:09, Ard Biesheuvel <ardb@kernel.org> wrote: > > On Fri, 9 Jan 2026 at 12:46, Brian Gerst <brgerst@gmail.com> wrote: > > > > On Fri, Jan 9, 2026 at 2:59 AM Ard Biesheuvel <ardb@kernel.org> wrote: > > > > > > On Fri, 9 Jan 2026 at 06:01, Brian Gerst <brgerst@gmail.com> wrote: > > > > > > > > On Thu, Jan 8, 2026 at 4:28 AM Ard Biesheuvel <ardb@kernel.org> wrote: > > > > > > > > > > Use ordinary RIP-relative references to make the code compatible with > > > > > running the linker in PIE mode. > > > > > > > > > > Note that wakeup_long64() runs in the kernel's ordinary virtual mapping > > > > > so there is no need to record the address of .Lresume_point in a global > > > > > variable. And fix the comment while at it. > > > > > > > > > > Signed-off-by: Ard Biesheuvel <ardb@kernel.org> > > > > > --- > > > > > arch/x86/kernel/acpi/wakeup_64.S | 11 ++++------- > > > > > 1 file changed, 4 insertions(+), 7 deletions(-) > > > > > > > > > > diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S > > > > > index 04f561f75e99..15233a4e1c95 100644 > > > > > --- a/arch/x86/kernel/acpi/wakeup_64.S > > > > > +++ b/arch/x86/kernel/acpi/wakeup_64.S > > > > > @@ -14,7 +14,7 @@ > > > > > > > > > > .code64 > > > > > /* > > > > > - * Hooray, we are in Long 64-bit mode (but still running in low memory) > > > > > + * Hooray, we are in Long 64-bit mode > > > > > */ > > > > > SYM_FUNC_START(wakeup_long64) > > > > > ANNOTATE_NOENDBR > > > > > @@ -41,7 +41,7 @@ SYM_FUNC_START(wakeup_long64) > > > > > movq saved_rsi(%rip), %rsi > > > > > movq saved_rbp(%rip), %rbp > > > > > > > > > > - movq saved_rip(%rip), %rax > > > > > + leaq .Lresume_point(%rip), %rax > > > > > ANNOTATE_RETPOLINE_SAFE > > > > > jmp *%rax > > > > > > > > If this is already running on the virtual mapping, this can simply be > > > > changed to a direct jump. > > > > > > > > > > Indeed, but I couldn't figure out how to do so without making objtool unhappy. > > > > I replaced it with a simple "jmp .Lresume_point" and objtool seemed > > fine with it on a defconfig build. What error did you see? > > arch/x86/kernel/acpi/wakeup_64.o: warning: objtool: wakeup_long64() > falls through to next function do_suspend_lowlevel() Note that this is x86_64_defconfig with CONFIG_X86_KERNEL_IBT disabled.
On Fri, Jan 9, 2026 at 7:10 AM Ard Biesheuvel <ardb@kernel.org> wrote: > > On Fri, 9 Jan 2026 at 13:09, Ard Biesheuvel <ardb@kernel.org> wrote: > > > > On Fri, 9 Jan 2026 at 12:46, Brian Gerst <brgerst@gmail.com> wrote: > > > > > > On Fri, Jan 9, 2026 at 2:59 AM Ard Biesheuvel <ardb@kernel.org> wrote: > > > > > > > > On Fri, 9 Jan 2026 at 06:01, Brian Gerst <brgerst@gmail.com> wrote: > > > > > > > > > > On Thu, Jan 8, 2026 at 4:28 AM Ard Biesheuvel <ardb@kernel.org> wrote: > > > > > > > > > > > > Use ordinary RIP-relative references to make the code compatible with > > > > > > running the linker in PIE mode. > > > > > > > > > > > > Note that wakeup_long64() runs in the kernel's ordinary virtual mapping > > > > > > so there is no need to record the address of .Lresume_point in a global > > > > > > variable. And fix the comment while at it. > > > > > > > > > > > > Signed-off-by: Ard Biesheuvel <ardb@kernel.org> > > > > > > --- > > > > > > arch/x86/kernel/acpi/wakeup_64.S | 11 ++++------- > > > > > > 1 file changed, 4 insertions(+), 7 deletions(-) > > > > > > > > > > > > diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S > > > > > > index 04f561f75e99..15233a4e1c95 100644 > > > > > > --- a/arch/x86/kernel/acpi/wakeup_64.S > > > > > > +++ b/arch/x86/kernel/acpi/wakeup_64.S > > > > > > @@ -14,7 +14,7 @@ > > > > > > > > > > > > .code64 > > > > > > /* > > > > > > - * Hooray, we are in Long 64-bit mode (but still running in low memory) > > > > > > + * Hooray, we are in Long 64-bit mode > > > > > > */ > > > > > > SYM_FUNC_START(wakeup_long64) > > > > > > ANNOTATE_NOENDBR > > > > > > @@ -41,7 +41,7 @@ SYM_FUNC_START(wakeup_long64) > > > > > > movq saved_rsi(%rip), %rsi > > > > > > movq saved_rbp(%rip), %rbp > > > > > > > > > > > > - movq saved_rip(%rip), %rax > > > > > > + leaq .Lresume_point(%rip), %rax > > > > > > ANNOTATE_RETPOLINE_SAFE > > > > > > jmp *%rax > > > > > > > > > > If this is already running on the virtual mapping, this can simply be > > > > > changed to a direct jump. > > > > > > > > > > > > > Indeed, but I couldn't figure out how to do so without making objtool unhappy. > > > > > > I replaced it with a simple "jmp .Lresume_point" and objtool seemed > > > fine with it on a defconfig build. What error did you see? > > > > arch/x86/kernel/acpi/wakeup_64.o: warning: objtool: wakeup_long64() > > falls through to next function do_suspend_lowlevel() > > Note that this is x86_64_defconfig with CONFIG_X86_KERNEL_IBT disabled. I do see the error now. I had missed it when building the .o file and thought it would show when linking vmlinux. I was able to make objtool happy by embedding wakeup_long64() into do_suspend_lowlevel() and using SYM_INNER_LABEL_ALIGN().
© 2016 - 2026 Red Hat, Inc.