cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

tailcall_bpf2bpf6.c (801B)


      1// SPDX-License-Identifier: GPL-2.0
      2#include <linux/bpf.h>
      3#include <bpf/bpf_helpers.h>
      4
      5#define __unused __attribute__((unused))
      6
      7struct {
      8	__uint(type, BPF_MAP_TYPE_PROG_ARRAY);
      9	__uint(max_entries, 1);
     10	__uint(key_size, sizeof(__u32));
     11	__uint(value_size, sizeof(__u32));
     12} jmp_table SEC(".maps");
     13
     14int done = 0;
     15
     16SEC("tc")
     17int classifier_0(struct __sk_buff *skb __unused)
     18{
     19	done = 1;
     20	return 0;
     21}
     22
     23static __noinline
     24int subprog_tail(struct __sk_buff *skb)
     25{
     26	/* Don't propagate the constant to the caller */
     27	volatile int ret = 1;
     28
     29	bpf_tail_call_static(skb, &jmp_table, 0);
     30	return ret;
     31}
     32
     33SEC("tc")
     34int entry(struct __sk_buff *skb)
     35{
     36	/* Have data on stack which size is not a multiple of 8 */
     37	volatile char arr[1] = {};
     38
     39	return subprog_tail(skb);
     40}
     41
     42char __license[] SEC("license") = "GPL";