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