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_usdt_multispec.c (691B)


      1// SPDX-License-Identifier: GPL-2.0
      2/* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */
      3
      4#include "vmlinux.h"
      5#include <bpf/bpf_helpers.h>
      6#include <bpf/usdt.bpf.h>
      7
      8/* this file is linked together with test_usdt.c to validate that usdt.bpf.h
      9 * can be included in multiple .bpf.c files forming single final BPF object
     10 * file
     11 */
     12
     13extern int my_pid;
     14
     15int usdt_100_called;
     16int usdt_100_sum;
     17
     18SEC("usdt//proc/self/exe:test:usdt_100")
     19int BPF_USDT(usdt_100, int x)
     20{
     21	long tmp;
     22
     23	if (my_pid != (bpf_get_current_pid_tgid() >> 32))
     24		return 0;
     25
     26	__sync_fetch_and_add(&usdt_100_called, 1);
     27	__sync_fetch_and_add(&usdt_100_sum, x);
     28
     29	return 0;
     30}
     31
     32char _license[] SEC("license") = "GPL";