lra-simple-panda: converted experiment to campaign
As we need hop chains to efficiently navigate to the injection point on pandaboard, this campaign uses these. As we do not yet have a component, which automatically navigates to a generic InjectionPoint (API needs to be properly designed), we do this explicitly. Change-Id: I26ca6ebb3f05cde735f9641551a8ce5478e463f6
This commit is contained in:
@ -4,14 +4,33 @@ configure_file(../instantiate-experiment.ah.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/instantiate-${EXPERIMENT_NAME}.ah @ONLY
|
||||
)
|
||||
|
||||
#experiment sources
|
||||
set(MY_EXPERIMENT_SRCS
|
||||
experiment.hpp
|
||||
experiment.cc
|
||||
## Setup desired protobuf descriptions HERE ##
|
||||
set(MY_PROTOS
|
||||
lra_simple.proto
|
||||
)
|
||||
|
||||
#### include directories ####
|
||||
set(MY_CAMPAIGN_SRCS
|
||||
experiment.hpp
|
||||
experiment.cc
|
||||
campaign.hpp
|
||||
campaign.cc
|
||||
)
|
||||
|
||||
#### PROTOBUFS ####
|
||||
find_package(Protobuf REQUIRED)
|
||||
include_directories(${PROTOBUF_INCLUDE_DIRS})
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
## build library
|
||||
add_library(fail-${EXPERIMENT_NAME} ${MY_EXPERIMENT_SRCS})
|
||||
set(PROTOBUF_IMPORT_DIRS ${PROTOBUF_IMPORT_DIRS} ${CMAKE_CURRENT_BINARY_DIR}/../../core/comm)
|
||||
|
||||
PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ${MY_PROTOS})
|
||||
|
||||
## Build library
|
||||
add_library(fail-${EXPERIMENT_NAME} ${PROTO_SRCS} ${PROTO_HDRS} ${MY_CAMPAIGN_SRCS})
|
||||
add_dependencies(fail-${EXPERIMENT_NAME} fail-comm)
|
||||
target_link_libraries(fail-${EXPERIMENT_NAME} ${PROTOBUF_LIBRARY})
|
||||
|
||||
## This is the example's campaign server distributing experiment parameters
|
||||
add_executable(${EXPERIMENT_NAME}-server main.cc)
|
||||
target_link_libraries(${EXPERIMENT_NAME}-server -Wl,--start-group fail-${EXPERIMENT_NAME} fail-sal fail-util fail-cpn fail-smarthopping fail-comm ${PROTOBUF_LIBRARY} ${Boost_THREAD_LIBRARY} -lmysqlclient -Wl,--end-group)
|
||||
install(TARGETS ${EXPERIMENT_NAME}-server RUNTIME DESTINATION bin)
|
||||
|
||||
19
src/experiments/lra-simple-panda/campaign.cc
Normal file
19
src/experiments/lra-simple-panda/campaign.cc
Normal file
@ -0,0 +1,19 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include "campaign.hpp"
|
||||
#include "cpn/CampaignManager.hpp"
|
||||
#include "util/ElfReader.hpp"
|
||||
#include "util/ProtoStream.hpp"
|
||||
#include "sal/SALConfig.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace fail;
|
||||
using namespace google::protobuf;
|
||||
|
||||
void LraSimpleCampaign::cb_send_pilot(DatabaseCampaignMessage pilot) {
|
||||
LraSimpleExperimentData *data = new LraSimpleExperimentData;
|
||||
data->msg.mutable_fsppilot()->CopyFrom(pilot);
|
||||
campaignmanager.addParam(data);
|
||||
}
|
||||
|
||||
23
src/experiments/lra-simple-panda/campaign.hpp
Normal file
23
src/experiments/lra-simple-panda/campaign.hpp
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef __DCIAOCAMPAIGN_HPP__
|
||||
#define __DCIAOCAMPAIGN_HPP__
|
||||
|
||||
#include "cpn/DatabaseCampaign.hpp"
|
||||
#include "comm/ExperimentData.hpp"
|
||||
#include "lra_simple.pb.h"
|
||||
#include "util/ElfReader.hpp"
|
||||
#include <google/protobuf/descriptor.h>
|
||||
|
||||
class LraSimpleExperimentData : public fail::ExperimentData {
|
||||
public:
|
||||
LraSimpleProtoMsg msg;
|
||||
LraSimpleExperimentData() : fail::ExperimentData(&msg) {}
|
||||
};
|
||||
|
||||
class LraSimpleCampaign : public fail::DatabaseCampaign {
|
||||
virtual const google::protobuf::Descriptor * cb_result_message()
|
||||
{ return google::protobuf::DescriptorPool::generated_pool()->FindMessageTypeByName("LraSimpleProtoMsg"); }
|
||||
|
||||
virtual void cb_send_pilot(DatabaseCampaignMessage pilot);
|
||||
};
|
||||
|
||||
#endif // __KESOREFCAMPAIGN_HPP__
|
||||
@ -1,6 +1,6 @@
|
||||
#include "experiment.hpp"
|
||||
|
||||
#include "experimentInfo.hpp"
|
||||
#include "util/Logger.hpp"
|
||||
#include "sal/SALConfig.hpp"
|
||||
#include "sal/SALInst.hpp"
|
||||
#include "sal/Listener.hpp"
|
||||
@ -9,6 +9,20 @@
|
||||
#include "config/FailConfig.hpp"
|
||||
#include "util/WallclockTimer.hpp"
|
||||
|
||||
#include "util/gzstream/gzstream.h"
|
||||
|
||||
#include "efw/JobClient.hpp"
|
||||
|
||||
#include "lra_simple.pb.h"
|
||||
#include "campaign.hpp"
|
||||
|
||||
#include "cpn/InjectionPoint.hpp"
|
||||
#include "config/FailConfig.hpp"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
// you need to have the tracing plugin enabled for this
|
||||
#include "../plugins/tracing/TracingPlugin.hpp"
|
||||
|
||||
@ -16,29 +30,89 @@ using namespace std;
|
||||
using namespace fail;
|
||||
|
||||
// Check if configuration dependencies are satisfied:
|
||||
#if !defined(CONFIG_EVENT_BREAKPOINTS) || !defined(CONFIG_EVENT_MEMREAD) || !defined(CONFIG_EVENT_MEMWRITE)
|
||||
#error This experiment needs: breakpoints and watchpoints. Enable them in the configuration.
|
||||
#if !defined(CONFIG_EVENT_BREAKPOINTS) || !defined(CONFIG_EVENT_MEMREAD) || !defined(CONFIG_EVENT_MEMWRITE) || !defined(CONFIG_EVENT_TRAP)
|
||||
#error This experiment needs: breakpoints, watchpoints and traps. Enable them in the configuration.
|
||||
#endif
|
||||
|
||||
#define PREPARATION 1
|
||||
#define PREPARATION 0
|
||||
|
||||
|
||||
// ToDo: Move this functionality to SimulatorController
|
||||
void LRASimplePandaExperiment::navigateToInjectionPoint(ConcreteInjectionPoint &ip) {
|
||||
Logger log_nav("navigator");
|
||||
|
||||
#ifdef CONFIG_INJECTIONPOINT_HOPS
|
||||
// Hop nav
|
||||
InjectionPointMessage ipm;
|
||||
ip.copyInjectionPointMessage(ipm);
|
||||
if (ipm.has_checkpoint_id()) {
|
||||
// ToDo: Load CP state!
|
||||
|
||||
log_nav << "FATAL ERROR: CPs not yet implemented!" << endl;
|
||||
simulator.terminate(1);
|
||||
}
|
||||
|
||||
|
||||
log_nav << "Navigating to next instruction at navigational costs of " << ipm.costs() << endl;
|
||||
log_nav << "Length of hop-chain: " << ipm.hops_size() << endl;
|
||||
|
||||
for (int i = 0; i < ipm.hops_size(); i++) {
|
||||
InjectionPointMessage_Hops h = ipm.hops(i);
|
||||
BaseListener *hop, *ev;
|
||||
|
||||
if (h.accesstype() == h.EXECUTE) {
|
||||
log_nav << "BP at " << hex << h.address() << dec << endl;
|
||||
BPSingleListener bp (h.address());
|
||||
hop = &bp;
|
||||
ev = simulator.addListenerAndResume(&bp);
|
||||
} else {
|
||||
log_nav << "WP at " << hex << h.address() << dec << "Access: " <<
|
||||
(h.accesstype() == h.READ ? "R" :"W")<< endl;
|
||||
MemAccessListener ma (h.address(), h.accesstype() == h.READ ?
|
||||
MemAccessEvent::MEM_READ : MemAccessEvent::MEM_WRITE);
|
||||
hop = &ma;
|
||||
ev = simulator.addListenerAndResume(&ma);
|
||||
}
|
||||
|
||||
log_nav << "Halted" << endl;
|
||||
|
||||
if (ev != hop) {
|
||||
log_nav << "FATAL ERROR: Unexpected event while navigating!" << endl;
|
||||
simulator.terminate(1);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Step nav
|
||||
InjectionPointMessage ipm;
|
||||
ip.copyInjectionPointMessage(ipm);
|
||||
log_nav << ipm.injection_instr() << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool LRASimplePandaExperiment::run()
|
||||
{
|
||||
Logger log("lra-simple-panda", false);
|
||||
Logger _log("lra-simpla-panda", false);
|
||||
_log << "Startup" << endl;
|
||||
|
||||
fail::ElfReader elfReader;
|
||||
fail::JobClient jobClient;
|
||||
|
||||
|
||||
#if PREPARATION == 1
|
||||
_log << "Preparation mode" << endl;
|
||||
// STEP 1: run until main starts, save state, record trace
|
||||
// TODO: store golden run output
|
||||
BPSingleListener func_begin(LRASP_ADDR_FUNC_BEGIN);
|
||||
BPSingleListener func_begin(elfReader.getSymbol("test_code_due").getAddress());
|
||||
simulator.addListenerAndResume(&func_begin);
|
||||
|
||||
log << "test_func() reached, beginning trace recording" << endl;
|
||||
_log << "test_func() reached, beginning trace recording" << endl;
|
||||
|
||||
TracingPlugin tp;
|
||||
tp.setLogIPOnly(true);
|
||||
|
||||
// ogzstream of(LRASP_TRACE);
|
||||
ofstream of(LRASP_TRACE);
|
||||
if (!of.is_open()) {
|
||||
log << "FATAL ERROR: Trace file could not be opened." << endl;
|
||||
if (of.bad()) {
|
||||
_log << "FATAL ERROR: Trace file could not be opened." << endl;
|
||||
simulator.terminate();
|
||||
return false;
|
||||
}
|
||||
@ -48,10 +122,11 @@ bool LRASimplePandaExperiment::run()
|
||||
// this must be done *after* configuring the plugin:
|
||||
simulator.addFlow(&tp);
|
||||
|
||||
// count instructions
|
||||
BPSingleListener func_end(LRASP_ADDR_FUNC_END);
|
||||
BPSingleListener func_end(elfReader.getSymbol("test_code_due").getAddress() + elfReader.getSymbol("test_code_due").getSize() - 4);
|
||||
simulator.addListener(&func_end);
|
||||
BPSingleListener step(ANY_ADDR);
|
||||
|
||||
// count instructions
|
||||
long counter = 0;
|
||||
while (true) {
|
||||
BaseListener *l = simulator.addListenerAndResume(&step);
|
||||
@ -59,85 +134,78 @@ bool LRASimplePandaExperiment::run()
|
||||
break;
|
||||
}
|
||||
counter++;
|
||||
if ((counter % 1000) == 0) {
|
||||
_log << "Traced " << counter << " insturctions" << endl;
|
||||
of.flush();
|
||||
}
|
||||
}
|
||||
log << "golden run took " << dec << counter << " instructions" << endl;
|
||||
_log << "golden run took " << dec << counter << " instructions" << endl;
|
||||
simulator.removeFlow(&tp);
|
||||
|
||||
// serialize trace to file
|
||||
if (of.fail()) {
|
||||
_log << "failed to write to trace file"<< std::endl;
|
||||
return false;
|
||||
}
|
||||
of.close();
|
||||
#else
|
||||
|
||||
log << "Startup!" << endl;
|
||||
unsigned executed_jobs = 0;
|
||||
|
||||
_log << "Startup!" << endl;
|
||||
|
||||
// std::ofstream exp_output ("exp.txt");
|
||||
|
||||
ConcreteCPU cpu = simulator.getCPU(0);
|
||||
for (ConcreteCPU::iterator it = cpu.begin(); it != cpu.end(); it++) {
|
||||
Register* pReg = *it; // get a ptr to the current register-object
|
||||
for (regwidth_t bitnr = 0; bitnr < pReg->getWidth(); ++bitnr) {
|
||||
int inst_offs;
|
||||
for (inst_offs = 0; inst_offs < 60; ++inst_offs) {
|
||||
WallclockTimer timer;
|
||||
timer.startTimer();
|
||||
|
||||
unsigned int inj_inst = 0x830004a0 + inst_offs*4;
|
||||
|
||||
static int experiment_counter = 1;
|
||||
log << "======================" << endl;
|
||||
log << "= Experiment " << setfill('0') << setw(7) << experiment_counter++ << " =" << endl;
|
||||
log << "======================" << endl;
|
||||
|
||||
/*
|
||||
* Trace navigation
|
||||
*/
|
||||
{
|
||||
log << "NavBP " << hex << inj_inst << dec << endl;
|
||||
BPSingleListener* bp_x;
|
||||
BPSingleListener bp(inj_inst);
|
||||
bp_x = (BPSingleListener*)simulator.addListenerAndResume(&bp);
|
||||
log << "Haltet at instruction " << hex << bp_x->getTriggerInstructionPointer() << endl;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fault injection in register file
|
||||
*/
|
||||
log << "Injecting bit flip to register " << pReg->getName() << " at bit position " << dec << bitnr
|
||||
<<" at instruction " << hex << inj_inst << dec << endl;
|
||||
regdata_t data = cpu.getRegisterContent(pReg);
|
||||
data ^= 1 << bitnr;
|
||||
cpu.setRegisterContent(pReg, data); // write back data to register
|
||||
|
||||
/*
|
||||
* Aftermath: Check for traps, timeout or normal termination
|
||||
*/
|
||||
BPSingleListener ev_trap(0x80e80010);
|
||||
simulator.addListener(&ev_trap);
|
||||
|
||||
TimerListener ev_timeout(LRASP_TIMEOUT); // 1000 millisecond timeout
|
||||
simulator.addListener(&ev_timeout);
|
||||
|
||||
BPSingleListener ev_func_end(0x83000590);
|
||||
simulator.addListener(&ev_func_end);
|
||||
|
||||
log << "waiting for function exit, trap or timeout(1 second)" << endl;
|
||||
BaseListener* ev = simulator.resume();
|
||||
|
||||
if (ev == &ev_timeout) {
|
||||
log << "Timeout!" << endl;
|
||||
} else if (ev == &ev_trap) {
|
||||
log << "Trap!" << endl;
|
||||
} else if (ev == &ev_func_end) {
|
||||
log << "Function terminated!" << endl;
|
||||
|
||||
uint32_t results[LRASP_RESULTS_BYTES/sizeof(uint32_t)];
|
||||
simulator.getMemoryManager().getBytes(LRASP_RESULT_ADDRESS, LRASP_RESULTS_BYTES, (unsigned char*)results);
|
||||
|
||||
for (unsigned i = 0; i < sizeof(results) / sizeof(*results); ++i) {
|
||||
log << "results[" << i << "]: " << dec << results[i] << endl;
|
||||
}
|
||||
}
|
||||
|
||||
simulator.reboot();
|
||||
log << "Experiment time: " << timer << endl;
|
||||
}
|
||||
ConcreteCPU::iterator it = cpu.begin();
|
||||
it++; it++;
|
||||
while (jobClient.getNumberOfUndoneJobs() > 0 || executed_jobs < 500) {
|
||||
_log << "asking jobserver for parameters" << endl;
|
||||
LraSimpleExperimentData param;
|
||||
if(!jobClient.getParam(param)){
|
||||
_log << "Dying." << endl; // We were told to die.
|
||||
simulator.terminate(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Get input data from Jobserver
|
||||
unsigned injection_instr = param.msg.fsppilot().injection_instr();
|
||||
address_t data_address = param.msg.fsppilot().data_address();
|
||||
unsigned data_width = param.msg.fsppilot().data_width();
|
||||
ConcreteInjectionPoint ip;
|
||||
ip.parseFromCampaignMessage(param.msg.fsppilot());
|
||||
|
||||
// ToDo: Insert into all 8 Bits
|
||||
for (int experiment_id = 0; experiment_id < 1; ++experiment_id) {
|
||||
LraSimpleProtoMsg_Result *result = 0;
|
||||
|
||||
_log << "rebooting device" << endl;
|
||||
|
||||
// Restore to the image, which starts at address(main)
|
||||
simulator.reboot();
|
||||
executed_jobs ++;
|
||||
|
||||
// Fast forward to injection address
|
||||
_log << "Trying to inject @ instr #" << dec << injection_instr << endl;
|
||||
|
||||
navigateToInjectionPoint(ip);
|
||||
|
||||
uint32_t iteration_counter;
|
||||
simulator.getMemoryManager().getBytes(elfReader.getSymbol("test_code_idx").getAddress(), 4, (void*)(&iteration_counter));
|
||||
|
||||
result = param.msg.add_result();
|
||||
|
||||
result->set_bitoffset(experiment_id);
|
||||
result->set_loop_iteration(iteration_counter);
|
||||
result->set_resulttype(result->OK);
|
||||
result->set_experiment_number(executed_jobs);
|
||||
|
||||
simulator.clearListeners();
|
||||
}
|
||||
|
||||
jobClient.sendResult(param);
|
||||
}
|
||||
|
||||
_log << "jobClient.getNumberOfUndoneJobs() = " << jobClient.getNumberOfUndoneJobs() << "executed_jobs = " << executed_jobs << endl;
|
||||
|
||||
#endif // PREPARATION
|
||||
|
||||
|
||||
@ -2,12 +2,16 @@
|
||||
#define __LRA_SIMPLE_PANDA_EXPERIMENT_HPP__
|
||||
|
||||
#include "efw/ExperimentFlow.hpp"
|
||||
#include "efw/JobClient.hpp"
|
||||
#include "cpn/InjectionPoint.hpp"
|
||||
|
||||
class LRASimplePandaExperiment : public fail::ExperimentFlow {
|
||||
using namespace fail;
|
||||
|
||||
class LRASimplePandaExperiment : public ExperimentFlow {
|
||||
public:
|
||||
LRASimplePandaExperiment() { }
|
||||
LRASimplePandaExperiment() : ExperimentFlow() {}
|
||||
bool run();
|
||||
void navigateToInjectionPoint(ConcreteInjectionPoint &ip);
|
||||
// void navigateToInjectionPoint(ConcreteInjectionPoint &ip, std::ostream &log);
|
||||
};
|
||||
|
||||
#endif // __LRA_SIMPLE_PANDA_EXPERIMENT_HPP__
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
#define LRASP_BIN_OFFSET 0x100000
|
||||
#define LRASP_RESULTS "LRASP.csv"
|
||||
#define LRASP_TIMEOUT 1000000 // 1s
|
||||
#define LRASP_ADDR_FUNC_BEGIN 0x830004a0
|
||||
#define LRASP_ADDR_FUNC_END 0x83000590
|
||||
#define LRASP_RESULT_ADDRESS 0x83010004
|
||||
#define LRASP_ADDR_FUNC_BEGIN 0x83000978
|
||||
#define LRASP_ADDR_FUNC_END 0x83000a68
|
||||
#define LRASP_RESULT_ADDRESS 0x83016804
|
||||
#define LRASP_RESULTS_BYTES 4
|
||||
|
||||
#endif
|
||||
|
||||
25
src/experiments/lra-simple-panda/lra_simple.proto
Normal file
25
src/experiments/lra-simple-panda/lra_simple.proto
Normal file
@ -0,0 +1,25 @@
|
||||
import "DatabaseCampaignMessage.proto";
|
||||
|
||||
message LraSimpleProtoMsg {
|
||||
required DatabaseCampaignMessage fsppilot = 1;
|
||||
|
||||
repeated group Result = 2 {
|
||||
enum ResultType {
|
||||
OK = 1;
|
||||
|
||||
ERR_WRONG_RESULT = 4;
|
||||
|
||||
ERR_TRAP = 5;
|
||||
ERR_TIMEOUT = 6;
|
||||
|
||||
ERR_OUTSIDE_TEXT = 7;
|
||||
|
||||
ERR_OUTSIDE_DATA = 8;
|
||||
}
|
||||
|
||||
required int32 bitoffset = 1 [(sql_primary_key) = true];
|
||||
required ResultType resulttype = 2;
|
||||
required uint32 experiment_number = 3;
|
||||
required uint32 loop_iteration = 4;
|
||||
}
|
||||
}
|
||||
20
src/experiments/lra-simple-panda/main.cc
Normal file
20
src/experiments/lra-simple-panda/main.cc
Normal file
@ -0,0 +1,20 @@
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "cpn/CampaignManager.hpp"
|
||||
#include "util/CommandLine.hpp"
|
||||
#include "campaign.hpp"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
fail::CommandLine &cmd = fail::CommandLine::Inst();
|
||||
for (int i = 1; i < argc; ++i)
|
||||
cmd.add_args(argv[i]);
|
||||
|
||||
LraSimpleCampaign c;
|
||||
if (fail::campaignmanager.runCampaign(&c)) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user