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_func12.c (340B)


      1// SPDX-License-Identifier: GPL-2.0-only
      2#include <stddef.h>
      3#include <linux/bpf.h>
      4#include <bpf/bpf_helpers.h>
      5
      6struct S {
      7	int x;
      8};
      9
     10__noinline int foo(const struct S *s)
     11{
     12	return bpf_get_prandom_u32() < s->x;
     13}
     14
     15SEC("cgroup_skb/ingress")
     16int test_cls(struct __sk_buff *skb)
     17{
     18	const struct S s = {.x = skb->len };
     19
     20	return foo(&s);
     21}