From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
Michal Marek <mmarek@suse.cz>,
Peter Zijlstra <peterz@infradead.org>,
Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@alien8.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andi Kleen <andi@firstfloor.org>,
x86@kernel.org, live-patching@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Len Brown <len.brown@intel.com>,
linux-pm@vger.kernel.org
Subject: Re: [PATCH v5 07/10] x86/asm/acpi: Fix asmvalidate warnings for wakeup_64.S
Date: Wed, 10 Jun 2015 09:08:30 -0500 [thread overview]
Message-ID: <20150610140830.GA25848@treble.redhat.com> (raw)
In-Reply-To: <20150610131914.GA25572@amd>
On Wed, Jun 10, 2015 at 03:19:14PM +0200, Pavel Machek wrote:
> Hi!
>
> > Fix the following asmvalidate warnings:
> >
> > asmvalidate: arch/x86/kernel/acpi/wakeup_64.o: wakeup_long64()+0x15: unsupported jump to outside of function
> > asmvalidate: arch/x86/kernel/acpi/wakeup_64.o: wakeup_long64()+0x55: unsupported jump to outside of function
> > asmvalidate: arch/x86/kernel/acpi/wakeup_64.o: wakeup_long64(): unsupported fallthrough at end of function
> > asmvalidate: arch/x86/kernel/acpi/wakeup_64.o: do_suspend_lowlevel()+0x9a: unsupported jump to outside of function
> > asmvalidate: arch/x86/kernel/acpi/wakeup_64.o: do_suspend_lowlevel()+0x116: unsupported jump to outside of function
> > asmvalidate: arch/x86/kernel/acpi/wakeup_64.o: do_suspend_lowlevel(): unsupported fallthrough at end of function
> > asmvalidate: arch/x86/kernel/acpi/wakeup_64.o: do_suspend_lowlevel(): missing FP_SAVE/RESTORE macros
> >
> > 1. wakeup_long64() isn't a function that can be called. It's actually
> > redirected to via a return instruction in the entry code. It
> > shouldn't be annotated as a callable function. Change ENDPROC ->
> > PROC accordingly.
>
> But I see -> END.
Oops! It should say -> END.
> > 2. do_suspend_lowlevel() is a non-leaf callable function, so
> > save/restore the frame pointer with FP_SAVE/RESTORE.
>
> It does not work with the frame pointer itself. Is FP_SAVE/RESTORE
> still neccessary? Will you need FP_RESTORE to wakeup_long64, then?
wakeup_long64 jumps to .Lresume_point, which does the FP_RESTORE.
> > 3. Remove the unnecessary jump to .Lresume_point, as it just results in
> > jumping to the next instruction (which is a nop because of the
> > align). Otherwise asmvalidate gets confused by the jump.
>
> It also results in flushing the pipeline. Ok, I guess this one is unneccessary.
>
> > 4. Change the "jmp restore_processor_state" to a call instruction,
> > because jumping outside the function's boundaries isn't allowed. Now
> > restore_processor_state() will return back to do_suspend_lowlevel()
> > instead of do_suspend_lowlevel()'s caller.
> >
> > 5. Remove superfluous rsp changes.
>
> Did you test the changes?
Yes, I verified that it didn't break suspend/resume on my system.
> Do you plan to make similar changes to wakeup_32.S?
Currently, asmvalidate is x86_64 only, so I'm only fixing the 64-bit
stuff right now.
> > diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S
> > index 8c35df4..7e442be 100644
> > --- a/arch/x86/kernel/acpi/wakeup_64.S
> > +++ b/arch/x86/kernel/acpi/wakeup_64.S
> > @@ -5,6 +5,7 @@
> > #include <asm/page_types.h>
> > #include <asm/msr.h>
> > #include <asm/asm-offsets.h>
> > +#include <asm/func.h>
> >
> > # Copyright 2003 Pavel Machek <pavel@suse.cz>, distribute under GPLv2
> >
> > @@ -33,13 +34,13 @@ ENTRY(wakeup_long64)
> >
> > movq saved_rip, %rax
> > jmp *%rax
> > -ENDPROC(wakeup_long64)
> > +END(wakeup_long64)
> >
>
> This should result in no binary code changes, so that's ok with me...
>
> > ENTRY(do_suspend_lowlevel)
> > - subq $8, %rsp
> > + FP_SAVE
> > xorl %eax, %eax
> > call save_processor_state
> >
>
> Are you sure? Stuff like
> movq $saved_context, %rax
> movq %rsp, pt_regs_sp(%rax)
>
> follows. And you did not modify wakeup_long64, which now receives
> different value in saved_rsp.
Hm, I'm looking hard, but I still don't see a problem with that code.
It's saving rsp to the saved_context struct. As I mentioned above, it's
ok for the wakeup_long64 path to restore the same rsp value, since it
jumps to .Lresume_point which has FP_RESTORE.
> > @@ -108,8 +108,9 @@ ENTRY(do_suspend_lowlevel)
> > movq pt_regs_r15(%rax), %r15
> >
> > xorl %eax, %eax
> > - addq $8, %rsp
> > - jmp restore_processor_state
> > + call restore_processor_state
> > + FP_RESTORE
> > + ret
> > ENDPROC(do_suspend_lowlevel)
>
> Umm. I rather liked the direct jump.
Why?
--
Josh
next prev parent reply other threads:[~2015-06-10 14:08 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-10 12:06 [PATCH v5 00/10] x86/asm: Compile-time asm code validation Josh Poimboeuf
2015-06-10 12:06 ` [PATCH v5 01/10] x86/asm: Add FP_SAVE/RESTORE frame pointer macros Josh Poimboeuf
2015-06-10 18:17 ` Pavel Machek
2015-06-10 18:24 ` Josh Poimboeuf
2015-06-11 4:22 ` Jiri Kosina
2015-06-11 6:46 ` Pavel Machek
2015-06-11 12:06 ` Jiri Kosina
2015-06-11 14:18 ` Josh Poimboeuf
2015-06-10 12:06 ` [PATCH v5 02/10] x86: Compile-time asm code validation Josh Poimboeuf
2015-06-10 17:21 ` Andy Lutomirski
2015-06-10 17:53 ` Josh Poimboeuf
2015-06-10 18:15 ` Andy Lutomirski
2015-06-10 18:58 ` Josh Poimboeuf
2015-06-10 22:17 ` Josh Poimboeuf
2015-06-11 6:08 ` Ingo Molnar
2015-06-11 14:01 ` Josh Poimboeuf
2015-06-11 6:10 ` Ingo Molnar
2015-06-11 14:10 ` Josh Poimboeuf
2015-06-12 11:18 ` Pedro Alves
2015-06-12 14:10 ` Josh Poimboeuf
2015-06-12 16:00 ` Pedro Alves
2015-06-12 16:41 ` Josh Poimboeuf
2015-06-10 18:16 ` Vojtech Pavlik
2015-06-10 18:18 ` Andy Lutomirski
2015-06-10 12:06 ` [PATCH v5 03/10] x86/asm/entry: Fix asmvalidate warnings for entry_64_compat.S Josh Poimboeuf
2015-06-10 12:06 ` [PATCH v5 04/10] x86/asm/crypto: Fix asmvalidate warnings for aesni-intel_asm.S Josh Poimboeuf
2015-06-10 12:06 ` [PATCH v5 05/10] x86/asm/crypto: Fix asmvalidate warnings for ghash-clmulni-intel_asm.S Josh Poimboeuf
[not found] ` <cover.1433937132.git.jpoimboe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-06-10 12:06 ` [PATCH v5 06/10] x86/asm/efi: Fix asmvalidate warnings for efi_stub_64.S Josh Poimboeuf
2015-06-10 12:06 ` Josh Poimboeuf
[not found] ` <3e1d9ce523b3174a49b4317cd8b1b85dfd0c319a.1433937132.git.jpoimboe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-06-11 13:14 ` Matt Fleming
2015-06-11 13:14 ` Matt Fleming
2015-06-12 19:24 ` Borislav Petkov
2015-06-10 12:06 ` [PATCH v5 07/10] x86/asm/acpi: Fix asmvalidate warnings for wakeup_64.S Josh Poimboeuf
2015-06-10 13:19 ` Pavel Machek
2015-06-10 14:08 ` Josh Poimboeuf [this message]
2015-06-11 12:36 ` Pavel Machek
2015-06-10 13:21 ` Pavel Machek
2015-06-10 14:13 ` Josh Poimboeuf
2015-06-11 6:13 ` Ingo Molnar
2015-06-10 12:06 ` [PATCH v5 08/10] x86/asm/head: Fix asmvalidate warnings for head_64.S Josh Poimboeuf
2015-06-10 12:06 ` [PATCH v5 09/10] x86/asm/lib: Fix asmvalidate warnings for lib functions Josh Poimboeuf
2015-06-10 12:06 ` [PATCH v5 10/10] x86/asm/lib: Fix asmvalidate warnings for rwsem.S Josh Poimboeuf
2015-06-10 12:16 ` [PATCH v5 00/10] x86/asm: Compile-time asm code validation Josh Poimboeuf
2015-06-10 13:08 ` Andi Kleen
2015-06-10 13:52 ` Josh Poimboeuf
2015-06-10 14:11 ` Andi Kleen
2015-06-10 14:32 ` Josh Poimboeuf
2015-06-10 15:04 ` Andi Kleen
2015-06-10 15:31 ` Josh Poimboeuf
2015-06-10 16:50 ` Josh Poimboeuf
2015-06-10 18:41 ` Andi Kleen
2015-06-10 19:43 ` Josh Poimboeuf
2015-06-10 18:40 ` Andi Kleen
2015-06-10 19:36 ` Josh Poimboeuf
2015-06-10 19:38 ` Andy Lutomirski
2015-06-10 19:51 ` Josh Poimboeuf
2015-06-10 13:42 ` Pavel Machek
2015-06-10 14:20 ` Josh Poimboeuf
2015-06-10 18:24 ` Andy Lutomirski
2015-06-10 20:26 ` Josh Poimboeuf
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=20150610140830.GA25848@treble.redhat.com \
--to=jpoimboe@redhat.com \
--cc=andi@firstfloor.org \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=mmarek@suse.cz \
--cc=pavel@ucw.cz \
--cc=peterz@infradead.org \
--cc=rjw@rjwysocki.net \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.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.