Message ID | 20190906075550.23435-1-jslaby@suse.cz (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | [1/2] x86/asm/suspend: Get rid of bogus_64_magic | expand |
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
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
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
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(-)