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

test_global_func3.c (965B)


      1// SPDX-License-Identifier: GPL-2.0-only
      2/* Copyright (c) 2020 Facebook */
      3#include <stddef.h>
      4#include <linux/bpf.h>
      5#include <bpf/bpf_helpers.h>
      6
      7__attribute__ ((noinline))
      8int f1(struct __sk_buff *skb)
      9{
     10	return skb->len;
     11}
     12
     13__attribute__ ((noinline))
     14int f2(int val, struct __sk_buff *skb)
     15{
     16	return f1(skb) + val;
     17}
     18
     19__attribute__ ((noinline))
     20int f3(int val, struct __sk_buff *skb, int var)
     21{
     22	return f2(var, skb) + val;
     23}
     24
     25__attribute__ ((noinline))
     26int f4(struct __sk_buff *skb)
     27{
     28	return f3(1, skb, 2);
     29}
     30
     31__attribute__ ((noinline))
     32int f5(struct __sk_buff *skb)
     33{
     34	return f4(skb);
     35}
     36
     37__attribute__ ((noinline))
     38int f6(struct __sk_buff *skb)
     39{
     40	return f5(skb);
     41}
     42
     43__attribute__ ((noinline))
     44int f7(struct __sk_buff *skb)
     45{
     46	return f6(skb);
     47}
     48
     49#ifndef NO_FN8
     50__attribute__ ((noinline))
     51int f8(struct __sk_buff *skb)
     52{
     53	return f7(skb);
     54}
     55#endif
     56
     57SEC("tc")
     58int test_cls(struct __sk_buff *skb)
     59{
     60#ifndef NO_FN8
     61	return f8(skb);
     62#else
     63	return f7(skb);
     64#endif
     65}