Skip to content

How to Use llfiindex Fault Injection Instruction Selector

Qining edited this page Dec 23, 2014 · 2 revisions

Overview

llfiindex is a custom fault injection instruction selector (defined under llvm_passes/LLFIIndexFIInstSelector.cpp ). The goal of the pass is to only select specified instruction(s) as fault injection targets and instrument it(them) for profiling/fault injection. The instruction(s) is specified through a unique ID named LLFI index. At runtime, you can choose one runtime instance of the specified instruction(s) for fault injection. Of course, you can do fault injection on the selected instruction(s) in some other ways.

The process of using llfiindex as instruction selector is the same as what is described in Get Started with LLFI. However, there are two things need to be changed in order to use it. One is input.yaml, and the other is getting the LLFI index for the instructions.

Configure input.yaml

Since llfiindex is a custom instruction selector, you need to specify instSelMethod to custominstselector and add two keys named customInstSelector and customInstSelectorOption (as is described in [Get Started with LLFI Using Command Line](Get Started with LLFI Using Command Line) ). For customInstSelectorOption, you can specify one or several -injecttoindex=<specify llfi index for fault injection> for fault injection. Below is the configuration of input.yaml

compileOption:
    instSelMethod: 
      - custominstselector:
          include:
            - llfiindex
          option:
            - -injecttoindex=<specify index for fault injection>
            [- -injecttoindex=<specify index for fault injection>]
            ...

Get LLFI index for the instructions

Since you need to use LLFI index to specify the fault injection targets, you need to know the LLFI index of a specific instruction first. To do this, you can first run instrument with --readable as an option, and then you will see the *.llfi_index.ll under the directory you specified through --dir (default llfi/). Then you can use the *.llfi_index.ll as a reference to do 'real' instrumentation and fault injection.