From: John Fastabend <john.fastabend@gmail.com>
To: songliubraving@fb.com, kafai@fb.com, daniel@iogearbox.net,
ast@kernel.org
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, john.fastabend@gmail.com
Subject: [bpf PATCH v3 4/5] bpf, selftests: Add tests for sock_ops load with r9, r8.r7 registers
Date: Tue, 11 Aug 2020 15:05:33 -0700 [thread overview]
Message-ID: <159718353345.4728.8805043614257933227.stgit@john-Precision-5820-Tower> (raw)
In-Reply-To: <159718333343.4728.9389284976477402193.stgit@john-Precision-5820-Tower>
Loads in sock_ops case when using high registers requires extra logic to
ensure the correct temporary value is used. We need to ensure the temp
register does not use either the src_reg or dst_reg. Lets add an asm
test to force the logic is triggered.
The xlated code is here,
30: (7b) *(u64 *)(r9 +32) = r7
31: (61) r7 = *(u32 *)(r9 +28)
32: (15) if r7 == 0x0 goto pc+2
33: (79) r7 = *(u64 *)(r9 +0)
34: (63) *(u32 *)(r7 +916) = r8
35: (79) r7 = *(u64 *)(r9 +32)
Notice r9 and r8 are not used for temp registers and r7 is chosen.
Acked-by: Song Liu <songliubraving@fb.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
---
.../testing/selftests/bpf/progs/test_tcpbpf_kern.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c b/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c
index f8b13682..6420b61 100644
--- a/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c
+++ b/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c
@@ -75,6 +75,13 @@ int bpf_testcb(struct bpf_sock_ops *skops)
: [skops] "r"(skops)
:);
+ asm volatile (
+ "r9 = %[skops];\n"
+ "r8 = *(u32 *)(r9 +164);\n"
+ "*(u32 *)(r9 +164) = r8;\n"
+ :: [skops] "r"(skops)
+ : "r9", "r8");
+
op = (int) skops->op;
update_event_map(op);
next prev parent reply other threads:[~2020-08-11 22:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-11 22:04 [bpf PATCH v3 0/5] Fix sock_ops field read splat John Fastabend
2020-08-11 22:04 ` [bpf PATCH v3 1/5] bpf: sock_ops ctx access may stomp registers in corner case John Fastabend
2020-08-11 22:04 ` [bpf PATCH v3 2/5] bpf: sock_ops sk access may stomp registers when dst_reg = src_reg John Fastabend
2020-08-11 22:05 ` [bpf PATCH v3 3/5] bpf, selftests: Add tests for ctx access in sock_ops with single register John Fastabend
2020-08-11 22:05 ` John Fastabend [this message]
2020-08-11 22:05 ` [bpf PATCH v3 5/5] bpf, selftests: Add tests to sock_ops for loading sk John Fastabend
2020-08-13 21:36 ` [bpf PATCH v3 0/5] Fix sock_ops field read splat Daniel Borkmann
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=159718353345.4728.8805043614257933227.stgit@john-Precision-5820-Tower \
--to=john.fastabend@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kafai@fb.com \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@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).