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

recursion.c (747B)


      1// SPDX-License-Identifier: GPL-2.0
      2/* Copyright (c) 2021 Facebook */
      3
      4#include "vmlinux.h"
      5#include <bpf/bpf_helpers.h>
      6#include <bpf/bpf_tracing.h>
      7
      8char _license[] SEC("license") = "GPL";
      9
     10struct {
     11	__uint(type, BPF_MAP_TYPE_HASH);
     12	__uint(max_entries, 1);
     13	__type(key, int);
     14	__type(value, long);
     15} hash1 SEC(".maps");
     16
     17struct {
     18	__uint(type, BPF_MAP_TYPE_HASH);
     19	__uint(max_entries, 1);
     20	__type(key, int);
     21	__type(value, long);
     22} hash2 SEC(".maps");
     23
     24int pass1 = 0;
     25int pass2 = 0;
     26
     27SEC("fentry/htab_map_delete_elem")
     28int BPF_PROG(on_delete, struct bpf_map *map)
     29{
     30	int key = 0;
     31
     32	if (map == (void *)&hash1) {
     33		pass1++;
     34		return 0;
     35	}
     36	if (map == (void *)&hash2) {
     37		pass2++;
     38		bpf_map_delete_elem(&hash2, &key);
     39		return 0;
     40	}
     41
     42	return 0;
     43}