From: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
To: Segher Boessenkool <segher@kernel.crashing.org>,
Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
netdev@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>,
Sandipan Das <sandipan@linux.ibm.com>,
bpf@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: bpf jit PPC64 (BE) test_verifier PTR_TO_STACK store/load failure
Date: Fri, 15 Mar 2019 18:46:45 +0530 [thread overview]
Message-ID: <1552655762.yswcan0ziz.naveen@linux.ibm.com> (raw)
In-Reply-To: <20190313221436.GO3969@gate.crashing.org>
Segher Boessenkool wrote:
> Hi!
>
> On Wed, Mar 13, 2019 at 12:54:16PM +0200, Yauheni Kaliuta wrote:
>> This is because of the handling of the +2 offset.
>
> The low two bits of instructions with primary opcodes 58 and 62 are part
> of the opcode, not the offset. These instructions can not have offsets
> with the low two bits non-zero.
>
>> For stores it is:
>> #define PPC_STD(r, base, i) EMIT(PPC_INST_STD | ___PPC_RS(r) | \
>> ___PPC_RA(base) | ((i) & 0xfffc))
>>
>> and for loads
>> #define PPC_LD(r, base, i) EMIT(PPC_INST_LD | ___PPC_RT(r) | \
>> ___PPC_RA(base) | IMM_L(i))
>> #define IMM_L(i) ((uintptr_t)(i) & 0xffff)
>>
>> So, in the load case the offset +2 (immediate value) is not
>> masked and turns the instruction to lwa instead of ld.
>>
>> Would it be correct to & 0xfffc the immediate value as well?
>
> That is only part of it. The other thing is you have to make sure those
> low bits are zero *already* (and then you do not need the mask anymore).
> For example, if the low two bits are not zero load the offset into a
> register instead (and then do ldx or lwax).
Thanks for pointing that out, Segher. That is a detail that is easily
missed.
- Naveen
prev parent reply other threads:[~2019-03-15 13:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-13 10:54 bpf jit PPC64 (BE) test_verifier PTR_TO_STACK store/load failure Yauheni Kaliuta
2019-03-13 13:51 ` Naveen N. Rao
2019-03-13 22:14 ` Segher Boessenkool
2019-03-15 13:16 ` Naveen N. Rao [this message]
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=1552655762.yswcan0ziz.naveen@linux.ibm.com \
--to=naveen.n.rao@linux.ibm.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jolsa@redhat.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=sandipan@linux.ibm.com \
--cc=segher@kernel.crashing.org \
--cc=yauheni.kaliuta@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).