Skip to content

Commit ffb515c

Browse files
eddyz87Alexei Starovoitov
authored andcommitted
selftests/bpf: verifier/xdp.c converted to inline assembly
Test verifier/xdp.c automatically converted to use inline assembly. Signed-off-by: Eduard Zingerman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent a8036ae commit ffb515c

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

tools/testing/selftests/bpf/prog_tests/verifier.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "verifier_value_or_null.skel.h"
4040
#include "verifier_var_off.skel.h"
4141
#include "verifier_xadd.skel.h"
42+
#include "verifier_xdp.skel.h"
4243

4344
__maybe_unused
4445
static void run_tests_aux(const char *skel_name, skel_elf_bytes_fn elf_bytes_factory)
@@ -100,3 +101,4 @@ void test_verifier_value(void) { RUN(verifier_value); }
100101
void test_verifier_value_or_null(void) { RUN(verifier_value_or_null); }
101102
void test_verifier_var_off(void) { RUN(verifier_var_off); }
102103
void test_verifier_xadd(void) { RUN(verifier_xadd); }
104+
void test_verifier_xdp(void) { RUN(verifier_xdp); }
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* Converted from tools/testing/selftests/bpf/verifier/xdp.c */
3+
4+
#include <linux/bpf.h>
5+
#include <bpf/bpf_helpers.h>
6+
#include "bpf_misc.h"
7+
8+
SEC("xdp")
9+
__description("XDP, using ifindex from netdev")
10+
__success __retval(1)
11+
__naked void xdp_using_ifindex_from_netdev(void)
12+
{
13+
asm volatile (" \
14+
r0 = 0; \
15+
r2 = *(u32*)(r1 + %[xdp_md_ingress_ifindex]); \
16+
if r2 < 1 goto l0_%=; \
17+
r0 = 1; \
18+
l0_%=: exit; \
19+
" :
20+
: __imm_const(xdp_md_ingress_ifindex, offsetof(struct xdp_md, ingress_ifindex))
21+
: __clobber_all);
22+
}
23+
24+
char _license[] SEC("license") = "GPL";

tools/testing/selftests/bpf/verifier/xdp.c

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)