xref: /linux/include/linux/rv.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1102227b9SDaniel Bristot de Oliveira /* SPDX-License-Identifier: GPL-2.0 */
2102227b9SDaniel Bristot de Oliveira /*
3102227b9SDaniel Bristot de Oliveira  * Runtime Verification.
4102227b9SDaniel Bristot de Oliveira  *
5102227b9SDaniel Bristot de Oliveira  * For futher information, see: kernel/trace/rv/rv.c.
6102227b9SDaniel Bristot de Oliveira  */
7102227b9SDaniel Bristot de Oliveira #ifndef _LINUX_RV_H
8102227b9SDaniel Bristot de Oliveira #define _LINUX_RV_H
9102227b9SDaniel Bristot de Oliveira 
10*79257534SDaniel Bristot de Oliveira #define MAX_DA_NAME_LEN	24
11*79257534SDaniel Bristot de Oliveira 
12102227b9SDaniel Bristot de Oliveira #ifdef CONFIG_RV
13*79257534SDaniel Bristot de Oliveira /*
14*79257534SDaniel Bristot de Oliveira  * Deterministic automaton per-object variables.
15*79257534SDaniel Bristot de Oliveira  */
16*79257534SDaniel Bristot de Oliveira struct da_monitor {
17*79257534SDaniel Bristot de Oliveira 	bool		monitoring;
18*79257534SDaniel Bristot de Oliveira 	unsigned int	curr_state;
19*79257534SDaniel Bristot de Oliveira };
20102227b9SDaniel Bristot de Oliveira 
21102227b9SDaniel Bristot de Oliveira /*
22102227b9SDaniel Bristot de Oliveira  * Per-task RV monitors count. Nowadays fixed in RV_PER_TASK_MONITORS.
23102227b9SDaniel Bristot de Oliveira  * If we find justification for more monitors, we can think about
24102227b9SDaniel Bristot de Oliveira  * adding more or developing a dynamic method. So far, none of
25102227b9SDaniel Bristot de Oliveira  * these are justified.
26102227b9SDaniel Bristot de Oliveira  */
27102227b9SDaniel Bristot de Oliveira #define RV_PER_TASK_MONITORS		1
28102227b9SDaniel Bristot de Oliveira #define RV_PER_TASK_MONITOR_INIT	(RV_PER_TASK_MONITORS)
29102227b9SDaniel Bristot de Oliveira 
30102227b9SDaniel Bristot de Oliveira /*
31102227b9SDaniel Bristot de Oliveira  * Futher monitor types are expected, so make this a union.
32102227b9SDaniel Bristot de Oliveira  */
33102227b9SDaniel Bristot de Oliveira union rv_task_monitor {
34*79257534SDaniel Bristot de Oliveira 	struct da_monitor da_mon;
35102227b9SDaniel Bristot de Oliveira };
36102227b9SDaniel Bristot de Oliveira 
3704acadcbSDaniel Bristot de Oliveira #ifdef CONFIG_RV_REACTORS
3804acadcbSDaniel Bristot de Oliveira struct rv_reactor {
3904acadcbSDaniel Bristot de Oliveira 	const char		*name;
4004acadcbSDaniel Bristot de Oliveira 	const char		*description;
4104acadcbSDaniel Bristot de Oliveira 	void			(*react)(char *msg);
4204acadcbSDaniel Bristot de Oliveira };
4304acadcbSDaniel Bristot de Oliveira #endif
4404acadcbSDaniel Bristot de Oliveira 
45102227b9SDaniel Bristot de Oliveira struct rv_monitor {
46102227b9SDaniel Bristot de Oliveira 	const char		*name;
47102227b9SDaniel Bristot de Oliveira 	const char		*description;
48102227b9SDaniel Bristot de Oliveira 	bool			enabled;
49102227b9SDaniel Bristot de Oliveira 	int			(*enable)(void);
50102227b9SDaniel Bristot de Oliveira 	void			(*disable)(void);
51102227b9SDaniel Bristot de Oliveira 	void			(*reset)(void);
5204acadcbSDaniel Bristot de Oliveira #ifdef CONFIG_RV_REACTORS
5304acadcbSDaniel Bristot de Oliveira 	void			(*react)(char *msg);
5404acadcbSDaniel Bristot de Oliveira #endif
55102227b9SDaniel Bristot de Oliveira };
56102227b9SDaniel Bristot de Oliveira 
57102227b9SDaniel Bristot de Oliveira bool rv_monitoring_on(void);
58102227b9SDaniel Bristot de Oliveira int rv_unregister_monitor(struct rv_monitor *monitor);
59102227b9SDaniel Bristot de Oliveira int rv_register_monitor(struct rv_monitor *monitor);
60102227b9SDaniel Bristot de Oliveira int rv_get_task_monitor_slot(void);
61102227b9SDaniel Bristot de Oliveira void rv_put_task_monitor_slot(int slot);
62102227b9SDaniel Bristot de Oliveira 
6304acadcbSDaniel Bristot de Oliveira #ifdef CONFIG_RV_REACTORS
6404acadcbSDaniel Bristot de Oliveira bool rv_reacting_on(void);
6504acadcbSDaniel Bristot de Oliveira int rv_unregister_reactor(struct rv_reactor *reactor);
6604acadcbSDaniel Bristot de Oliveira int rv_register_reactor(struct rv_reactor *reactor);
6704acadcbSDaniel Bristot de Oliveira #endif /* CONFIG_RV_REACTORS */
6804acadcbSDaniel Bristot de Oliveira 
69102227b9SDaniel Bristot de Oliveira #endif /* CONFIG_RV */
70102227b9SDaniel Bristot de Oliveira #endif /* _LINUX_RV_H */
71