All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Thierry <jthierry@redhat.com>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Alexandre Chartre <alexandre.chartre@oracle.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	peterz@infradead.org, tglx@linutronix.de
Subject: Re: [PATCH 3/7] objtool: Add support for intra-function calls
Date: Fri, 3 Apr 2020 09:01:38 +0100	[thread overview]
Message-ID: <3d075cb2-8d99-5ab7-4842-efef1964247d@redhat.com> (raw)
In-Reply-To: <20200402154919.2c6shw4hfreagchg@treble>



On 4/2/20 4:49 PM, Josh Poimboeuf wrote:
> On Thu, Apr 02, 2020 at 01:53:49PM +0100, Julien Thierry wrote:
>> Hi Alexandre,
>>
>> I ran into the limitation of intra-function call for the arm64 support but
>> didn't take the time to make a clean patch to support them properly.
> 
> Can you give an example of where arm64 uses intra-function calls?  It
> sounds sketchy to me :-)  Is it really needed/useful?
> 

So the most notable/necessary one(s) is the one in tramp_ventry [1]. 
This macro is used as the begining of exception handlers for exceptions 
coming from userland. It was added as part of the mitigations of spectre 
(v1???).

To give some context, x30 is the register that "ret" instruction will 
use as return address, "bl" is the equivalent of x86 "call" and sets x30 
before jumping to the target address. (However, it doesn't have a 
special semantic for exception returns)

Note: I believe the comment about the return "stack" is about processor 
internal state (speculative thingies and all) rather than the actual 
stack, since the stack is untouched by that code. But I don't know the 
actual details.


There are also some in arch/arm64/crypto/crct10dif-ce-core.o , which is 
probably full of fast, smart and optimized code I don't understand :) . 
So I wouldn't feel confident commenting on whether those intra-function 
calls are needed or not.


Last I found is in qcom_link_stack_sanitization() [2], but that's just a 
workaround for a very specific hardware. In my local tree I just put the 
function as STACK_FRAME_NON_STANDARD. But the code just saves the return 
address, has 16 call instructions that just call the instruction after 
them, restores the return address and lets the C-function return 
normally (and it somehow fixes something for that hardware).


Those are the ones I stumbled on. So yes, it a bit sketchy, corner case 
code, but it's there and unlikely to go away.


[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/kernel/entry.S?h=v5.6#n803

[2] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/kernel/cpu_errata.c?h=v5.6#n195

Cheers,

-- 
Julien Thierry


  parent reply	other threads:[~2020-04-03  8:01 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-02  8:22 [PATCH 0/7] objtool changes to remove most ANNOTATE_NOSPEC_ALTERNATIVE Alexandre Chartre
2020-04-02  8:22 ` [PATCH 1/7] objtool: is_fentry_call() crashes if call has no destination Alexandre Chartre
2020-04-02  8:22 ` [PATCH 2/7] objtool: Allow branches within the same alternative Alexandre Chartre
2020-04-02 12:03   ` Julien Thierry
2020-04-02 12:38     ` Alexandre Chartre
2020-04-02  8:22 ` [PATCH 3/7] objtool: Add support for intra-function calls Alexandre Chartre
2020-04-02 12:53   ` Julien Thierry
2020-04-02 13:24     ` Alexandre Chartre
2020-04-02 13:38       ` Julien Thierry
2020-04-02 14:56         ` Alexandre Chartre
2020-04-02 15:04       ` Peter Zijlstra
2020-04-02 15:54         ` Josh Poimboeuf
2020-04-03  7:06           ` Alexandre Chartre
2020-04-02 15:49     ` Josh Poimboeuf
2020-04-02 17:27       ` Josh Poimboeuf
2020-04-03  8:01       ` Julien Thierry [this message]
2020-04-03 12:41         ` Peter Zijlstra
2020-04-03 12:49           ` Julien Thierry
2020-04-03 14:37             ` Peter Zijlstra
2020-04-03 14:44         ` Josh Poimboeuf
2020-04-02  8:22 ` [PATCH 4/7] objtool: Add support for return trampoline call Alexandre Chartre
2020-04-02 13:26   ` Julien Thierry
2020-04-02 14:46     ` Alexandre Chartre
2020-04-02 15:31       ` Julien Thierry
2020-04-02 15:40         ` Peter Zijlstra
2020-04-03  8:11           ` Julien Thierry
2020-04-03 15:17             ` Josh Poimboeuf
2020-04-03 15:22               ` Josh Poimboeuf
2020-04-03 15:32                 ` Josh Poimboeuf
2020-04-03 15:46               ` Peter Zijlstra
2020-04-03 15:55                 ` Josh Poimboeuf
2020-04-04 13:32                 ` Peter Zijlstra
2020-04-04 14:22                   ` Josh Poimboeuf
2020-04-04 15:51                     ` Peter Zijlstra
2020-04-06  8:19                       ` Alexandre Chartre
2020-04-06  9:31                         ` Peter Zijlstra
2020-04-06 11:03                           ` Alexandre Chartre
2020-04-06 14:16                       ` Josh Poimboeuf
2020-04-02 15:27   ` Peter Zijlstra
2020-04-03  7:19     ` Alexandre Chartre
2020-04-06 14:34     ` Alexandre Chartre
2020-04-06 14:55       ` Alexandre Chartre
2020-04-02  8:22 ` [PATCH 5/7] x86/speculation: Annotate intra-function calls Alexandre Chartre
2020-04-03 16:05   ` Josh Poimboeuf
2020-04-03 16:16     ` Josh Poimboeuf
2020-04-03 17:14       ` Alexandre Chartre
2020-04-03 17:18         ` Peter Zijlstra
2020-04-03 17:24           ` Josh Poimboeuf
2020-04-03 18:20             ` Peter Zijlstra
2020-04-02  8:22 ` [PATCH 6/7] x86/speculation: Annotate retpoline return instructions Alexandre Chartre
2020-04-02  8:22 ` [PATCH 7/7] x86/speculation: Remove most ANNOTATE_NOSPEC_ALTERNATIVE Alexandre Chartre
2020-04-03  7:53   ` kbuild test robot

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=3d075cb2-8d99-5ab7-4842-efef1964247d@redhat.com \
    --to=jthierry@redhat.com \
    --cc=alexandre.chartre@oracle.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --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.