* [PATCH 1/2] x86/asm/suspend: Get rid of bogus_64_magic
@ 2019-09-06 7:55 Jiri Slaby
2019-09-06 9:52 ` [tip: x86/asm] " tip-bot2 for Jiri Slaby
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jiri Slaby @ 2019-09-06 7:55 UTC (permalink / raw)
To: bp
Cc: tglx, mingo, hpa, x86, linux-kernel, Jiri Slaby,
Rafael J. Wysocki, Pavel Machek, Len Brown, linux-pm
bogus_64_magic is only a dead-end loop. There is no need for an
out-of-order function (and unannotated local label), so just handle it
in-place and also store 0xbad-m-a-g-i-c to rcx beforehand.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Len Brown <lenb@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: linux-pm@vger.kernel.org
---
arch/x86/kernel/acpi/wakeup_64.S | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S
index b0715c3ac18d..7f9ade13bbcf 100644
--- a/arch/x86/kernel/acpi/wakeup_64.S
+++ b/arch/x86/kernel/acpi/wakeup_64.S
@@ -18,8 +18,13 @@ ENTRY(wakeup_long64)
movq saved_magic, %rax
movq $0x123456789abcdef0, %rdx
cmpq %rdx, %rax
- jne bogus_64_magic
+ je 2f
+ /* stop here on a saved_magic mismatch */
+ movq $0xbad6d61676963, %rcx
+1:
+ jmp 1b
+2:
movw $__KERNEL_DS, %ax
movw %ax, %ss
movw %ax, %ds
@@ -37,9 +42,6 @@ ENTRY(wakeup_long64)
jmp *%rax
ENDPROC(wakeup_long64)
-bogus_64_magic:
- jmp bogus_64_magic
-
ENTRY(do_suspend_lowlevel)
FRAME_BEGIN
subq $8, %rsp
--
2.23.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [tip: x86/asm] x86/asm/suspend: Get rid of bogus_64_magic
2019-09-06 7:55 [PATCH 1/2] x86/asm/suspend: Get rid of bogus_64_magic Jiri Slaby
@ 2019-09-06 9:52 ` tip-bot2 for Jiri Slaby
2019-09-06 10:57 ` [PATCH 1/2] " Pavel Machek
2019-09-07 13:10 ` Pavel Machek
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Jiri Slaby @ 2019-09-06 9:52 UTC (permalink / raw)
To: linux-tip-commits
Cc: Jiri Slaby, Borislav Petkov, H. Peter Anvin, Ingo Molnar,
Len Brown, linux-pm, Pavel Machek, Rafael J. Wysocki,
Thomas Gleixner, x86-ml, Ingo Molnar, Borislav Petkov,
linux-kernel
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: 559ceeed62a5121783a8955c63aeb18aaa0ef224
Gitweb: https://git.kernel.org/tip/559ceeed62a5121783a8955c63aeb18aaa0ef224
Author: Jiri Slaby <jslaby@suse.cz>
AuthorDate: Fri, 06 Sep 2019 09:55:49 +02:00
Committer: Borislav Petkov <bp@suse.de>
CommitterDate: Fri, 06 Sep 2019 10:34:15 +02:00
x86/asm/suspend: Get rid of bogus_64_magic
bogus_64_magic is only a dead-end loop. There is no need for an
out-of-order function (and unannotated local label), so just handle it
in-place and also store 0xbad-m-a-g-i-c to %rcx beforehand, in case
someone is inspecting registers.
Here a qemu+gdb example:
Remote debugging using localhost:1235
wakeup_long64 () at arch/x86/kernel/acpi/wakeup_64.S:26
26 jmp 1b
(gdb) info registers
rax 0x123456789abcdef0 1311768467463790320
rbx 0x0 0
rcx 0xbad6d61676963 3286910041024867
^^^^^^^^^^^^^^^
[ bp: Add the gdb example. ]
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-pm@vger.kernel.org
Cc: Pavel Machek <pavel@ucw.cz>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86-ml <x86@kernel.org>
Link: https://lkml.kernel.org/r/20190906075550.23435-1-jslaby@suse.cz
---
arch/x86/kernel/acpi/wakeup_64.S | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S
index b0715c3..7f9ade1 100644
--- a/arch/x86/kernel/acpi/wakeup_64.S
+++ b/arch/x86/kernel/acpi/wakeup_64.S
@@ -18,8 +18,13 @@ ENTRY(wakeup_long64)
movq saved_magic, %rax
movq $0x123456789abcdef0, %rdx
cmpq %rdx, %rax
- jne bogus_64_magic
+ je 2f
+ /* stop here on a saved_magic mismatch */
+ movq $0xbad6d61676963, %rcx
+1:
+ jmp 1b
+2:
movw $__KERNEL_DS, %ax
movw %ax, %ss
movw %ax, %ds
@@ -37,9 +42,6 @@ ENTRY(wakeup_long64)
jmp *%rax
ENDPROC(wakeup_long64)
-bogus_64_magic:
- jmp bogus_64_magic
-
ENTRY(do_suspend_lowlevel)
FRAME_BEGIN
subq $8, %rsp
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] x86/asm/suspend: Get rid of bogus_64_magic
2019-09-06 7:55 [PATCH 1/2] x86/asm/suspend: Get rid of bogus_64_magic Jiri Slaby
2019-09-06 9:52 ` [tip: x86/asm] " tip-bot2 for Jiri Slaby
@ 2019-09-06 10:57 ` Pavel Machek
2019-09-07 13:10 ` Pavel Machek
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Machek @ 2019-09-06 10:57 UTC (permalink / raw)
To: Jiri Slaby
Cc: bp, tglx, mingo, hpa, x86, linux-kernel, Rafael J. Wysocki,
Len Brown, linux-pm
[-- Attachment #1: Type: text/plain, Size: 1735 bytes --]
On Fri 2019-09-06 09:55:49, Jiri Slaby wrote:
> bogus_64_magic is only a dead-end loop. There is no need for an
> out-of-order function (and unannotated local label), so just handle it
> in-place and also store 0xbad-m-a-g-i-c to rcx beforehand.
Slower, longer, does not really fix anything. Why is it good idea?
NAK.
Pavel
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: x86@kernel.org
> Cc: linux-pm@vger.kernel.org
> ---
> arch/x86/kernel/acpi/wakeup_64.S | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S
> index b0715c3ac18d..7f9ade13bbcf 100644
> --- a/arch/x86/kernel/acpi/wakeup_64.S
> +++ b/arch/x86/kernel/acpi/wakeup_64.S
> @@ -18,8 +18,13 @@ ENTRY(wakeup_long64)
> movq saved_magic, %rax
> movq $0x123456789abcdef0, %rdx
> cmpq %rdx, %rax
> - jne bogus_64_magic
> + je 2f
>
> + /* stop here on a saved_magic mismatch */
> + movq $0xbad6d61676963, %rcx
> +1:
> + jmp 1b
> +2:
> movw $__KERNEL_DS, %ax
> movw %ax, %ss
> movw %ax, %ds
> @@ -37,9 +42,6 @@ ENTRY(wakeup_long64)
> jmp *%rax
> ENDPROC(wakeup_long64)
>
> -bogus_64_magic:
> - jmp bogus_64_magic
> -
> ENTRY(do_suspend_lowlevel)
> FRAME_BEGIN
> subq $8, %rsp
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] x86/asm/suspend: Get rid of bogus_64_magic
2019-09-06 7:55 [PATCH 1/2] x86/asm/suspend: Get rid of bogus_64_magic Jiri Slaby
2019-09-06 9:52 ` [tip: x86/asm] " tip-bot2 for Jiri Slaby
2019-09-06 10:57 ` [PATCH 1/2] " Pavel Machek
@ 2019-09-07 13:10 ` Pavel Machek
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Machek @ 2019-09-07 13:10 UTC (permalink / raw)
To: Jiri Slaby
Cc: bp, tglx, mingo, hpa, x86, linux-kernel, Rafael J. Wysocki,
Len Brown, linux-pm
[-- Attachment #1: Type: text/plain, Size: 1610 bytes --]
On Fri 2019-09-06 09:55:49, Jiri Slaby wrote:
> bogus_64_magic is only a dead-end loop. There is no need for an
> out-of-order function (and unannotated local label), so just handle it
> in-place and also store 0xbad-m-a-g-i-c to rcx beforehand.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: x86@kernel.org
> Cc: linux-pm@vger.kernel.org
> ---
> arch/x86/kernel/acpi/wakeup_64.S | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S
> index b0715c3ac18d..7f9ade13bbcf 100644
> --- a/arch/x86/kernel/acpi/wakeup_64.S
> +++ b/arch/x86/kernel/acpi/wakeup_64.S
> @@ -18,8 +18,13 @@ ENTRY(wakeup_long64)
> movq saved_magic, %rax
> movq $0x123456789abcdef0, %rdx
> cmpq %rdx, %rax
> - jne bogus_64_magic
> + je 2f
>
> + /* stop here on a saved_magic mismatch */
> + movq $0xbad6d61676963, %rcx
> +1:
> + jmp 1b
> +2:
btw I suspect you can simply do here
1b: jne 1b
... if someone is looking with gdb, he'll understand what is going
on. no need to bother with special %rcx, %rdx is already rather magic.
Best regards,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-09-07 13:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-06 7:55 [PATCH 1/2] x86/asm/suspend: Get rid of bogus_64_magic Jiri Slaby
2019-09-06 9:52 ` [tip: x86/asm] " tip-bot2 for Jiri Slaby
2019-09-06 10:57 ` [PATCH 1/2] " Pavel Machek
2019-09-07 13:10 ` Pavel Machek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).