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

add_remove_eprobe.tc (2816B)


      1#!/bin/sh
      2# SPDX-License-Identifier: GPL-2.0
      3# description: Generic dynamic event - add/remove eprobe events
      4# requires: dynamic_events events/syscalls/sys_enter_openat "e[:[<group>/]<event>] <attached-group>.<attached-event> [<args>]":README
      5
      6echo 0 > events/enable
      7
      8clear_dynamic_events
      9
     10SYSTEM="syscalls"
     11EVENT="sys_enter_openat"
     12FIELD="filename"
     13EPROBE="eprobe_open"
     14OPTIONS="file=+0(\$filename):ustring"
     15echo "e:$EPROBE $SYSTEM/$EVENT $OPTIONS" >> dynamic_events
     16
     17grep -q "$EPROBE" dynamic_events
     18test -d events/eprobes/$EPROBE
     19
     20echo 1 > events/eprobes/$EPROBE/enable
     21ls
     22echo 0 > events/eprobes/$EPROBE/enable
     23
     24content=`grep '^ *ls-' trace | grep 'file='`
     25nocontent=`grep '^ *ls-' trace | grep 'file=' | grep -v -e '"/' -e '"."' -e '(fault)' ` || true
     26
     27if [ -z "$content" ]; then
     28	exit_fail
     29fi
     30
     31if [ ! -z "$nocontent" ]; then
     32	exit_fail
     33fi
     34
     35echo "-:$EPROBE" >> dynamic_events
     36
     37! grep -q "$EPROBE" dynamic_events
     38! test -d events/eprobes/$EPROBE
     39
     40# test various ways to remove the probe (already tested with just event name)
     41
     42# With group name
     43echo "e:$EPROBE $SYSTEM/$EVENT $OPTIONS" >> dynamic_events
     44grep -q "$EPROBE" dynamic_events
     45test -d events/eprobes/$EPROBE
     46echo "-:eprobes/$EPROBE" >> dynamic_events
     47! grep -q "$EPROBE" dynamic_events
     48! test -d events/eprobes/$EPROBE
     49
     50# With group name and system/event
     51echo "e:$EPROBE $SYSTEM/$EVENT $OPTIONS" >> dynamic_events
     52grep -q "$EPROBE" dynamic_events
     53test -d events/eprobes/$EPROBE
     54echo "-:eprobes/$EPROBE $SYSTEM/$EVENT" >> dynamic_events
     55! grep -q "$EPROBE" dynamic_events
     56! test -d events/eprobes/$EPROBE
     57
     58# With just event name and system/event
     59echo "e:$EPROBE $SYSTEM/$EVENT $OPTIONS" >> dynamic_events
     60grep -q "$EPROBE" dynamic_events
     61test -d events/eprobes/$EPROBE
     62echo "-:$EPROBE $SYSTEM/$EVENT" >> dynamic_events
     63! grep -q "$EPROBE" dynamic_events
     64! test -d events/eprobes/$EPROBE
     65
     66# With just event name and system/event and options
     67echo "e:$EPROBE $SYSTEM/$EVENT $OPTIONS" >> dynamic_events
     68grep -q "$EPROBE" dynamic_events
     69test -d events/eprobes/$EPROBE
     70echo "-:$EPROBE $SYSTEM/$EVENT $OPTIONS" >> dynamic_events
     71! grep -q "$EPROBE" dynamic_events
     72! test -d events/eprobes/$EPROBE
     73
     74# With group name and system/event and options
     75echo "e:$EPROBE $SYSTEM/$EVENT $OPTIONS" >> dynamic_events
     76grep -q "$EPROBE" dynamic_events
     77test -d events/eprobes/$EPROBE
     78echo "-:eprobes/$EPROBE $SYSTEM/$EVENT $OPTIONS" >> dynamic_events
     79! grep -q "$EPROBE" dynamic_events
     80! test -d events/eprobes/$EPROBE
     81
     82# Finally make sure what is in the dynamic_events file clears it too
     83echo "e:$EPROBE $SYSTEM/$EVENT $OPTIONS" >> dynamic_events
     84LINE=`sed -e '/$EPROBE/s/^e/-/' < dynamic_events`
     85test -d events/eprobes/$EPROBE
     86echo "-:eprobes/$EPROBE $SYSTEM/$EVENT $OPTIONS" >> dynamic_events
     87! grep -q "$EPROBE" dynamic_events
     88! test -d events/eprobes/$EPROBE
     89
     90clear_trace