Skip to content

Commit

Permalink
Update example/bare_etiss_processor with new CPUCore instance forced …
Browse files Browse the repository at this point in the history
…initialize_virtualstruct call. Add WIP: Fault Injection How-To to examples/bare_etiss_processor/README.md and example `fault.xml` file for better reference.
  • Loading branch information
JoGei committed Jun 30, 2022
1 parent c0c4b0c commit d0c70df
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 8 deletions.
37 changes: 37 additions & 0 deletions examples/bare_etiss_processor/faults.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<faults>
<fault name="meta">
<triggers>
<trigger type="META_COUNTER">
<count>1</count>
<trigger type="VARIABLEVALUE">
<injector>core%i%</injector>
<field>instructionPointer</field>
<value>b0</value>
</trigger>
</trigger>
</triggers>
<actions>
<action type="BITFLIP">
<injector>core%i%</injector>
<field>R1</field>
<bit>1</bit>
</action>
<action type="INJECTION">
<fault name="injected_fault">
<triggers>
<trigger type="NOP"></trigger>
<trigger type="VARIABLEVALUE">
<injector>core%i%</injector>
<field>instructionPointer</field>
<value>b8</value>
</trigger>
</triggers>
<actions>
<action type="NOP">
</action>
</actions>
</fault>
</action>
</actions>
</fault>
</faults>
51 changes: 51 additions & 0 deletions src/bare_etiss_processor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,54 @@ When utilizing **gdbserver** to debug target software.
### ETISS output in terminal

![](etissSnapshot.png "ETISS output in terminal")

## Fault Injection Demo

Usage:

- ./run_helper.sh ELFFILE --faults.xml=/path/to/faults.xml

`faults.xml` Example:

- `[]` are optional attributes
- `#` is a comment for this example

```
<faults> # a faults.xml root
<fault [name="some name"]> # a <fault> has <triggers> and <actions>
<triggers>
<trigger type="META_COUNTER"> # a <trigger> must have a type of {META_COUNTER, VARIABLEVALUE, TIME, TIMERELATIVE, NOP}
<count>1</count> # the META_COUNTER here will trigger once its subtrigger fired <count> times
<trigger type="VARIABLEVALUE"> # a <trigger> can have a sub <trigger>, awesome!
<injector>core%i%</injector> # the trigger type VARIABLEVALUE needs an <injector> that supplies the triggerable object, bare_etiss_processor constructs "core0" ETISS-FI will replace %i% to the core id "0" by default
<field>instructionPointer</field> # the <field> of "core%i%" should be listened for, here, the instruction pointer
<value>b0</value> # the <value> that <field>'s value will be compared to as a hexadecimal
</trigger>
</trigger>
</triggers>
<actions>
<action type="COMMAND"> # an <action> must have a type of {BITFLIP, COMMAND, NOP, INJECTION}, here, Command
<injector>core%i%</injector> # an <action> can have a different <injector> than its <trigger>s, which means, you could trigger on one VirtualStruct and inject into another
<command>test</command> # the COMMAND type is a custom string encoded action the <injector> has to implement, by default no custom actions are supported. Set VirtualStructs::applyCustomAction member to a std::function of your choice and handle the passed string
</action>
<action type="BITFLIP"> # why not have more than one <action>, an additional "BITFLIP"
<injector>core%i%</injector> # again we need the <injector>
<field>R1</field> # BITFLIP takes a <field>, here R1 aka X1 in RISC-V, with the CPUCore all ISA-GPRs and the PC are <fields>
<bit>1</bit> # the target <bit> number
</action>
<action type="INJECTION"> # now, we inject a new fault as our action.
<fault [name="some name"]>
<triggers>
<trigger type="NOP">
</trigger>
</triggers>
<actions>
<action type="NOP">
</action>
</actions>
</fault>
</action>
</actions>
</fault>
</faults>
```
12 changes: 4 additions & 8 deletions src/bare_etiss_processor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,10 @@ int main(int argc, const char *argv[])
// reset CPU with a manual start address
cpu->reset(&sa);

// add the virtual structure of the cpu to the VirtualStruct root. This allows
// to access the field of the cpu from a global context. See
// etiss::VirtualStruct::getVirtualStruct() and
// etiss::VirtualStruct::getResolvedField(). In this case e.g. the
// instructionPointer can be read from a global context by calling
// etiss::VirtualStruct::root()->getResolvedField("core0.instructionPointer")
// ->read().
etiss::VirtualStruct::root()->mountStruct("core0", cpu->getStruct());
// bind the cpu's VirtualStruct to etiss' root VirtualStruct and initialize faults
// if those where specified in config/cmdline
etiss::initialize_virtualstruct(cpu);

std::cout << "=== Finished Setting up test system ===" << std::endl << std::endl;

std::cout << "=== Setting up plug-ins ===" << std::endl;
Expand Down

0 comments on commit d0c70df

Please sign in to comment.