1// SPDX-License-Identifier: GPL-2.0
2
3#include <linux/bpf.h>
4#include <bpf/bpf_helpers.h>
5#include "bpf_misc.h"
6
7#if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \
8     (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64)) && __clang_major__ >= 18
9
10SEC("socket")
11__description("gotol, small_imm")
12__success __success_unpriv __retval(1)
13__naked void gotol_small_imm(void)
14{
15	asm volatile ("					\
16	call %[bpf_ktime_get_ns];			\
17	if r0 == 0 goto l0_%=;				\
18	gotol l1_%=;					\
19l2_%=:							\
20	gotol l3_%=;					\
21l1_%=:							\
22	r0 = 1;						\
23	gotol l2_%=;					\
24l0_%=:							\
25	r0 = 2;						\
26l3_%=:							\
27	exit;						\
28"	:
29	: __imm(bpf_ktime_get_ns)
30	: __clobber_all);
31}
32
33#else
34
35SEC("socket")
36__description("cpuv4 is not supported by compiler or jit, use a dummy test")
37__success
38int dummy_test(void)
39{
40	return 0;
41}
42
43#endif
44
45char _license[] SEC("license") = "GPL";
46