~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/progs/verifier_jit_convergence.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */
  3 
  4 #include <linux/bpf.h>
  5 #include <bpf/bpf_helpers.h>
  6 #include "bpf_misc.h"
  7 
  8 struct value_t {
  9         long long a[32];
 10 };
 11 
 12 struct {
 13         __uint(type, BPF_MAP_TYPE_HASH);
 14         __uint(max_entries, 1);
 15         __type(key, long long);
 16         __type(value, struct value_t);
 17 } map_hash SEC(".maps");
 18 
 19 SEC("socket")
 20 __description("bpf_jit_convergence je <-> jmp")
 21 __success __retval(0)
 22 __arch_x86_64
 23 __jited("       pushq   %rbp")
 24 __naked void btf_jit_convergence_je_jmp(void)
 25 {
 26         asm volatile (
 27         "call %[bpf_get_prandom_u32];"
 28         "if r0 == 0 goto l20_%=;"
 29         "if r0 == 1 goto l21_%=;"
 30         "if r0 == 2 goto l22_%=;"
 31         "if r0 == 3 goto l23_%=;"
 32         "if r0 == 4 goto l24_%=;"
 33         "call %[bpf_get_prandom_u32];"
 34         "call %[bpf_get_prandom_u32];"
 35 "l20_%=:"
 36 "l21_%=:"
 37 "l22_%=:"
 38 "l23_%=:"
 39 "l24_%=:"
 40         "r1 = 0;"
 41         "*(u64 *)(r10 - 8) = r1;"
 42         "r2 = r10;"
 43         "r2 += -8;"
 44         "r1 = %[map_hash] ll;"
 45         "call %[bpf_map_lookup_elem];"
 46         "if r0 == 0 goto l1_%=;"
 47         "r6 = r0;"
 48         "call %[bpf_get_prandom_u32];"
 49         "r7 = r0;"
 50         "r5 = r6;"
 51         "if r0 != 0x0 goto l12_%=;"
 52         "call %[bpf_get_prandom_u32];"
 53         "r1 = r0;"
 54         "r2 = r6;"
 55         "if r1 == 0x0 goto l0_%=;"
 56 "l9_%=:"
 57         "r2 = *(u64 *)(r6 + 0x0);"
 58         "r2 += 0x1;"
 59         "*(u64 *)(r6 + 0x0) = r2;"
 60         "goto l1_%=;"
 61 "l12_%=:"
 62         "r1 = r7;"
 63         "r1 += 0x98;"
 64         "r2 = r5;"
 65         "r2 += 0x90;"
 66         "r2 = *(u32 *)(r2 + 0x0);"
 67         "r3 = r7;"
 68         "r3 &= 0x1;"
 69         "r2 *= 0xa8;"
 70         "if r3 == 0x0 goto l2_%=;"
 71         "r1 += r2;"
 72         "r1 -= r7;"
 73         "r1 += 0x8;"
 74         "if r1 <= 0xb20 goto l3_%=;"
 75         "r1 = 0x0;"
 76         "goto l4_%=;"
 77 "l3_%=:"
 78         "r1 += r7;"
 79 "l4_%=:"
 80         "if r1 == 0x0 goto l8_%=;"
 81         "goto l9_%=;"
 82 "l2_%=:"
 83         "r1 += r2;"
 84         "r1 -= r7;"
 85         "r1 += 0x10;"
 86         "if r1 <= 0xb20 goto l6_%=;"
 87         "r1 = 0x0;"
 88         "goto l7_%=;"
 89 "l6_%=:"
 90         "r1 += r7;"
 91 "l7_%=:"
 92         "if r1 == 0x0 goto l8_%=;"
 93         "goto l9_%=;"
 94 "l0_%=:"
 95         "r1 = 0x3;"
 96         "*(u64 *)(r10 - 0x10) = r1;"
 97         "r2 = r1;"
 98         "goto l1_%=;"
 99 "l8_%=:"
100         "r1 = r5;"
101         "r1 += 0x4;"
102         "r1 = *(u32 *)(r1 + 0x0);"
103         "*(u64 *)(r10 - 0x8) = r1;"
104 "l1_%=:"
105         "r0 = 0;"
106         "exit;"
107         :
108         : __imm(bpf_get_prandom_u32),
109           __imm(bpf_map_lookup_elem),
110           __imm_addr(map_hash)
111         : __clobber_all);
112 }
113 
114 char _license[] SEC("license") = "GPL";
115 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php