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 nocache-cleanup 109 lines 2.5 kB view raw
1// SPDX-License-Identifier: GPL-2.0 2/* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */ 3 4#include <linux/bpf.h> 5#include <bpf/bpf_helpers.h> 6#include "../../../include/linux/filter.h" 7#include "bpf_misc.h" 8 9SEC("raw_tp") 10__description("may_goto 0") 11__arch_x86_64 12__arch_s390x 13__arch_arm64 14__xlated("0: r0 = 1") 15__xlated("1: exit") 16__success 17__naked void may_goto_simple(void) 18{ 19 asm volatile ( 20 ".8byte %[may_goto];" 21 "r0 = 1;" 22 ".8byte %[may_goto];" 23 "exit;" 24 : 25 : __imm_insn(may_goto, BPF_RAW_INSN(BPF_JMP | BPF_JCOND, 0, 0, 0 /* offset */, 0)) 26 : __clobber_all); 27} 28 29SEC("raw_tp") 30__description("batch 2 of may_goto 0") 31__arch_x86_64 32__arch_s390x 33__arch_arm64 34__xlated("0: r0 = 1") 35__xlated("1: exit") 36__success 37__naked void may_goto_batch_0(void) 38{ 39 asm volatile ( 40 ".8byte %[may_goto1];" 41 ".8byte %[may_goto1];" 42 "r0 = 1;" 43 ".8byte %[may_goto1];" 44 ".8byte %[may_goto1];" 45 "exit;" 46 : 47 : __imm_insn(may_goto1, BPF_RAW_INSN(BPF_JMP | BPF_JCOND, 0, 0, 0 /* offset */, 0)) 48 : __clobber_all); 49} 50 51SEC("raw_tp") 52__description("may_goto batch with offsets 2/1/0") 53__arch_x86_64 54__arch_s390x 55__arch_arm64 56__xlated("0: r0 = 1") 57__xlated("1: exit") 58__success 59__naked void may_goto_batch_1(void) 60{ 61 asm volatile ( 62 ".8byte %[may_goto1];" 63 ".8byte %[may_goto2];" 64 ".8byte %[may_goto3];" 65 "r0 = 1;" 66 ".8byte %[may_goto1];" 67 ".8byte %[may_goto2];" 68 ".8byte %[may_goto3];" 69 "exit;" 70 : 71 : __imm_insn(may_goto1, BPF_RAW_INSN(BPF_JMP | BPF_JCOND, 0, 0, 2 /* offset */, 0)), 72 __imm_insn(may_goto2, BPF_RAW_INSN(BPF_JMP | BPF_JCOND, 0, 0, 1 /* offset */, 0)), 73 __imm_insn(may_goto3, BPF_RAW_INSN(BPF_JMP | BPF_JCOND, 0, 0, 0 /* offset */, 0)) 74 : __clobber_all); 75} 76 77SEC("raw_tp") 78__description("may_goto batch with offsets 2/0") 79__arch_x86_64 80__arch_s390x 81__arch_arm64 82__xlated("0: *(u64 *)(r10 -16) = 65535") 83__xlated("1: *(u64 *)(r10 -8) = 0") 84__xlated("2: r11 = *(u64 *)(r10 -16)") 85__xlated("3: if r11 == 0x0 goto pc+6") 86__xlated("4: r11 -= 1") 87__xlated("5: if r11 != 0x0 goto pc+2") 88__xlated("6: r11 = -16") 89__xlated("7: call unknown") 90__xlated("8: *(u64 *)(r10 -16) = r11") 91__xlated("9: r0 = 1") 92__xlated("10: r0 = 2") 93__xlated("11: exit") 94__success 95__naked void may_goto_batch_2(void) 96{ 97 asm volatile ( 98 ".8byte %[may_goto1];" 99 ".8byte %[may_goto3];" 100 "r0 = 1;" 101 "r0 = 2;" 102 "exit;" 103 : 104 : __imm_insn(may_goto1, BPF_RAW_INSN(BPF_JMP | BPF_JCOND, 0, 0, 2 /* offset */, 0)), 105 __imm_insn(may_goto3, BPF_RAW_INSN(BPF_JMP | BPF_JCOND, 0, 0, 0 /* offset */, 0)) 106 : __clobber_all); 107} 108 109char _license[] SEC("license") = "GPL";