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

trigger_bench.c (1147B)


      1// SPDX-License-Identifier: GPL-2.0
      2// Copyright (c) 2020 Facebook
      3
      4#include <linux/bpf.h>
      5#include <asm/unistd.h>
      6#include <bpf/bpf_helpers.h>
      7#include <bpf/bpf_tracing.h>
      8#include "bpf_misc.h"
      9
     10char _license[] SEC("license") = "GPL";
     11
     12long hits = 0;
     13
     14SEC("tp/syscalls/sys_enter_getpgid")
     15int bench_trigger_tp(void *ctx)
     16{
     17	__sync_add_and_fetch(&hits, 1);
     18	return 0;
     19}
     20
     21SEC("raw_tp/sys_enter")
     22int BPF_PROG(bench_trigger_raw_tp, struct pt_regs *regs, long id)
     23{
     24	if (id == __NR_getpgid)
     25		__sync_add_and_fetch(&hits, 1);
     26	return 0;
     27}
     28
     29SEC("kprobe/" SYS_PREFIX "sys_getpgid")
     30int bench_trigger_kprobe(void *ctx)
     31{
     32	__sync_add_and_fetch(&hits, 1);
     33	return 0;
     34}
     35
     36SEC("fentry/" SYS_PREFIX "sys_getpgid")
     37int bench_trigger_fentry(void *ctx)
     38{
     39	__sync_add_and_fetch(&hits, 1);
     40	return 0;
     41}
     42
     43SEC("fentry.s/" SYS_PREFIX "sys_getpgid")
     44int bench_trigger_fentry_sleep(void *ctx)
     45{
     46	__sync_add_and_fetch(&hits, 1);
     47	return 0;
     48}
     49
     50SEC("fmod_ret/" SYS_PREFIX "sys_getpgid")
     51int bench_trigger_fmodret(void *ctx)
     52{
     53	__sync_add_and_fetch(&hits, 1);
     54	return -22;
     55}
     56
     57SEC("uprobe")
     58int bench_trigger_uprobe(void *ctx)
     59{
     60	__sync_add_and_fetch(&hits, 1);
     61	return 0;
     62}