Moved deprecated files/folders to temp-folder, FI-stuff removed, cleaned up aspect (file-)names and code (-> coding-style).

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1320 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
adrian
2012-06-07 18:57:26 +00:00
parent b7d904140e
commit d474a5b952
119 changed files with 110 additions and 55385 deletions

View File

@ -10,7 +10,7 @@ else()
Memory.cc
Register.cc
SimulatorController.cc
${VARIANT}/Controller.cc
${VARIANT}/OVPController.cc
)
endif(BUILD_BOCHS)

View File

@ -9,7 +9,7 @@
#include <iomanip>
#include <string.h>
#include "failbochs.hpp"
#include "FailBochsGlobals.hpp"
#include "../SimulatorController.hpp"
#include "../../controller/Event.hpp"

View File

@ -1,16 +1,16 @@
#ifndef __NONVERBOSE_AH__
#define __NONVERBOSE_AH__
#ifndef __BOCHS_NON_VERBOSE_AH__
#define __BOCHS_NON_VERBOSE_AH__
#include "config/FailConfig.hpp"
#ifdef CONFIG_STFU
#ifdef CONFIG_BOCHS_NON_VERBOSE
#include "bochs.h"
// Doesn't work because AspectC++ doesn't deal properly with variadic parameter
// lists:
/*
aspect nonverbose {
aspect BochsNonVerbose {
// needed to suppress Bochs output *before* a state restore finished
// FIXME ac++ segfaults if we use call() instead of execution()
advice execution("% logfunctions::debug(...)")
@ -22,10 +22,11 @@ aspect nonverbose {
};
*/
aspect nonverbose {
aspect BochsNonVerbose {
// needed to suppress Bochs output *before* a state restore finished
advice call("int logfunctions::get_default_action(int)")
: around () {
: around ()
{
int action;
switch (*(tjp->arg<0>())) {
case LOGLEV_DEBUG:
@ -43,12 +44,11 @@ aspect nonverbose {
*(tjp->result()) = action;
}
// no credits header
// No credits header
advice call("void bx_print_header()")
: around () {
}
: around () { }
};
#endif // CONFIG_STFU
#endif // CONFIG_BOCHS_NON_VERBOSE
#endif // __NONVERBOSE_AH__
#endif // __BOCHS_NON_VERBOSE_AH__

View File

@ -13,10 +13,7 @@ aspect Breakpoints
{
pointcut cpuLoop() = "void defineCPULoopJoinPoint(...)";
//
// Event source: "instruction pointer"
//
advice execution (cpuLoop()) : after ()
advice execution (cpuLoop()) : after () // Event source: "instruction pointer"
{
// Points to the cpu class: "this" if BX_USE_CPU_SMF == 0,
// BX_CPU(0) otherwise

View File

@ -4,9 +4,9 @@
#include <string.h>
#include <stdio.h>
aspect credits {
aspect Credits {
bool first;
credits() : first(true) {}
Credits() : first(true) {}
advice call ("% bx_center_print(...)")
&& within ("void bx_print_header()")

View File

@ -8,16 +8,16 @@
#include "../../../bochs/iodev/iodev.h"
#include "../../../bochs/iodev/keyboard.h"
aspect DisableKeybInt {
aspect DisableKeyboardInterrupt {
pointcut heyboard_interrupt() =
"void bx_keyb_c::timer_handler(...)";
advice execution (heyboard_interrupt()) : around () {
bx_keyb_c *class_ptr = (bx_keyb_c *) tjp->arg<0>();
advice execution (heyboard_interrupt()) : around ()
{
bx_keyb_c *class_ptr = (bx_keyb_c *)tjp->arg<0>();
unsigned retval;
retval=class_ptr->periodic(1);
retval = class_ptr->periodic(1);
}
};

View File

@ -9,11 +9,11 @@
* decided to simply ignore this tiny memory leak and to hack around the
* problem by disabling iofunctions::add/remove_logfn().
*/
aspect DisableLogfn {
aspect DisableLogFunctions {
pointcut add_remove_logfn() =
"void iofunctions::add_logfn(...)" ||
"void iofunctions::remove_logfn(...)";
advice execution (add_remove_logfn()) : around () {}
advice execution (add_remove_logfn()) : around () { }
};
#endif // __DISABLE_ADD_REMOVE_LOGFN_AH__

View File

@ -1,11 +1,9 @@
#ifndef __FAILBOCHS_HPP__
#define __FAILBOCHS_HPP__
#ifndef __FAIL_BOCHS_GLOBALS_HPP__
#define __FAIL_BOCHS_GLOBALS_HPP__
#include <string>
#include "config.h"
// FIXME: Maybe rename this file to "FailBochsGlobals.hpp"?
#include "config.h"
namespace fail {
@ -21,4 +19,4 @@ extern int interrupt_to_fire;
}
#endif // __FAILBOCHS_HPP__
#endif // __FAIL_BOCHS_GLOBALS_HPP__

View File

@ -0,0 +1,13 @@
#ifndef __FAIL_BOCHS_INIT_AH__
#define __FAIL_BOCHS_INIT_AH__
#include "../SALInst.hpp"
aspect FailBochsInit {
advice call("int bxmain()") : before ()
{
fail::simulator.startup();
}
};
#endif // __FAIL_BOCHS_INIT_AH__

View File

@ -10,32 +10,29 @@
#include "../../../bochs/iodev/iodev.h"
#include "../SALInst.hpp"
aspect fireInterrupt
{
aspect FireInterrupt {
pointcut cpuLoop() = "void defineCPULoopJoinPoint(...)";
advice execution (cpuLoop()) : before ()
{
if (!fail::interrupt_injection_request) {
return;
}else{
} else {
BX_SET_INTR(fail::interrupt_to_fire);
DEV_pic_raise_irq(fail::interrupt_to_fire);
}
}
};
aspect InterruptDone
{
aspect InterruptDone {
pointcut interrupt_method() = "void bx_cpu_c::interrupt(...)";
advice execution (interrupt_method()) : before ()
{
if (!fail::interrupt_injection_request) {
return;
}else{
if(*(tjp->arg<0>()) == 32 + fail::interrupt_to_fire){
} else {
if (*(tjp->arg<0>()) == 32 + fail::interrupt_to_fire) {
DEV_pic_lower_irq(fail::interrupt_to_fire);
fail::simulator.fireInterruptDone();
}

View File

@ -1,5 +1,5 @@
#ifndef __GUESTSYS_COM_AH__
#define __GUESTSYS_COM_AH__
#ifndef __GUEST_SYS_COM_AH__
#define __GUEST_SYS_COM_AH__
#include "config/FailConfig.hpp"
@ -9,21 +9,17 @@
#include "../../../bochs/cpu/cpu.h"
#include "../SALInst.hpp"
#include "bochs_helpers.hpp"
#include "BochsHelpers.hpp"
// Fixed "port number" for "Guest system >> Bochs" communication
#define BOCHS_COM_PORT 0x378
// FIXME: This #define should be located in a config or passed within the event object...
aspect GuestSysCom
{
aspect GuestSysCom {
pointcut outInstructions() = "% ...::bx_cpu_c::OUT_DX%(...)";
advice execution (outInstructions()) : after ()
advice execution (outInstructions()) : after () // Event source: "guest system"
{
//
// Event source: "guest system"
//
unsigned rDX = getCPU(tjp->that())->gen_reg[2].word.rx; // port number
unsigned rAL = getCPU(tjp->that())->gen_reg[0].word.byte.rl; // data
if (rDX == BOCHS_COM_PORT) {
@ -34,4 +30,4 @@ aspect GuestSysCom
#endif // CONFIG_EVENT_GUESTSYS
#endif // __GUESTSYS_COM_AH__
#endif // __GUEST_SYS_COM_AH__

View File

@ -9,11 +9,11 @@
#include "../../../bochs/cpu/cpu.h"
#include "../SALInst.hpp"
#include "bochs_helpers.hpp"
#include "BochsHelpers.hpp"
aspect IOPortCom
{
// ATM only capturing bytewise output (most common, I suppose)
// TODO: ATM only capturing bytewise output (most common, I suppose)
aspect IOPortCom {
pointcut outInstruction() = "% ...::bx_cpu_c::OUT_DXAL(...)";
advice execution (outInstruction()) : after ()

View File

@ -9,8 +9,7 @@
#include "../../../bochs/cpu/cpu.h"
#include "../SALInst.hpp"
aspect Interrupt
{
aspect Interrupt {
// cpu/exception.cc
pointcut interrupt_method() = "void bx_cpu_c::interrupt(...)";
@ -28,9 +27,9 @@ aspect Interrupt
unsigned vector = *(tjp->arg<0>());
unsigned type = *(tjp->arg<1>());
if(type == BX_EXTERNAL_INTERRUPT)
if (type == BX_EXTERNAL_INTERRUPT)
fail::simulator.onInterruptEvent(vector, false);
else if(type == BX_NMI)
else if (type == BX_NMI)
fail::simulator.onInterruptEvent(vector, true);
}
};

View File

@ -9,14 +9,13 @@
#include "../../../bochs/cpu/cpu.h"
#include "../SALInst.hpp"
aspect Interrupt_FI
{
aspect InterruptSuppression {
pointcut interrupt_method() = "void bx_cpu_c::interrupt(...)";
advice execution (interrupt_method()) : around ()
{
unsigned vector = *(tjp->arg<0>());
if(!fail::simulator.isSuppressedInterrupt(vector)){
if (!fail::simulator.isSuppressedInterrupt(vector)) {
tjp->proceed();
}
}

View File

@ -13,10 +13,9 @@
#include "../../../bochs/bochs.h"
#include "../SALInst.hpp"
// FIXME: This seems (partial) deprecated as well...
// FIXME: This seems (partial) deprecated/incomplete as well...
aspect Jump
{
aspect Jump {
// Note: Have a look at the Bochs-Code (cpu/cpu.h) and the Intel
// Architecture Software Developer's Manual - Instruction Set Reference
// p. 3-329 (PDF p. 369) for further information:

View File

@ -1,35 +0,0 @@
#ifndef __JUMP_TO_PREVIOUS_CTX_AH__
#define __JUMP_TO_PREVIOUS_CTX_AH__
#include "config/FailConfig.hpp"
// FIXME: What's the purpose of this file/code? Deprecated?
#if 0
// #if defined(CONFIG_SR_RESTORE) || defined(CONFIG_SR_REBOOT)
#include "bochs.h"
#include "../SALInst.hpp"
aspect jumpToPreviousCtx
{
pointcut end_reset_handler() = "void bx_gui_c::reset_handler(...)";
//|| "int bxmain()";
advice execution (end_reset_handler()) : after ()
{
if (fail::restore_bochs_request || fail::reboot_bochs_request )
{
fail::restore_bochs_request = false;
fail::reboot_bochs_request = false;
fail::simulator.toPreviousCtx();
}
}
};
#endif // CONFIG_SR_RESTORE || CONFIG_SR_REBOOT
#endif // __JUMP_TO_PREVIOUS_CTX_AH__

View File

@ -1,5 +1,5 @@
#ifndef __MEM_EVENTS_AH__
#define __MEM_EVENTS_AH__
#ifndef __MEM_ACCESS_AH__
#define __MEM_ACCESS_AH__
#include <iostream>
#include "config/FailConfig.hpp"
@ -10,14 +10,13 @@
#include "../../../bochs/cpu/cpu.h"
#include "../SALInst.hpp"
#include "bochs_helpers.hpp"
#include "BochsHelpers.hpp"
// FIXME we currently assume a "flat" memory model and ignore the segment
// parameter of all memory accesses
// TODO instruction fetch?
// TODO warn on uncovered memory accesses
aspect MemEvents
{
aspect MemAccess {
fail::address_t rmw_address;
pointcut write_methods() =
@ -58,19 +57,22 @@ aspect MemEvents
// Event source: "memory write access"
//
#ifdef CONFIG_EVENT_MEMWRITE
advice execution (write_methods()) : after () {
advice execution (write_methods()) : after ()
{
fail::simulator.onMemoryAccessEvent(
*(tjp->arg<1>()), sizeof(*(tjp->arg<2>())), true,
getCPU(tjp->that())->prev_rip);
}
advice execution (write_methods_RMW()) : after () {
advice execution (write_methods_RMW()) : after ()
{
fail::simulator.onMemoryAccessEvent(
rmw_address, sizeof(*(tjp->arg<0>())), true,
getCPU(tjp->that())->prev_rip);
}
advice execution (write_methods_new_stack()) : after () {
advice execution (write_methods_new_stack()) : after ()
{
std::cerr << "WOOOOOT write_methods_new_stack" << std::endl;
// TODO: Log-level?
fail::simulator.onMemoryAccessEvent(
@ -78,7 +80,8 @@ aspect MemEvents
getCPU(tjp->that())->prev_rip);
}
advice execution (write_methods_new_stack_64()) : after () {
advice execution (write_methods_new_stack_64()) : after ()
{
std::cerr << "WOOOOOT write_methods_new_stack_64" << std::endl;
// TODO: Log-level?
fail::simulator.onMemoryAccessEvent(
@ -86,7 +89,8 @@ aspect MemEvents
getCPU(tjp->that())->prev_rip);
}
advice execution (write_methods_system()) : after () {
advice execution (write_methods_system()) : after ()
{
// We don't do anything here for now: This type of memory
// access is used when the hardware itself needs to access
// memory (e.g., to read vectors from the interrupt vector
@ -106,20 +110,23 @@ aspect MemEvents
// Event source: "memory read access"
//
#ifdef CONFIG_EVENT_MEMREAD
advice execution (read_methods()) : before () {
advice execution (read_methods()) : before ()
{
fail::simulator.onMemoryAccessEvent(
*(tjp->arg<1>()), sizeof(*(tjp->result())), false,
getCPU(tjp->that())->prev_rip);
}
advice execution (read_methods_dqword()) : before () {
advice execution (read_methods_dqword()) : before ()
{
fail::simulator.onMemoryAccessEvent(
*(tjp->arg<1>()), 16, false,
getCPU(tjp->that())->prev_rip);
}
#endif
advice execution (read_methods_RMW()) : before () {
advice execution (read_methods_RMW()) : before ()
{
rmw_address = *(tjp->arg<1>());
#ifdef CONFIG_EVENT_MEMREAD
fail::simulator.onMemoryAccessEvent(
@ -129,7 +136,8 @@ aspect MemEvents
}
#ifdef CONFIG_EVENT_MEMREAD
advice execution (read_methods_system()) : before () {
advice execution (read_methods_system()) : before ()
{
// We don't do anything here for now: This type of memory
// access is used when the hardware itself needs to access
// memory (e.g., to read vectors from the interrupt vector
@ -145,4 +153,4 @@ aspect MemEvents
#endif // CONFIG_EVENT_MEMACCESS
#endif // __MEM_EVENTS_AH__
#endif // __MEM_ACCESS_AH__

View File

@ -1,102 +0,0 @@
#ifndef __MEM_ACCESS_BIT_FLIP_AH__
#define __MEM_ACCESS_BIT_FLIP_AH__
#include "config/FailConfig.hpp"
#ifdef CONFIG_FI_MEM_ACCESS_BITFLIP
#include <iostream>
#include <cstdlib>
#include <ctime>
#include "bochs.h"
#include "../../controller/EventList.hpp"
#include "../../controller/Event.hpp"
// FIXME: This is deprecated stuff. Delete this file.
using namespace std;
// FIXME this code doesn't make any sense for the read_virtual_% functions
// (the fault would need to be injected into their *return* value)
aspect MemAccessBitFlip
{
pointcut injection_methods()
= "% ...::bx_cpu_c::read_virtual_%(...)" || // -> access32/64.cc
/*
"% ...::bx_cpu_c::read_RMW_virtual_%(...)" || // -> access32.cc
"% ...::bx_cpu_c::system_read_%(...)" || // -> access.cc
"% ...::bx_cpu_c::v2h_read_byte(...)" || // -> access.cc
*/
"% ...::bx_cpu_c::write_virtual_%(...)"; // -> access32/64.cc
/*
"% ...::bx_cpu_c::write_RMW_virtual_%(...)" || // -> access32.cc
"% ...::bx_cpu_c::write_new_stack_%(...)" || // -> access32/64.cc
"% ...::bx_cpu_c::system_write_%(...)" || // -> access.cc
"% ...::bx_cpu_c::v2h_write_byte(...)"; // -> access.cc
*/
//
// Injects a bitflip each time the guest system requests to write/read
// data to/from RAM at the (hardcoded) addresses defined above:
//
// Event source: "memory write/read access"
//
advice execution (injection_methods()) : before ()
{
for(size_t i = 0; i < fi::evbuf.getEventCount(); i++) // check for active events
{
fi::SimpleBitFlip* pEv = dynamic_cast<fi::SimpleBitFlip*>(fi::evbuf.getEvent(i)); // FIXME: Performance verbessern
if(pEv && *(tjp->arg<1>())/*typed!*/ == pEv->getAddress())
{
cout << " " << tjp->signature() << endl;
// Get a pointer to the data that should be written to RAM
// *before* it is actually written:
Bit32u* pData = (Bit32u*)(tjp->arg(JoinPoint::ARGS-1));
// Flip bit at position pEv->getBitPos():
char* ptr = (char*)pData; // For simplification we're just looking at the
// first byte of the data
ptr[0] = (ptr[0]) ^ (pEv->getMask() << pEv->getBitPos());
cout << " >>> Bit flipped at index " << pEv->getBitPos()
<< " at address 0x" << hex << (*(tjp->arg<1>())) << "!" << endl;
fi::evbuf.fireEvent(pEv);
// Continue... (maybe more events to process)
}
}
}
/*
//
// Shows the mapping of a virtual address (within eCos) to a *host* address:
//
if(g_fEnableInjection) // event fired?
{
g_fEnableInjection = false;
const unsigned SEGMENT_SELECTOR_IDX = 2; // always the code segment (seg-base-addr should be zero)
const bx_address logicalAddr = MEM_ADDR_TO_INJECT; // offset within the segment ("local eCos address")
// Get the linear address:
Bit32u linearAddr = pThis->get_laddr32(SEGMENT_SELECTOR_IDX/ *seg* /, logicalAddr/ *offset* /);
// Map the linear address to the physical address:
bx_phy_address physicalAddr;
bx_bool fValid = pThis->dbg_xlate_linear2phy(linearAddr, (bx_phy_address*)&physicalAddr);
// Determine the *host* address of the physical address:
Bit8u* hostAddr = BX_MEM(0)->getHostMemAddr(pThis, physicalAddr, BX_READ);
// Now, hostAddr contains the "final" address where we are allowed to inject errors:
*(unsigned*)hostAddr = BAD_VALUE; // inject error
if(!fValid)
printf("[Error]: Could not map logical address to host address.\n");
else
printf("[Info]: Error injected at logical addr %p (host addr %p).\n", logicalAddr, hostAddr);
}
*/
};
#endif // CONFIG_FI_MEM_ACCESS_BITFLIP
#endif // __MEM_ACCESS_BIT_FLIP_AH__

View File

@ -8,10 +8,11 @@
#include "bochs.h"
aspect reboot {
aspect Reboot {
pointcut cpuLoop() = "void defineCPULoopJoinPoint(...)";
advice execution (cpuLoop()) : after () {
advice execution (cpuLoop()) : after ()
{
if (!fail::reboot_bochs_request) {
return;
}

View File

@ -1,5 +1,5 @@
#ifndef __RESTORE_AH__
#define __RESTORE_AH__
#ifndef __RESTORE_STATE_AH__
#define __RESTORE_STATE_AH__
#include <iostream>
@ -10,15 +10,17 @@
#include "bochs.h"
aspect restore {
aspect RestoreState {
pointcut restoreState() = "void bx_sr_after_restore_state()";
advice execution (restoreState()) : after () {
advice execution (restoreState()) : after ()
{
std::cout << "[FAIL] Restore finished" << std::endl;
// TODO: Log-Level?
fail::simulator.restoreDone();
}
};
#endif // CONFIG_SR_RESTORE
#endif // __RESTORE_AH__
#endif // __RESTORE_STATE_AH__

View File

@ -1,5 +1,5 @@
#ifndef __SAVE_AH__
#define __SAVE_AH__
#ifndef _SAVE_STATE_AH__
#define _SAVE_STATE_AH__
#include "config/FailConfig.hpp"
@ -8,25 +8,26 @@
#include "bochs.h"
#include "../SALInst.hpp"
aspect save {
aspect SaveState {
pointcut cpuLoop() = "void defineCPULoopJoinPoint(...)";
// make sure the "save" aspect comes *after* the breakpoint stuff: In
// make sure the "SaveState" aspect comes *after* the breakpoint stuff: In
// an "after" advice this means it must get a *higher* precedence,
// therefore it's first in the order list.
advice execution (cpuLoop()) : order ("save", "Breakpoints");
advice execution (cpuLoop()) : order ("SaveState", "Breakpoints");
advice execution (cpuLoop()) : after () {
if (!fail::save_bochs_request) {
return;
}
assert(fail::sr_path.size() > 0 && "[FAIL] tried to save state without valid path");
assert(fail::sr_path.size() > 0 && "FATAL ERROR: tried to save state without valid path");
SIM->save_state(fail::sr_path.c_str());
std::cout << "[FAIL] Save finished" << std::endl;
// TODO: Log-Level?
fail::simulator.saveDone();
}
};
#endif // CONFIG_SR_SAVE
#endif // _SAVE_AH__
#endif // _SAVE_STATE_AH__

View File

@ -10,8 +10,7 @@
#include "../SALInst.hpp"
aspect Trap
{
aspect Trap {
pointcut exception_method() = "void bx_cpu_c::exception(...)";
advice execution (exception_method()) : before ()

View File

@ -1,29 +0,0 @@
#ifndef __FIRETIMER_AH__
#define __FIRETIMER_AH__
#include <iostream>
// FIXME: This seems deprecated...?!
aspect fireTimer {
advice "bx_pc_system_c" : slice class {
public:
// TODO: Log-level?
void fireTimer(Bit32u timerNum){
if(timerNum <= numTimers){
if(!timer[timerNum].active){
std::cout << "[FAIL] WARNING: The selected timer is actually NOT active!" << std::endl;
}
currCountdownPeriod = Bit64u(1);
timer[timerNum].timeToFire = Bit64u(currCountdownPeriod) + ticksTotal;
std::cout << "[FAIL] Timer " << timerNum <<" will fire now!" << std::endl;
}else{
std::cout << "[FAIL] There are actually only " << numTimers <<" allocated!" << std::endl;
}
}
};
};
#endif // __FIRETIMER_AH__

View File

@ -1,13 +0,0 @@
#ifndef __BXINIT_AH__
#define __BXINIT_AH__
#include "../SALInst.hpp"
aspect BochsInit {
advice call("int bxmain()") : before ()
{
fail::simulator.startup();
}
};
#endif // __BXINIT_AH__

View File

@ -3,10 +3,11 @@
#include "../SALInst.hpp"
aspect OVPInit {
aspect FailOVPInit {
advice call("% ...::startSimulation(...)") : before ()
{
std::cout << "OVP init aspect!" << std::endl;
// TODO: Log-Level?
fail::simulator.startup();
}
};