[PATCH 2/2] ARM: psci: move psci firmware calls out of line

Will Deacon will.deacon at arm.com
Wed Mar 18 03:39:02 PDT 2015


On Wed, Mar 18, 2015 at 10:35:57AM +0000, Russell King - ARM Linux wrote:
> On Wed, Mar 18, 2015 at 10:30:14AM +0000, Will Deacon wrote:
> > On Wed, Mar 18, 2015 at 10:20:29AM +0000, Russell King - ARM Linux wrote:
> > > Why not convert these to:
> > > 
> > > static int __naked __invoke_psci_fn_hvc(u32 function_id, u32 arg0, u32 arg1,
> > > 					u32 arg2)
> > > {
> > > 	asm(
> > > 		__HVC(0)
> > > 		"bx lr");
> > > }
> > > 
> > > ?
> > 
> > I tried this, but the compiler printed a diagnostic along the lines of
> > "Ignoring __naked attribute", so we moved the functions out-of-line like
> > we have on arm64 instead. Assuming it worked reliably, what's the
> > advantage of __naked over having these out-of-line?
> 
> Note that the above isn't using any asm constraints/arguments.  The GCC
> manual states what can be safely included:
> 
> `naked'
>      Use this attribute on the ARM, AVR, IP2K, RX and SPU ports to
>      indicate that the specified function does not need
>      prologue/epilogue sequences generated by the compiler.  It is up
>      to the programmer to provide these sequences. The only statements
> 
>      that can be safely included in naked functions are `asm'
> 
>      statements that do not have operands.  All other statements,
>                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
>      including declarations of local variables, `if' statements, and so
>      forth, should be avoided.  Naked functions should be used to
>      implement the body of an assembly function, while allowing the
>      compiler to construct the requisite function declaration for the
>      assembler.
> 
> The advantage is that you have locality of code, and we don't need to
> spring up lots of assembly files along side their .c files.
> 
> I'd guess that if you try to declare local variables etc, the compiler
> will just ignore the naked attribute, because it then can't give the
> guarantees that the function will be truely naked.

In which case, I can reinvestigate when I get some spare cycles. IIRC, the
problem only cropped up with allmodconfig, because we compile with -pg
but it's all a bit hazy...

Will



More information about the linux-arm-kernel mailing list