reactor_panic.c 986 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (C) 2019-2022 Red Hat, Inc. Daniel Bristot de Oliveira <[email protected]>
  4. *
  5. * Panic RV reactor:
  6. * Prints the exception msg to the kernel message log and panic().
  7. */
  8. #include <linux/ftrace.h>
  9. #include <linux/tracepoint.h>
  10. #include <linux/kernel.h>
  11. #include <linux/module.h>
  12. #include <linux/init.h>
  13. #include <linux/rv.h>
  14. static void rv_panic_reaction(char *msg)
  15. {
  16. panic(msg);
  17. }
  18. static struct rv_reactor rv_panic = {
  19. .name = "panic",
  20. .description = "panic the system if an exception is found.",
  21. .react = rv_panic_reaction
  22. };
  23. static int __init register_react_panic(void)
  24. {
  25. rv_register_reactor(&rv_panic);
  26. return 0;
  27. }
  28. static void __exit unregister_react_panic(void)
  29. {
  30. rv_unregister_reactor(&rv_panic);
  31. }
  32. module_init(register_react_panic);
  33. module_exit(unregister_react_panic);
  34. MODULE_LICENSE("GPL");
  35. MODULE_AUTHOR("Daniel Bristot de Oliveira");
  36. MODULE_DESCRIPTION("panic rv reactor: panic if an exception is found.");