[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150718025116.GB13059@gmail.com>
Date: Sat, 18 Jul 2015 04:51:16 +0200
From: Ingo Molnar <mingo@...nel.org>
To: Josh Poimboeuf <jpoimboe@...hat.com>
Cc: Andy Lutomirski <luto@...capital.net>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, Michal Marek <mmarek@...e.cz>,
Peter Zijlstra <peterz@...radead.org>,
Andy Lutomirski <luto@...nel.org>,
Borislav Petkov <bp@...en8.de>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andi Kleen <andi@...stfloor.org>,
Pedro Alves <palves@...hat.com>, X86 ML <x86@...nel.org>,
live-patching@...r.kernel.org,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH 13/21] x86/asm/crypto: Fix frame pointer usage in
aesni-intel_asm.S
* Josh Poimboeuf <jpoimboe@...hat.com> wrote:
> On Fri, Jul 17, 2015 at 12:44:42PM -0700, Andy Lutomirski wrote:
> > On Fri, Jul 17, 2015 at 12:43 PM, Ingo Molnar <mingo@...nel.org> wrote:
> > >
> > > * Josh Poimboeuf <jpoimboe@...hat.com> wrote:
> > >
> > >> ENTRY(aesni_set_key)
> > >> + FRAME
> > >> #ifndef __x86_64__
> > >> pushl KEYP
> > >> movl 8(%esp), KEYP # ctx
> > >> @@ -1905,6 +1907,7 @@ ENTRY(aesni_set_key)
> > >> #ifndef __x86_64__
> > >> popl KEYP
> > >> #endif
> > >> + ENDFRAME
> > >> ret
> > >> ENDPROC(aesni_set_key)
> > >
> > > So cannot we make this a bit more compact and less fragile?
> > >
> > > Instead of:
> > >
> > > ENTRY(aesni_set_key)
> > > FRAME
> > > ...
> > > ENDFRAME
> > > ret
> > > ENDPROC(aesni_set_key)
> > >
> > >
> > > How about writing this as:
> > >
> > > FUNCTION_ENTRY(aesni_set_key)
> > > ...
> > > FUNCTION_RETURN(aesni_set_key)
> > >
> > > which does the same thing in a short, symmetric construct?
> > >
> > > One potential problem with this approach would be that what 'looks' like an entry
> > > declaration, but it will now generate real code.
> > >
> > > OTOH if people find this intuitive enough then it's a lot harder to mess it up,
> > > and I think 'RETURN' makes it clear enough that there's a real instruction
> > > generated there.
> > >
> >
> > How about FUNCTION_PROLOGUE and FUNCTION_EPILOGUE?
>
> Perhaps the macro name should describe what the epilogue does, since
> frame pointers aren't required for _all_ functions, only those which
> don't have call instructions.
>
> What do you think about ENTRY_FRAME and ENDPROC_FRAME_RETURN? The
> ending macro is kind of long, but at least it a) matches the existing
> ENTRY/ENDPROC convention for asm functions; b) gives a clue that frame
> pointers are involved; and c) lets you know that the return is there.
So the thing I like about these:
FUNCTION_ENTRY(aesni_set_key)
...
FUNCTION_RETURN(aesni_set_key)
is the symmetry - it's a lot harder to misplace/miswrite these than two completely
separately named things:
ENTRY_FRAME(aesni_set_key)
...
ENDPROC_FRAME_RETURN(aesni_set_key)
Also, the 'FRAME' part will be pointless and somewhat misleading once we do
dwarves, right?
Another valid variants would be:
FUNCTION_ENTER(aesni_set_key)
...
FUNCTION_RET(aesni_set_key)
or:
FUNCTION_START(aesni_set_key)
...
FUNCTION_RET(aesni_set_key)
or:
ASM_FUNCTION_START(aesni_set_key)
...
ASM_FUNCTION_RET(aesni_set_key)
Note that the name has two parts:
- The symmetric 'FUNCTION_' prefix tells us that this is a callable function that
we are defining. That is a very significant property of this construct, and
should be present in both the 'start' and the 'end' markers.
- The '_RET' stresses the fact that it always generates a 'ret' instruction.
Note what the names _don't_ contain: that we generate debug info! That fact is not
present in the naming, and that's very much intentional, because the precise form
of debug info is conditional:
- if CONFIG_FRAME_POINTERS=y then we push/pop a stack frame
- if (later on) we do CFI annotations we don't push/pop a stack frame but emit
CFI debuginfo
In that sense 'FRAME' should never be in these names I think, nor 'PROC' (which is
not symmetric).
Plus all 3 variants I suggested are very easy to remember, why I'd always have to
look up any non-symmetric macro name called 'PROC'...
Thanks,
Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists