forked from Fraunhofer-AISEC/archie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfault_injection.h
119 lines (107 loc) · 3.52 KB
/
fault_injection.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* Copyright 2021 Florian Andreas Hauschild
* Copyright (c) 2021 Fraunhofer AISEC
* Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file contains the header for injecting faults in qemu
*/
#ifndef FAULT_INJECTION
#define FAULT_INJECTION
#include "fault_list.h"
#include "singlestep.h"
/**
* inject_fault
*
* At this point the fault needs to be injected. This is the function to select the right model and call the injection function
*
* current: Struct address containing the fault information needed
*/
void inject_fault(fault_list_t * current);
/**
* reverse_fault
*
* Reverse the fault injected
*
* current: fault description
*/
void reverse_fault(fault_list_t * current);
/**
* inject_register_fault
*
* Inject fault into registers. Reads the current string and determines the register that is attacked, loads it and performs the fault required
*/
void inject_register_fault(fault_list_t * current);
/**
* reverse_register_fault
*/
void reverse_register_fault(fault_list_t * current);
/**
* inject_memory_fault
*
* injects fault into memory regions
* Reads current struct to determine the location, model, and mask of fault.
* Then performs the fault injection
*
* current: Struct address containing the fault information
*/
void inject_memory_fault(fault_list_t * current);
/**
* process_overwrite_memory
*
* Read memory, then overwrite the bytes specified by mask value. Num_bytes specify the number of bytes. currently max 16 bytes.
*
* address: base address of lowest byte
* maks: Values to overwrite the bytes at address location.
* num_bytes: Number of bytes to be overwritten.
* restoremask: Mask used to restore back values to original values for temoporary faults
*/
void process_overwrite_memory(uint64_t address, uint8_t num_bytes, uint8_t mask[], uint8_t restoremask[]);
/**
* process_set1_memory
*
* Read memory, then set bits according to mask, then write memory back
*
* address: base address of lowest byte
* mask: mask containing which bits need to be flipped to 1
*/
void process_set1_memory(uint64_t address, uint8_t mask[], uint8_t restoremask[]);
/**
* process_reverse_fault
*
* Read memory, then apply restore mask according to fault mask, then write memory back
*
* address: base address of fault
* mask: location mask of bits set to 0 for reverse
*/
void process_reverse_fault(uint64_t address, uint8_t mask[], uint8_t restoremask[]);
/**
* process_set0_memory
*
* Read memory, then clear bits according to mask, then write memory back
*
* address: base address of fault
* mask: location mask of bits set to 0
*/
void process_set0_memory(uint64_t address, uint8_t mask[], uint8_t restoremask[]);
/**
* process_toggle_memory
*
* Read memory, then toggle bits according to mask, then write memory back
*
* address: base address of fault
* mask: location mask of bits to be toggled
*/
void process_toggle_memory(uint64_t address, uint8_t mask[], uint8_t restoremask[]);
#endif