File tree Expand file tree Collapse file tree 6 files changed +581
-0
lines changed Expand file tree Collapse file tree 6 files changed +581
-0
lines changed Original file line number Diff line number Diff line change 24
24
union rv_task_monitor {
25
25
};
26
26
27
+ #ifdef CONFIG_RV_REACTORS
28
+ struct rv_reactor {
29
+ const char * name ;
30
+ const char * description ;
31
+ void (* react )(char * msg );
32
+ };
33
+ #endif
34
+
27
35
struct rv_monitor {
28
36
const char * name ;
29
37
const char * description ;
30
38
bool enabled ;
31
39
int (* enable )(void );
32
40
void (* disable )(void );
33
41
void (* reset )(void );
42
+ #ifdef CONFIG_RV_REACTORS
43
+ void (* react )(char * msg );
44
+ #endif
34
45
};
35
46
36
47
bool rv_monitoring_on (void );
@@ -39,5 +50,11 @@ int rv_register_monitor(struct rv_monitor *monitor);
39
50
int rv_get_task_monitor_slot (void );
40
51
void rv_put_task_monitor_slot (int slot );
41
52
53
+ #ifdef CONFIG_RV_REACTORS
54
+ bool rv_reacting_on (void );
55
+ int rv_unregister_reactor (struct rv_reactor * reactor );
56
+ int rv_register_reactor (struct rv_reactor * reactor );
57
+ #endif /* CONFIG_RV_REACTORS */
58
+
42
59
#endif /* CONFIG_RV */
43
60
#endif /* _LINUX_RV_H */
Original file line number Diff line number Diff line change @@ -10,3 +10,14 @@ menuconfig RV
10
10
theorem proving). RV works by analyzing the trace of the system's
11
11
actual execution, comparing it against a formal specification of
12
12
the system behavior.
13
+
14
+ config RV_REACTORS
15
+ bool "Runtime verification reactors"
16
+ default y
17
+ depends on RV
18
+ help
19
+ Enables the online runtime verification reactors. A runtime
20
+ monitor can cause a reaction to the detection of an exception
21
+ on the model's execution. By default, the monitors have
22
+ tracing reactions, printing the monitor output via tracepoints,
23
+ but other reactions can be added (on-demand) via this interface.
Original file line number Diff line number Diff line change 1
1
# SPDX-License-Identifier: GPL-2.0
2
2
3
3
obj-$(CONFIG_RV) += rv.o
4
+ obj-$(CONFIG_RV_REACTORS) += rv_reactors.o
Original file line number Diff line number Diff line change @@ -353,6 +353,10 @@ static int create_monitor_dir(struct rv_monitor_def *mdef)
353
353
goto out_remove_root ;
354
354
}
355
355
356
+ retval = reactor_populate_monitor (mdef );
357
+ if (retval )
358
+ goto out_remove_root ;
359
+
356
360
return 0 ;
357
361
358
362
out_remove_root :
@@ -669,6 +673,7 @@ static const struct file_operations monitoring_on_fops = {
669
673
670
674
static void destroy_monitor_dir (struct rv_monitor_def * mdef )
671
675
{
676
+ reactor_cleanup_monitor (mdef );
672
677
rv_remove (mdef -> root_d );
673
678
}
674
679
@@ -747,6 +752,7 @@ int rv_unregister_monitor(struct rv_monitor *monitor)
747
752
int __init rv_init_interface (void )
748
753
{
749
754
struct dentry * tmp ;
755
+ int retval ;
750
756
751
757
rv_root .root_dir = rv_create_dir ("rv" , NULL );
752
758
if (!rv_root .root_dir )
@@ -770,6 +776,9 @@ int __init rv_init_interface(void)
770
776
& monitoring_on_fops );
771
777
if (!tmp )
772
778
goto out_err ;
779
+ retval = init_rv_reactors (rv_root .root_dir );
780
+ if (retval )
781
+ goto out_err ;
773
782
774
783
turn_monitoring_on ();
775
784
Original file line number Diff line number Diff line change @@ -18,16 +18,51 @@ struct rv_interface {
18
18
#define rv_remove tracefs_remove
19
19
20
20
#define MAX_RV_MONITOR_NAME_SIZE 32
21
+ #define MAX_RV_REACTOR_NAME_SIZE 32
21
22
22
23
extern struct mutex rv_interface_lock ;
23
24
25
+ #ifdef CONFIG_RV_REACTORS
26
+ struct rv_reactor_def {
27
+ struct list_head list ;
28
+ struct rv_reactor * reactor ;
29
+ /* protected by the monitor interface lock */
30
+ int counter ;
31
+ };
32
+ #endif
33
+
24
34
struct rv_monitor_def {
25
35
struct list_head list ;
26
36
struct rv_monitor * monitor ;
27
37
struct dentry * root_d ;
38
+ #ifdef CONFIG_RV_REACTORS
39
+ struct rv_reactor_def * rdef ;
40
+ bool reacting ;
41
+ #endif
28
42
bool task_monitor ;
29
43
};
30
44
31
45
struct dentry * get_monitors_root (void );
32
46
int rv_disable_monitor (struct rv_monitor_def * mdef );
33
47
int rv_enable_monitor (struct rv_monitor_def * mdef );
48
+
49
+ #ifdef CONFIG_RV_REACTORS
50
+ int reactor_populate_monitor (struct rv_monitor_def * mdef );
51
+ void reactor_cleanup_monitor (struct rv_monitor_def * mdef );
52
+ int init_rv_reactors (struct dentry * root_dir );
53
+ #else
54
+ static inline int reactor_populate_monitor (struct rv_monitor_def * mdef )
55
+ {
56
+ return 0 ;
57
+ }
58
+
59
+ static inline void reactor_cleanup_monitor (struct rv_monitor_def * mdef )
60
+ {
61
+ return ;
62
+ }
63
+
64
+ static inline int init_rv_reactors (struct dentry * root_dir )
65
+ {
66
+ return 0 ;
67
+ }
68
+ #endif
You can’t perform that action at this time.
0 commit comments