Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.12-rc5 114 lines 2.1 kB view raw
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 8struct value_t { 9 long long a[32]; 10}; 11 12struct { 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 19SEC("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 114char _license[] SEC("license") = "GPL";