plugin_xen.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "event-parse.h"
  5. #define __HYPERVISOR_set_trap_table 0
  6. #define __HYPERVISOR_mmu_update 1
  7. #define __HYPERVISOR_set_gdt 2
  8. #define __HYPERVISOR_stack_switch 3
  9. #define __HYPERVISOR_set_callbacks 4
  10. #define __HYPERVISOR_fpu_taskswitch 5
  11. #define __HYPERVISOR_sched_op_compat 6
  12. #define __HYPERVISOR_dom0_op 7
  13. #define __HYPERVISOR_set_debugreg 8
  14. #define __HYPERVISOR_get_debugreg 9
  15. #define __HYPERVISOR_update_descriptor 10
  16. #define __HYPERVISOR_memory_op 12
  17. #define __HYPERVISOR_multicall 13
  18. #define __HYPERVISOR_update_va_mapping 14
  19. #define __HYPERVISOR_set_timer_op 15
  20. #define __HYPERVISOR_event_channel_op_compat 16
  21. #define __HYPERVISOR_xen_version 17
  22. #define __HYPERVISOR_console_io 18
  23. #define __HYPERVISOR_physdev_op_compat 19
  24. #define __HYPERVISOR_grant_table_op 20
  25. #define __HYPERVISOR_vm_assist 21
  26. #define __HYPERVISOR_update_va_mapping_otherdomain 22
  27. #define __HYPERVISOR_iret 23 /* x86 only */
  28. #define __HYPERVISOR_vcpu_op 24
  29. #define __HYPERVISOR_set_segment_base 25 /* x86/64 only */
  30. #define __HYPERVISOR_mmuext_op 26
  31. #define __HYPERVISOR_acm_op 27
  32. #define __HYPERVISOR_nmi_op 28
  33. #define __HYPERVISOR_sched_op 29
  34. #define __HYPERVISOR_callback_op 30
  35. #define __HYPERVISOR_xenoprof_op 31
  36. #define __HYPERVISOR_event_channel_op 32
  37. #define __HYPERVISOR_physdev_op 33
  38. #define __HYPERVISOR_hvm_op 34
  39. #define __HYPERVISOR_tmem_op 38
  40. /* Architecture-specific hypercall definitions. */
  41. #define __HYPERVISOR_arch_0 48
  42. #define __HYPERVISOR_arch_1 49
  43. #define __HYPERVISOR_arch_2 50
  44. #define __HYPERVISOR_arch_3 51
  45. #define __HYPERVISOR_arch_4 52
  46. #define __HYPERVISOR_arch_5 53
  47. #define __HYPERVISOR_arch_6 54
  48. #define __HYPERVISOR_arch_7 55
  49. #define N(x) [__HYPERVISOR_##x] = "("#x")"
  50. static const char *xen_hypercall_names[] = {
  51. N(set_trap_table),
  52. N(mmu_update),
  53. N(set_gdt),
  54. N(stack_switch),
  55. N(set_callbacks),
  56. N(fpu_taskswitch),
  57. N(sched_op_compat),
  58. N(dom0_op),
  59. N(set_debugreg),
  60. N(get_debugreg),
  61. N(update_descriptor),
  62. N(memory_op),
  63. N(multicall),
  64. N(update_va_mapping),
  65. N(set_timer_op),
  66. N(event_channel_op_compat),
  67. N(xen_version),
  68. N(console_io),
  69. N(physdev_op_compat),
  70. N(grant_table_op),
  71. N(vm_assist),
  72. N(update_va_mapping_otherdomain),
  73. N(iret),
  74. N(vcpu_op),
  75. N(set_segment_base),
  76. N(mmuext_op),
  77. N(acm_op),
  78. N(nmi_op),
  79. N(sched_op),
  80. N(callback_op),
  81. N(xenoprof_op),
  82. N(event_channel_op),
  83. N(physdev_op),
  84. N(hvm_op),
  85. /* Architecture-specific hypercall definitions. */
  86. N(arch_0),
  87. N(arch_1),
  88. N(arch_2),
  89. N(arch_3),
  90. N(arch_4),
  91. N(arch_5),
  92. N(arch_6),
  93. N(arch_7),
  94. };
  95. #undef N
  96. #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
  97. static const char *xen_hypercall_name(unsigned op)
  98. {
  99. if (op < ARRAY_SIZE(xen_hypercall_names) &&
  100. xen_hypercall_names[op] != NULL)
  101. return xen_hypercall_names[op];
  102. return "";
  103. }
  104. unsigned long long process_xen_hypercall_name(struct trace_seq *s,
  105. unsigned long long *args)
  106. {
  107. unsigned int op = args[0];
  108. trace_seq_printf(s, "%s", xen_hypercall_name(op));
  109. return 0;
  110. }
  111. int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
  112. {
  113. pevent_register_print_function(pevent,
  114. process_xen_hypercall_name,
  115. PEVENT_FUNC_ARG_STRING,
  116. "xen_hypercall_name",
  117. PEVENT_FUNC_ARG_INT,
  118. PEVENT_FUNC_ARG_VOID);
  119. return 0;
  120. }
  121. void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
  122. {
  123. pevent_unregister_print_function(pevent, process_xen_hypercall_name,
  124. "xen_hypercall_name");
  125. }