From: Yonghong Song <yhs@fb.com>
To: John Fastabend <john.fastabend@gmail.com>,
Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next 1/2] bpf: fix a verifier failure with xor
Date: Tue, 1 Sep 2020 22:43:03 -0700 [thread overview]
Message-ID: <c26f372b-748e-2141-33bc-00d40c5e4205@fb.com> (raw)
In-Reply-To: <5f4f2d24485ac_5f398208c@john-XPS-13-9370.notmuch>
On 9/1/20 10:27 PM, John Fastabend wrote:
> Yonghong Song wrote:
>>
>>
>> On 9/1/20 1:07 PM, Andrii Nakryiko wrote:
>>> On Mon, Aug 24, 2020 at 11:47 PM Yonghong Song <yhs@fb.com> wrote:
>>>>
>>>> bpf selftest test_progs/test_sk_assign failed with llvm 11 and llvm 12.
>>>> Compared to llvm 10, llvm 11 and 12 generates xor instruction which
>>>
>>> Does this mean that some perfectly working BPF programs will now fail
>>> to verify on older kernels, if compiled with llvm 11 or llvm 12? If
>>
>> Right.
>>
>>> yes, is there something that one can do to prevent Clang from using
>>> xor in such situations?
>>
>> The xor is generated by the combination of llvm simplifyCFG and
>> instrCombine phase.
>
> Another option would be to move it out of the isAsCheapAsAMove on the
John, do you mean the following change?
diff --git a/llvm/lib/Target/BPF/BPFInstrInfo.td
b/llvm/lib/Target/BPF/BPFInstrInfo.td
index 4298e2eaec04..7448a2499d40 100644
--- a/llvm/lib/Target/BPF/BPFInstrInfo.td
+++ b/llvm/lib/Target/BPF/BPFInstrInfo.td
@@ -293,9 +293,9 @@ let isAsCheapAsAMove = 1 in {
defm AND : ALU<BPF_AND, "&=", and>;
defm SLL : ALU<BPF_LSH, "<<=", shl>;
defm SRL : ALU<BPF_RSH, ">>=", srl>;
- defm XOR : ALU<BPF_XOR, "^=", xor>;
defm SRA : ALU<BPF_ARSH, "s>>=", sra>;
}
+ defm XOR : ALU<BPF_XOR, "^=", xor>;
defm MUL : ALU<BPF_MUL, "*=", mul>;
defm DIV : ALU<BPF_DIV, "/=", udiv>;
}
Tried the above change with latest trunk. xor still generated :-(
I did not trace down to exact llvm optimization location for this
particular optimization instance.
> llvm side. But, probably better to force the workaround until kernels
> get support. Even with it being more expensive it wouldn't mean we never
> get it so likely not a great idea. Just thought it might be worth
> mentioning. If you have your own llvm and don't have these kernels yet
> it looks like a win.
>
>>
>> The following is a hack to prevent compiler from generating xor's.
next prev parent reply other threads:[~2020-09-02 5:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-25 6:46 [PATCH bpf-next 0/2] fix a verifier failure with xor Yonghong Song
2020-08-25 6:46 ` [PATCH bpf-next 1/2] bpf: " Yonghong Song
2020-08-26 1:58 ` Alexei Starovoitov
2020-08-26 3:36 ` Yonghong Song
2020-08-26 22:06 ` John Fastabend
2020-08-27 5:12 ` Alexei Starovoitov
2020-08-27 18:43 ` John Fastabend
2020-09-01 20:07 ` Andrii Nakryiko
2020-09-02 2:17 ` Yonghong Song
2020-09-02 5:27 ` John Fastabend
2020-09-02 5:43 ` Yonghong Song [this message]
2020-09-04 5:29 ` John Fastabend
2020-09-02 9:33 ` Toke Høiland-Jørgensen
2020-09-02 14:21 ` Alexei Starovoitov
2020-09-02 15:01 ` Toke Høiland-Jørgensen
2020-09-02 21:40 ` Alexei Starovoitov
2020-08-25 6:46 ` [PATCH bpf-next 2/2] selftests/bpf: add verifier tests for xor operation Yonghong Song
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=c26f372b-748e-2141-33bc-00d40c5e4205@fb.com \
--to=yhs@fb.com \
--cc=andrii.nakryiko@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kernel-team@fb.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).