Skip to content

Commit 8e0c151

Browse files
jrfastabborkmann
authored andcommitted
bpf, selftests: Add tests for sock_ops load with r9, r8.r7 registers
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. Signed-off-by: John Fastabend <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Song Liu <[email protected]> Acked-by: Martin KaFai Lau <[email protected]> Link: https://lore.kernel.org/bpf/159718353345.4728.8805043614257933227.stgit@john-Precision-5820-Tower
1 parent 86ed4be commit 8e0c151

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ int bpf_testcb(struct bpf_sock_ops *skops)
7575
: [skops] "r"(skops)
7676
:);
7777

78+
asm volatile (
79+
"r9 = %[skops];\n"
80+
"r8 = *(u32 *)(r9 +164);\n"
81+
"*(u32 *)(r9 +164) = r8;\n"
82+
:: [skops] "r"(skops)
83+
: "r9", "r8");
84+
7885
op = (int) skops->op;
7986

8087
update_event_map(op);

0 commit comments

Comments
 (0)