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 
10 SEC("socket")
11 __description("gotol, small_imm")
12 __success __success_unpriv __retval(1)
gotol_small_imm(void)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_%=;					\
19 l2_%=:							\
20 	gotol l3_%=;					\
21 l1_%=:							\
22 	r0 = 1;						\
23 	gotol l2_%=;					\
24 l0_%=:							\
25 	r0 = 2;						\
26 l3_%=:							\
27 	exit;						\
28 "	:
29 	: __imm(bpf_ktime_get_ns)
30 	: __clobber_all);
31 }
32 
33 #else
34 
35 SEC("socket")
36 __description("cpuv4 is not supported by compiler or jit, use a dummy test")
37 __success
dummy_test(void)38 int dummy_test(void)
39 {
40 	return 0;
41 }
42 
43 #endif
44 
45 char _license[] SEC("license") = "GPL";
46