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