From: "Björn Töpel" <bjorn.topel@gmail.com>
To: daniel@iogearbox.net, ast@kernel.org, netdev@vger.kernel.org
Cc: "Björn Töpel" <bjorn.topel@gmail.com>, bpf@vger.kernel.org
Subject: [PATCH bpf] selftests: bpf: add zero extend checks for ALU32 and/or/xor
Date: Wed, 22 May 2019 11:23:23 +0200 [thread overview]
Message-ID: <20190522092323.17435-1-bjorn.topel@gmail.com> (raw)
Add three tests to test_verifier/basic_instr that make sure that the
high 32-bits of the destination register is cleared after an ALU32
and/or/xor.
Signed-off-by: Björn Töpel <bjorn.topel@gmail.com>
---
.../selftests/bpf/verifier/basic_instr.c | 39 +++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/tools/testing/selftests/bpf/verifier/basic_instr.c b/tools/testing/selftests/bpf/verifier/basic_instr.c
index ed91a7b9a456..4d844089938e 100644
--- a/tools/testing/selftests/bpf/verifier/basic_instr.c
+++ b/tools/testing/selftests/bpf/verifier/basic_instr.c
@@ -132,3 +132,42 @@
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
.result = ACCEPT,
},
+{
+ "and32 reg zero extend check",
+ .insns = {
+ BPF_MOV64_IMM(BPF_REG_0, -1),
+ BPF_MOV64_IMM(BPF_REG_2, -2),
+ BPF_ALU32_REG(BPF_AND, BPF_REG_0, BPF_REG_2),
+ BPF_ALU64_IMM(BPF_RSH, BPF_REG_0, 32),
+ BPF_EXIT_INSN(),
+ },
+ .prog_type = BPF_PROG_TYPE_SCHED_CLS,
+ .result = ACCEPT,
+ .retval = 0,
+},
+{
+ "or32 reg zero extend check",
+ .insns = {
+ BPF_MOV64_IMM(BPF_REG_0, -1),
+ BPF_MOV64_IMM(BPF_REG_2, -2),
+ BPF_ALU32_REG(BPF_OR, BPF_REG_0, BPF_REG_2),
+ BPF_ALU64_IMM(BPF_RSH, BPF_REG_0, 32),
+ BPF_EXIT_INSN(),
+ },
+ .prog_type = BPF_PROG_TYPE_SCHED_CLS,
+ .result = ACCEPT,
+ .retval = 0,
+},
+{
+ "xor32 reg zero extend check",
+ .insns = {
+ BPF_MOV64_IMM(BPF_REG_0, -1),
+ BPF_MOV64_IMM(BPF_REG_2, 0),
+ BPF_ALU32_REG(BPF_XOR, BPF_REG_0, BPF_REG_2),
+ BPF_ALU64_IMM(BPF_RSH, BPF_REG_0, 32),
+ BPF_EXIT_INSN(),
+ },
+ .prog_type = BPF_PROG_TYPE_SCHED_CLS,
+ .result = ACCEPT,
+ .retval = 0,
+},
--
2.20.1
next reply other threads:[~2019-05-22 9:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-22 9:23 Björn Töpel [this message]
2019-05-22 18:13 ` [PATCH bpf] selftests: bpf: add zero extend checks for ALU32 and/or/xor Y Song
2019-05-22 20:46 ` Björn Töpel
2019-05-23 6:38 ` Y Song
2019-05-23 7:48 ` Björn Töpel
2019-05-23 14:02 ` Daniel Borkmann
2019-05-23 14:31 ` Jiong Wang
2019-05-23 16:05 ` Björn Töpel
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=20190522092323.17435-1-bjorn.topel@gmail.com \
--to=bjorn.topel@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=netdev@vger.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 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).