All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@amacapital.net>,
	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>, Pedro Alves <palves@redhat.com>,
	X86 ML <x86@kernel.org>,
	live-patching@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH 13/21] x86/asm/crypto: Fix frame pointer usage in aesni-intel_asm.S
Date: Mon, 20 Jul 2015 19:21:24 +0200	[thread overview]
Message-ID: <20150720172124.GA13344@gmail.com> (raw)
In-Reply-To: <20150720135930.GB7326@treble.redhat.com>


* Josh Poimboeuf <jpoimboe@redhat.com> wrote:

> On Mon, Jul 20, 2015 at 09:56:11AM +0200, Ingo Molnar wrote:
> > > 
> > > The reason I suggested to put FRAME in the macro name is to try to prevent it 
> > > from being accidentally used for leaf functions, where it isn't needed.
> > 
> > Well, we could use LEAF_FUNCTION to mark that fact.
> > 
> > Wether a function written in assembly is a leaf function or not is a higher level 
> > (and thus more valuable) piece of information whether we generate frame pointer 
> > debuginfo or not.
> > 
> > > Also the naming of FUNCTION_ENTRY and FUNCTION_RETURN doesn't do anything to 
> > > distinguish them from the already ubiquitous ENTRY and ENDPROC.  So as a kernel 
> > > developer it seems confusing to me, e.g. how do I remember when to use 
> > > FUNCTION_ENTRY vs ENTRY?
> > 
> > 'ENDPROC' is really leftover from older debuginfo cruft, it's not a valuable 
> > construct IMHO, even if it's (sadly) ubiquitious.
> > 
> > We want to create new, clean, as minimal as possible and as clearly named as 
> > possible debuginfo constructs from first principles.
> 
> Ok. So if I understand right, the proposal is:
> 
> Replace *all* x86 usage of ENTRY/ENDPROC with either:
> 
> FUNCTION_ENTRY(func)
> FUNCTION_RETURN(func)
> 
> or
> 
> LEAF_FUNCTION_ENTRY(func)
> LEAF_FUNCTION_RETURN(func)
> 
> Those sound fine to me.

Yeah - but keep the old constructs as well and don't necessarily do the full 
migration straight away, only once the dust has settled - to reduce churn.

> I should point out that there are still a few cases where the more granular 
> FRAME/ENDFRAME and ENTRY/ENDPROC macros would still be needed.
> 
> For example, if the function ends with a jump instead of a ret.  If the
> jump is a sibling call, the code would look like:
> 
> FUNCTION_ENTRY(func)
> 	...
> 	ENDFRAME
> 	jmp another_func
> ENDPROC(func)
> 
> 
> Or if it's a jump within the function to an internal ret:
> 
> FUNCTION_ENTRY(func)
> 	...
> 1:	...
> 	ENDFRAME
> 	ret
> 2:	...
> 	jmp 1b
> ENDPROC(func)
> 
> 
> Or if it jumps to some shared code before returning:
> 
> FUNCTION_ENTRY(func_1)
> 	...
> 	jmp common_return
> ENDPROC(func_1)
> 
> FUNCTION_ENTRY(func_2)
> 	...
> 	jmp common_return
> ENDPROC(func_2)
> 
> common_return:
> 	...
> 	ENDFRAME
> 	ret
> 
> 
> So in some cases we'd still need the more granular macros, unless we
> decided to make special macros for these cases as well.

Ok, I see how the naming scheme I proposed won't work with all that very well, but 
I'd still suggest using consistently named patterns.

Let me suggest yet another approach. How about open-coding something like this:

 FUNCTION_START(func)

	push_bp
	mov_sp_bp

	...

	pop_bp
	ret

 FUNCTION_END(func)

This is just two easy things:

 - a redefine of the FUNCTION_ENTRY and ENDPROC names

 - the introduction of three quasi-mnemonics: push_bp, mov_sp_bp, pop_bp - which 
   all look very similar to a real frame setup sequence, except that we can easily 
   make them go away in the !CONFIG_FRAME_POINTERS case.

The advantage of this approach would be:

 - it looks pretty 'natural' and very close to how the real disassembly looks
   like in CONFIG_FRAME_POINTERS=y kernels. So while it's not as compact as some 
   of the other variants, it's close to what the real instruction sequence looks 
   like and that is a positive quality in itself.

 - it also makes it apparent 'on sight' that it's probably a bug to have
   unbalanced push/pop sequences in a regular function, to any reasonably alert 
   assembly coder.

 - if we ever unsupport framepointer kernels in the (far far) future, we can get
   rid of all lines with those 3 mnemonics and be done with it.

 - it's finegrained enough so that we can express all the special function/tail
   variants you listed above.

What do you think?

I'd still keep existing frame setup functionality and names and only use these in 
fixes, new code and new annotations - and do a full rename and cleanup once the 
dust has settled.

Thanks,

	Ingo

  reply	other threads:[~2015-07-20 17:21 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-14 17:14 [PATCH v7 0/4] Compile-time stack validation Josh Poimboeuf
2015-07-14 17:14 ` [PATCH v7 1/4] x86/asm: Frame pointer macro cleanup Josh Poimboeuf
2015-07-14 17:14 ` [PATCH v7 2/4] x86/stackvalidate: Compile-time stack validation Josh Poimboeuf
2015-07-14 20:57   ` Peter Zijlstra
2015-07-14 21:11     ` Josh Poimboeuf
2015-07-14 21:08   ` Peter Zijlstra
2015-07-14 21:30     ` Josh Poimboeuf
2015-07-14 21:56       ` Peter Zijlstra
2015-07-14 22:32         ` Josh Poimboeuf
2015-07-20 16:53   ` Namhyung Kim
2015-07-20 17:50     ` Josh Poimboeuf
2015-07-21  8:02       ` Ingo Molnar
2015-07-21 12:04         ` Josh Poimboeuf
2015-07-21  8:42       ` Bernd Petrovitsch
2015-07-21 12:06         ` Josh Poimboeuf
2015-07-14 17:14 ` [PATCH v7 3/4] x86/stackvalidate: Add file and directory ignores Josh Poimboeuf
2015-07-14 17:14 ` [PATCH v7 4/4] x86/stackvalidate: Add ignore macros Josh Poimboeuf
2015-07-14 17:25 ` [PATCH v7 0/4] Compile-time stack validation Josh Poimboeuf
2015-07-15 10:16   ` Ingo Molnar
2015-07-15 16:05     ` Josh Poimboeuf
2015-07-17 16:47     ` [RFC PATCH 00/21] x86: Proposed fixes for stackvalidate warnings Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 01/21] stackvalidate: Process ignores earlier and add more ignore checks Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 02/21] stackvalidate: Add C version of STACKVALIDATE_IGNORE_INSN Josh Poimboeuf
2015-07-18 14:56         ` Borislav Petkov
2015-07-18 16:00           ` Josh Poimboeuf
     [not found]         ` <CA+55aFyoO75n-mQBrB_YBLx9yNpAjisFAqkO8+YsphD-xmgY+w@mail.gmail.com>
2015-07-18 16:40           ` Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 03/21] x86/asm: Add C versions of FRAME and ENDFRAME macros Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 04/21] x86/hweight: Add stack frame dependency for __arch_hweight*() Josh Poimboeuf
2015-07-17 17:17         ` Borislav Petkov
2015-07-17 17:32           ` Josh Poimboeuf
2015-07-18  5:05             ` Borislav Petkov
2015-07-18 13:44               ` Josh Poimboeuf
2015-07-18 14:56                 ` Borislav Petkov
2015-07-18 15:57                   ` Josh Poimboeuf
2015-07-19  4:12                     ` Borislav Petkov
2015-07-22  0:13                       ` Andy Lutomirski
2015-07-22  4:25                         ` Borislav Petkov
2015-07-22  4:39                           ` Andy Lutomirski
2015-07-22  4:45                             ` Borislav Petkov
2015-07-17 16:47       ` [RFC PATCH 05/21] x86/xen: Add stack frame dependency to hypercall inline asm calls Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 06/21] x86/paravirt: Add stack frame dependency to PVOP " Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 07/21] x86/paravirt: Fix frame pointer usage in PV_CALLEE_SAVE_REGS_THUNK Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 08/21] x86/paravirt: Align paravirt thunk functions at 16-byte boundaries Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 09/21] x86/amd: Set ELF function type for vide() Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 10/21] x86/reboot: Add ljmp instructions to stackvalidate whitelist Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 11/21] x86/xen: Add xen_cpuid() and xen_setup_gdt() to stackvalidate whitelists Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 12/21] sched: Add __schedule() to stackvalidate whitelist Josh Poimboeuf
2015-07-17 19:46         ` Peter Zijlstra
2015-07-17 19:58           ` Andy Lutomirski
2015-07-17 21:03             ` Peter Zijlstra
2015-07-17 21:23             ` Josh Poimboeuf
2015-07-18  3:44             ` Ingo Molnar
2015-07-17 16:47       ` [RFC PATCH 13/21] x86/asm/crypto: Fix frame pointer usage in aesni-intel_asm.S Josh Poimboeuf
2015-07-17 19:43         ` Ingo Molnar
2015-07-17 19:44           ` Andy Lutomirski
2015-07-17 20:37             ` Josh Poimboeuf
2015-07-17 20:39               ` Andy Lutomirski
2015-07-17 20:44                 ` Josh Poimboeuf
2015-07-17 20:46                   ` Andy Lutomirski
2015-07-17 20:59                     ` Josh Poimboeuf
2015-07-17 21:01                       ` Andy Lutomirski
2015-07-17 21:10                         ` Josh Poimboeuf
2015-07-18  8:42                           ` Borislav Petkov
2015-07-18 13:46                             ` Josh Poimboeuf
2015-07-18 14:25                               ` Borislav Petkov
2015-07-18 15:40                                 ` Josh Poimboeuf
2015-07-18  2:51               ` Ingo Molnar
2015-07-18  3:56                 ` Josh Poimboeuf
2015-07-20  7:56                   ` Ingo Molnar
2015-07-20 13:59                     ` Josh Poimboeuf
2015-07-20 17:21                       ` Ingo Molnar [this message]
2015-07-20 18:00                         ` Josh Poimboeuf
2015-07-22 11:52                           ` Josh Poimboeuf
2015-07-20 15:30                   ` Andy Lutomirski
2015-07-20 16:36                     ` Josh Poimboeuf
2015-07-20 16:52                       ` Peter Zijlstra
2015-07-20 17:19                         ` Josh Poimboeuf
2015-07-21  8:00                       ` Ingo Molnar
2015-07-21 12:06                         ` Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 14/21] x86/asm/crypto: Move .Lbswap_mask data to .rodata section Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 15/21] x86/asm/crypto: Move jump_table " Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 16/21] x86/asm/crypto: Fix frame pointer usage in clmul_ghash_mul/update() Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 17/21] x86/asm/entry: Fix frame pointer usage in thunk functions Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 18/21] x86/asm/acpi: Fix frame pointer usage in do_suspend_lowlevel() Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 19/21] x86/asm: Fix frame pointer usage in rwsem functions Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 20/21] x86/asm/efi: Fix frame pointer usage in efi_call() Josh Poimboeuf
2015-07-17 16:47       ` [RFC PATCH 21/21] x86/asm/power: Fix frame pointer usage in hibernate_asm_64.S Josh Poimboeuf
2015-07-17 18:56       ` [RFC PATCH 00/21] x86: Proposed fixes for stackvalidate warnings Andy Lutomirski
2015-07-18  3:05         ` Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2015-07-18 21:02 [RFC PATCH 13/21] x86/asm/crypto: Fix frame pointer usage in aesni-intel_asm.S Gustavo da Silva

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=20150720172124.GA13344@gmail.com \
    --to=mingo@kernel.org \
    --cc=andi@firstfloor.org \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=mmarek@suse.cz \
    --cc=palves@redhat.com \
    --cc=peterz@infradead.org \
    --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.