cored-tester: adapt the cored tester experiment
For redoing the bench-coptermock-isorc experiment, we have to change the timeout settings. We now use a soft timeout setting. A soft timeout is resetted after each checkpoint event. If a hard timeout (2 seconds) is reached although the soft timeout was resetted, we also abort the injection. Change-Id: Ib7c2b1ad201641f47434a11d3273dde797e0012e
This commit is contained in:
@ -102,6 +102,7 @@ unsigned CoredTester::injectBitFlip(address_t data_address, unsigned data_width,
|
|||||||
<< " offset " << (int) reginfo.offset
|
<< " offset " << (int) reginfo.offset
|
||||||
<< ") bitpos: " << bitpos
|
<< ") bitpos: " << bitpos
|
||||||
<< " value: 0x" << hex << setw(2) << setfill('0') << value << " -> 0x" << setw(2) << setfill('0') << injectedval
|
<< " value: 0x" << hex << setw(2) << setfill('0') << value << " -> 0x" << setw(2) << setfill('0') << injectedval
|
||||||
|
<< " stackptr: " << hex << simulator.getCPU(0).getStackPointer()
|
||||||
<< dec << endl;
|
<< dec << endl;
|
||||||
if (reginfo.id == RID_PC) {
|
if (reginfo.id == RID_PC) {
|
||||||
m_log << "Redecode current instruction" << endl;
|
m_log << "Redecode current instruction" << endl;
|
||||||
@ -123,7 +124,9 @@ unsigned CoredTester::injectBitFlip(address_t data_address, unsigned data_width,
|
|||||||
mm.setByte(data_address, injectedval);
|
mm.setByte(data_address, injectedval);
|
||||||
|
|
||||||
m_log << "INJECTION at: 0x" << hex << setw(2) << setfill('0') << data_address
|
m_log << "INJECTION at: 0x" << hex << setw(2) << setfill('0') << data_address
|
||||||
<< " value: 0x" << setw(2) << setfill('0') << value << " -> 0x" << setw(2) << setfill('0') << injectedval << endl;
|
<< " value: 0x" << setw(2) << setfill('0') << value << " -> 0x" << setw(2) << setfill('0') << injectedval
|
||||||
|
<< " stackptr: " << hex << simulator.getCPU(0).getStackPointer()
|
||||||
|
<< dec << endl;
|
||||||
|
|
||||||
/* If it is the current instruction redecode it */
|
/* If it is the current instruction redecode it */
|
||||||
guest_address_t pc = simulator.getCPU(0).getInstructionPointer();
|
guest_address_t pc = simulator.getCPU(0).getInstructionPointer();
|
||||||
@ -195,7 +198,11 @@ bool CoredTester::run() {
|
|||||||
const ElfSymbol &s_stext_app = getELFSymbol("_stext_application");
|
const ElfSymbol &s_stext_app = getELFSymbol("_stext_application");
|
||||||
const ElfSymbol &s_etext_app = getELFSymbol("_etext_application");
|
const ElfSymbol &s_etext_app = getELFSymbol("_etext_application");
|
||||||
|
|
||||||
const ElfSymbol &s_panic_handler = getELFSymbol("irq_handler_2");
|
const ElfSymbol &s_panic_handler = getELFSymbol("__OS_HOOK_FaultDetectedHook");
|
||||||
|
const ElfSymbol &s_panic_handler_2 = getELFSymbol("irq_handler_2");
|
||||||
|
|
||||||
|
assert(s_panic_handler.isValid() && s_panic_handler_2.isValid());
|
||||||
|
|
||||||
|
|
||||||
const ElfSymbol &s_fail_trace = getELFSymbol("fail_trace");
|
const ElfSymbol &s_fail_trace = getELFSymbol("fail_trace");
|
||||||
MemAccessListener l_fail_trace(s_fail_trace.getAddress());
|
MemAccessListener l_fail_trace(s_fail_trace.getAddress());
|
||||||
@ -216,10 +223,22 @@ bool CoredTester::run() {
|
|||||||
//TrapListener l_trap(2); // NMI trap?
|
//TrapListener l_trap(2); // NMI trap?
|
||||||
BPSingleListener l_panic(s_panic_handler.getAddress());
|
BPSingleListener l_panic(s_panic_handler.getAddress());
|
||||||
m_log << "PANIC handler @ " << std::hex << s_panic_handler.getAddress() << std::endl;
|
m_log << "PANIC handler @ " << std::hex << s_panic_handler.getAddress() << std::endl;
|
||||||
|
BPSingleListener l_panic_2(s_panic_handler_2.getAddress());
|
||||||
|
m_log << "PANIC2 handler @ " << std::hex << s_panic_handler_2.getAddress() << std::endl;
|
||||||
|
|
||||||
unsigned i_timeout = 50 * 1000;
|
unsigned upper_timeout, lower_timeout, instr_timeout;
|
||||||
TimerListener l_timeout(i_timeout); // 1s in microseconds
|
if (m_elf.getFilename().find("isorc") != std::string::npos) {
|
||||||
TimerListener l_timeout_hard(1 * 1000 * 1000); // 1s in microseconds
|
upper_timeout = 2*1000*1000;
|
||||||
|
lower_timeout = 50 * 1000;
|
||||||
|
instr_timeout = 500000;
|
||||||
|
} else {
|
||||||
|
upper_timeout = 2*1000*1000;
|
||||||
|
lower_timeout = 50 * 1000;
|
||||||
|
instr_timeout = 500000;
|
||||||
|
}
|
||||||
|
|
||||||
|
TimerListener l_timeout(lower_timeout); // 1s in microseconds
|
||||||
|
TimerListener l_timeout_hard(upper_timeout); // 1s in microseconds
|
||||||
|
|
||||||
// initialize LLVM disassembler
|
// initialize LLVM disassembler
|
||||||
m_ltof = LLVMtoFailTranslator::createFromBinary(m_elf.getFilename());
|
m_ltof = LLVMtoFailTranslator::createFromBinary(m_elf.getFilename());
|
||||||
@ -415,7 +434,18 @@ bool CoredTester::run() {
|
|||||||
// add listeners
|
// add listeners
|
||||||
simulator.clearListeners(this);
|
simulator.clearListeners(this);
|
||||||
simulator.addListener(&l_panic);
|
simulator.addListener(&l_panic);
|
||||||
|
simulator.addListener(&l_panic_2);
|
||||||
|
l_timeout.setTimeout(upper_timeout);
|
||||||
simulator.addListener(&l_timeout);
|
simulator.addListener(&l_timeout);
|
||||||
|
simulator.addListener(&l_timeout_hard);
|
||||||
|
BPSingleListener l_timeout_instr;
|
||||||
|
l_timeout_instr.setWatchInstructionPointer(ANY_ADDR);
|
||||||
|
if (instr_timeout != 0) {
|
||||||
|
// Simulate only further 500 000 instructions
|
||||||
|
l_timeout_instr.setCounter(instr_timeout);
|
||||||
|
simulator.addListener(&l_timeout_instr);
|
||||||
|
}
|
||||||
|
|
||||||
simulator.addListener(&l_fail_trace);
|
simulator.addListener(&l_fail_trace);
|
||||||
if (s_color_assert_port.isValid()) {
|
if (s_color_assert_port.isValid()) {
|
||||||
simulator.addListener(&l_color_assert_port);
|
simulator.addListener(&l_color_assert_port);
|
||||||
@ -424,65 +454,15 @@ bool CoredTester::run() {
|
|||||||
}
|
}
|
||||||
simulator.addListener(&l_trace_end_marker);
|
simulator.addListener(&l_trace_end_marker);
|
||||||
|
|
||||||
// BPSingleListener single_step;
|
|
||||||
// single_step.setWatchInstructionPointer(ANY_ADDR);
|
|
||||||
// simulator.addListener(&single_step);
|
|
||||||
// fail::BaseListener* ll = simulator.resume();
|
|
||||||
// while (ll == &single_step || ll == &l_fail_trace) {
|
|
||||||
// if (ll == &l_fail_trace) {
|
|
||||||
// Checkpoint::check_result res = cpoint.check(s_fail_trace, l_fail_trace.getTriggerInstructionPointer());
|
|
||||||
|
|
||||||
// if(res == Checkpoint::DIFFERENT_IP) {
|
|
||||||
// std::stringstream ss;
|
|
||||||
// ss << "different IP";
|
|
||||||
// ss << "@ IP 0x" << std::hex << l_fail_trace.getTriggerInstructionPointer();
|
|
||||||
// ss << " (checkpoint " << std::dec << cpoint.getCount() << ")";
|
|
||||||
// std::cout << ss.str() << endl;
|
|
||||||
// break;
|
|
||||||
// } else if(res == Checkpoint::DIFFERENT_VALUE) {
|
|
||||||
// std::stringstream ss;
|
|
||||||
// ss << "different value";
|
|
||||||
// ss << "@ IP 0x" << std::hex << l_fail_trace.getTriggerInstructionPointer();
|
|
||||||
// ss << " (checkpoint " << std::dec << cpoint.getCount() << ")";
|
|
||||||
// std::cout << ss.str() << endl;
|
|
||||||
// break;
|
|
||||||
// } else if(res == Checkpoint::DIFFERENT_DIGEST) {
|
|
||||||
// std::stringstream ss;
|
|
||||||
// ss << "different digest";
|
|
||||||
// ss << "@ IP 0x" << std::hex << l_fail_trace.getTriggerInstructionPointer();
|
|
||||||
// ss << " (checkpoint " << std::dec << cpoint.getCount() << ")";
|
|
||||||
// std::cout << ss.str() << endl;
|
|
||||||
// break;
|
|
||||||
// } else if(res == Checkpoint::INVALID) {
|
|
||||||
// std::stringstream ss;
|
|
||||||
// ss << "invalid checkpoint";
|
|
||||||
// ss << "@ IP 0x" << std::hex << l_fail_trace.getTriggerInstructionPointer();
|
|
||||||
// ss << " (checkpoint " << std::dec << cpoint.getCount() << ")";
|
|
||||||
// std::cout << ss.str() << endl;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// std::stringstream ss;
|
|
||||||
// ss << "@ IP " << std::hex << simulator.getCPU(0).getInstructionPointer();
|
|
||||||
// const ElfSymbol &sym = m_elf.getSymbol(simulator.getCPU(0).getInstructionPointer());
|
|
||||||
// ss << " " << sym.getName();
|
|
||||||
// std::cout << ss.str() << endl;
|
|
||||||
// ll = simulator.addListenerAndResume(ll);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// std::cout << (ll == &l_color_assert_port) << " COLOR ASSERT" << endl;
|
|
||||||
|
|
||||||
// //continue;
|
|
||||||
// simulator.terminate(0);
|
|
||||||
|
|
||||||
// resume and wait for results
|
// resume and wait for results
|
||||||
m_log << "Resuming till the crash (time: " << simulator.getTimerTicks() << ")"<< std::endl;
|
m_log << "Resuming till the crash (time: " << simulator.getTimerTicks() << ")"<< std::endl;
|
||||||
bool reached_check_start = false;
|
bool reached_check_start = false;
|
||||||
fail::BaseListener* l = simulator.resume();
|
fail::BaseListener* l = simulator.resume();
|
||||||
|
|
||||||
|
int checkpoints = 0;
|
||||||
while(l == &l_fail_trace) {
|
while(l == &l_fail_trace) {
|
||||||
Checkpoint::check_result res = cpoint.check(s_fail_trace, l_fail_trace.getTriggerInstructionPointer());
|
Checkpoint::check_result res = cpoint.check(s_fail_trace, l_fail_trace.getTriggerInstructionPointer());
|
||||||
|
checkpoints ++;
|
||||||
if(res == Checkpoint::DIFFERENT_IP) {
|
if(res == Checkpoint::DIFFERENT_IP) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "different IP";
|
ss << "different IP";
|
||||||
@ -515,6 +495,11 @@ bool CoredTester::run() {
|
|||||||
|
|
||||||
// Reset the soft timeout listener
|
// Reset the soft timeout listener
|
||||||
simulator.removeListener(&l_timeout);
|
simulator.removeListener(&l_timeout);
|
||||||
|
unsigned i_timeout = upper_timeout;
|
||||||
|
if (checkpoints > 5) {
|
||||||
|
i_timeout = lower_timeout;
|
||||||
|
}
|
||||||
|
l_timeout.setTimeout(i_timeout);
|
||||||
simulator.addListener(&l_timeout);
|
simulator.addListener(&l_timeout);
|
||||||
assert(l_timeout.getTimeout() == i_timeout);
|
assert(l_timeout.getTimeout() == i_timeout);
|
||||||
|
|
||||||
@ -532,7 +517,7 @@ bool CoredTester::run() {
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "correct end after " << cpoint.getCount() << " checkpoints";
|
ss << "correct end after " << cpoint.getCount() << " checkpoints";
|
||||||
handleEvent(*result, result->OK, ss.str());
|
handleEvent(*result, result->OK, ss.str());
|
||||||
} else if (l == &l_panic) {
|
} else if (l == &l_panic || l == &l_panic_2) {
|
||||||
// error detected
|
// error detected
|
||||||
stringstream sstr;
|
stringstream sstr;
|
||||||
sstr << "PANIC";
|
sstr << "PANIC";
|
||||||
@ -563,7 +548,7 @@ bool CoredTester::run() {
|
|||||||
uint32_t color = 0;
|
uint32_t color = 0;
|
||||||
mm.getBytes(s_color_assert_port.getAddress(), 4, &color);
|
mm.getBytes(s_color_assert_port.getAddress(), 4, &color);
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "@ IP" << std::hex << simulator.getCPU(0).getInstructionPointer();
|
ss << "color assert @ IP" << std::hex << simulator.getCPU(0).getInstructionPointer();
|
||||||
|
|
||||||
if (color == 0xb83829de) {
|
if (color == 0xb83829de) {
|
||||||
handleEvent(*result, result->ERR_ASSERT_UNKOWN, ss.str());
|
handleEvent(*result, result->ERR_ASSERT_UNKOWN, ss.str());
|
||||||
@ -574,9 +559,14 @@ bool CoredTester::run() {
|
|||||||
} else {
|
} else {
|
||||||
handleEvent(*result, result->ERR_ASSERT_SPURIOUS, ss.str());
|
handleEvent(*result, result->ERR_ASSERT_SPURIOUS, ss.str());
|
||||||
}
|
}
|
||||||
} else if ( l == &l_timeout || l == &l_timeout_hard) {
|
} else if ( l == &l_timeout || l == &l_timeout_hard || l == &l_timeout_instr) {
|
||||||
// timeout, probably infinite loop
|
if (l == &l_timeout) {
|
||||||
handleEvent(*result, result->ERR_TIMEOUT, "");
|
handleEvent(*result, result->ERR_TIMEOUT, "soft timeout");
|
||||||
|
} else if (l == &l_timeout_hard) {
|
||||||
|
handleEvent(*result, result->ERR_TIMEOUT, "hard timeout");
|
||||||
|
} else if (l == &l_timeout_instr) {
|
||||||
|
handleEvent(*result, result->ERR_TIMEOUT, "instr timeout");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// what happened?
|
// what happened?
|
||||||
handleEvent(*result, result->UNKNOWN, "WTF");
|
handleEvent(*result, result->UNKNOWN, "WTF");
|
||||||
|
|||||||
Reference in New Issue
Block a user