rv.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Runtime Verification.
  4. *
  5. * For futher information, see: kernel/trace/rv/rv.c.
  6. */
  7. #ifndef _LINUX_RV_H
  8. #define _LINUX_RV_H
  9. #define MAX_DA_NAME_LEN 24
  10. #ifdef CONFIG_RV
  11. /*
  12. * Deterministic automaton per-object variables.
  13. */
  14. struct da_monitor {
  15. bool monitoring;
  16. unsigned int curr_state;
  17. };
  18. /*
  19. * Per-task RV monitors count. Nowadays fixed in RV_PER_TASK_MONITORS.
  20. * If we find justification for more monitors, we can think about
  21. * adding more or developing a dynamic method. So far, none of
  22. * these are justified.
  23. */
  24. #define RV_PER_TASK_MONITORS 1
  25. #define RV_PER_TASK_MONITOR_INIT (RV_PER_TASK_MONITORS)
  26. /*
  27. * Futher monitor types are expected, so make this a union.
  28. */
  29. union rv_task_monitor {
  30. struct da_monitor da_mon;
  31. };
  32. #ifdef CONFIG_RV_REACTORS
  33. struct rv_reactor {
  34. const char *name;
  35. const char *description;
  36. void (*react)(char *msg);
  37. };
  38. #endif
  39. struct rv_monitor {
  40. const char *name;
  41. const char *description;
  42. bool enabled;
  43. int (*enable)(void);
  44. void (*disable)(void);
  45. void (*reset)(void);
  46. #ifdef CONFIG_RV_REACTORS
  47. void (*react)(char *msg);
  48. #endif
  49. };
  50. bool rv_monitoring_on(void);
  51. int rv_unregister_monitor(struct rv_monitor *monitor);
  52. int rv_register_monitor(struct rv_monitor *monitor);
  53. int rv_get_task_monitor_slot(void);
  54. void rv_put_task_monitor_slot(int slot);
  55. #ifdef CONFIG_RV_REACTORS
  56. bool rv_reacting_on(void);
  57. int rv_unregister_reactor(struct rv_reactor *reactor);
  58. int rv_register_reactor(struct rv_reactor *reactor);
  59. #endif /* CONFIG_RV_REACTORS */
  60. #endif /* CONFIG_RV */
  61. #endif /* _LINUX_RV_H */