From f8e31445ce49d5fb461ede036fdb4053374a1f7f Mon Sep 17 00:00:00 2001 From: Bjoern Doebel Date: Thu, 8 Aug 2013 16:57:11 +0200 Subject: [PATCH] L4Sys: add a script to automate experiment setup Change-Id: I1f5770bbbc75a6498182e8b357756c48cc81dfa2 --- scripts/l4sys/l4sys-prepare.sh | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 scripts/l4sys/l4sys-prepare.sh diff --git a/scripts/l4sys/l4sys-prepare.sh b/scripts/l4sys/l4sys-prepare.sh new file mode 100755 index 00000000..25e2bda5 --- /dev/null +++ b/scripts/l4sys/l4sys-prepare.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# Script to automate the preparation steps for an L4Sys experiment +# +# The L4Sys experiment manual lists four steps that need to be performed +# in order to launch an L4Sys campaign. This script automates the final +# three steps. +# +# Usage: Follow the manual. Find injection addresses and CR3 value and +# adjust experimentInfo.hpp accordingly. Then run this script. +# +# TODO: Adjust $FAILDIR to your needs! + +BAK=experimentInfo.hpp.bak +CFG=experimentInfo.hpp +FAIL_CMD="fail-client -q -rc bochs-dbg.rc" +FAILDIR=/home/doebel/src/fail + +function buildfail { + echo -e "\033[33mCompiling....\033[0m" + cd $FAILDIR/build + FAIL_BUILD_PARALLEL=16 $FAILDIR/scripts/rebuild-bochs.sh - >/dev/null + cd - +} + +function BuildNRun { + buildfail + echo -e "\033[33mRunning...\033[0m" + $FAIL_CMD $@ +} + +# backup experiment config +cp $CFG $BAK + +echo -e "\033[35;1m[$(date)] ================== Step 1: Generating Snapshot =================\033[0m" +cat $BAK | sed -e 's/PREPARATION_STEP.*/PREPARATION_STEP 1/' >$CFG +BuildNRun -f bochsrc-bd + +echo -e "\033[35;1m[$(date)] ================== Step 2: Get Instruction Count ===============\033[0m" +cat $BAK | sed -e 's/PREPARATION_STEP.*/PREPARATION_STEP 2/' >$CFG +buildfail +echo -e "\033[32mRunning...\033[0m" +num_inst=`$FAIL_CMD 2>/dev/null | grep instructions\; | sed -e 's/.*after \(.*\) instructions.*/\1/'` + +echo -e "\033[35;1m[$(date)] ================== Step 3: Golden Run ==========================\033[0m" +cat $BAK | sed -e 's/PREPARATION_STEP.*/PREPARATION_STEP 3/' >$CFG +BuildNRun + +# now get ready to rumble... +echo -e "\033[35;1m[$(date)] ================== Step 4: Build Injection Client ==============\033[0m" +cat $BAK | sed -e "s/L4SYS_NUMINSTR.*/L4SYS_NUMINSTR $((num_inst*10))/" >$BAK.2 +cat $BAK.2 | sed -e "s/PREPARATION_STEP.*/PREPARATION_STEP 0/" +rm $BAK $BAK.2 +buildfail + +echo -e "\033[32;1m==========================================================================================" +echo "[$(date)] Preparations are finished. Happy injecting...." +echo -e "==========================================================================================\033[0m"