All of lore.kernel.org
 help / color / mirror / Atom feed
From: yang.shi@linaro.org (Shi, Yang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] arm64: bpf: make BPF prologue and epilogue align with ARM64 AAPCS
Date: Fri, 13 Nov 2015 09:28:45 -0800	[thread overview]
Message-ID: <56461DCD.4020701@linaro.org> (raw)
In-Reply-To: <CABg9mctTj2M7Mw+bPgkDYtorW21uTuLxWnxLFucWPtM4TQ-7VA@mail.gmail.com>

On 11/12/2015 7:28 PM, Z Lim wrote:
> On Thu, Nov 12, 2015 at 1:57 PM, Yang Shi <yang.shi@linaro.org> wrote:
>>
>> Save and restore FP/LR in BPF prog prologue and epilogue, save SP to FP
>> in prologue in order to get the correct stack backtrace.
>>
>> However, ARM64 JIT used FP (x29) as eBPF fp register, FP is subjected to
>> change during function call so it may cause the BPF prog stack base address
>> change too.
>>
>> Use x25 to replace FP as BPF stack base register (fp). Since x25 is callee
>> saved register, so it will keep intact during function call.
>> It is initialized in BPF prog prologue when BPF prog is started to run
>> everytime. When BPF prog exits, it could be just tossed.
>>
>> So, the BPF stack layout looks like:
>>
>>                                   high
>>           original A64_SP =>   0:+-----+ BPF prologue
>>                                  |     | FP/LR and callee saved registers
>>           BPF fp register => -64:+-----+
>>                                  |     |
>>                                  | ... | BPF prog stack
>>                                  |     |
>>                                  |     |
>>           current A64_SP/FP =>   +-----+
>>                                  |     |
>>                                  | ... | Function call stack
>>                                  |     |
>>                                  +-----+
>>                                    low
>>
>
> Yang, for stack unwinding to work, shouldn't it be something like the following?

Yes, thanks for catching this. v3 will be post soon.

Yang

>
>            | LR |
> A64_FP => | FP |
>            | .. |
>

WARNING: multiple messages have this Message-ID (diff)
From: "Shi, Yang" <yang.shi@linaro.org>
To: Z Lim <zlim.lnx@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	daniel@iogearbox.net, Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>, Xi Wang <xi.wang@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Network Development <netdev@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	linaro-kernel@lists.linaro.org
Subject: Re: [PATCH 2/2] arm64: bpf: make BPF prologue and epilogue align with ARM64 AAPCS
Date: Fri, 13 Nov 2015 09:28:45 -0800	[thread overview]
Message-ID: <56461DCD.4020701@linaro.org> (raw)
In-Reply-To: <CABg9mctTj2M7Mw+bPgkDYtorW21uTuLxWnxLFucWPtM4TQ-7VA@mail.gmail.com>

On 11/12/2015 7:28 PM, Z Lim wrote:
> On Thu, Nov 12, 2015 at 1:57 PM, Yang Shi <yang.shi@linaro.org> wrote:
>>
>> Save and restore FP/LR in BPF prog prologue and epilogue, save SP to FP
>> in prologue in order to get the correct stack backtrace.
>>
>> However, ARM64 JIT used FP (x29) as eBPF fp register, FP is subjected to
>> change during function call so it may cause the BPF prog stack base address
>> change too.
>>
>> Use x25 to replace FP as BPF stack base register (fp). Since x25 is callee
>> saved register, so it will keep intact during function call.
>> It is initialized in BPF prog prologue when BPF prog is started to run
>> everytime. When BPF prog exits, it could be just tossed.
>>
>> So, the BPF stack layout looks like:
>>
>>                                   high
>>           original A64_SP =>   0:+-----+ BPF prologue
>>                                  |     | FP/LR and callee saved registers
>>           BPF fp register => -64:+-----+
>>                                  |     |
>>                                  | ... | BPF prog stack
>>                                  |     |
>>                                  |     |
>>           current A64_SP/FP =>   +-----+
>>                                  |     |
>>                                  | ... | Function call stack
>>                                  |     |
>>                                  +-----+
>>                                    low
>>
>
> Yang, for stack unwinding to work, shouldn't it be something like the following?

Yes, thanks for catching this. v3 will be post soon.

Yang

>
>            | LR |
> A64_FP => | FP |
>            | .. |
>


  reply	other threads:[~2015-11-13 17:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-12 21:56 [PATCH V2 0/2] arm64: bpf: correct JIT stack setup and make it align with ARM64 AAPCS Yang Shi
2015-11-12 21:56 ` Yang Shi
2015-11-12 21:57 ` [PATCH 1/2] arm64: bpf: fix JIT frame pointer setup Yang Shi
2015-11-12 21:57   ` Yang Shi
2015-11-13  3:21   ` Z Lim
2015-11-13  3:21     ` Z Lim
2015-11-16 19:39   ` David Miller
2015-11-16 19:39     ` David Miller
2015-11-12 21:57 ` [PATCH 2/2] arm64: bpf: make BPF prologue and epilogue align with ARM64 AAPCS Yang Shi
2015-11-12 21:57   ` Yang Shi
2015-11-13  3:28   ` Z Lim
2015-11-13  3:28     ` Z Lim
2015-11-13 17:28     ` Shi, Yang [this message]
2015-11-13 17:28       ` Shi, Yang

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=56461DCD.4020701@linaro.org \
    --to=yang.shi@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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.