summaryrefslogtreecommitdiff
path: root/tools/lib/traceevent/plugin_xen.c
blob: 993b208d0323f8745e6360895fdf3befc30ac5cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// SPDX-License-Identifier: GPL-2.0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "event-parse.h"
#include "trace-seq.h"

#define __HYPERVISOR_set_trap_table			0
#define __HYPERVISOR_mmu_update				1
#define __HYPERVISOR_set_gdt				2
#define __HYPERVISOR_stack_switch			3
#define __HYPERVISOR_set_callbacks			4
#define __HYPERVISOR_fpu_taskswitch			5
#define __HYPERVISOR_sched_op_compat			6
#define __HYPERVISOR_dom0_op				7
#define __HYPERVISOR_set_debugreg			8
#define __HYPERVISOR_get_debugreg			9
#define __HYPERVISOR_update_descriptor			10
#define __HYPERVISOR_memory_op				12
#define __HYPERVISOR_multicall				13
#define __HYPERVISOR_update_va_mapping			14
#define __HYPERVISOR_set_timer_op			15
#define __HYPERVISOR_event_channel_op_compat		16
#define __HYPERVISOR_xen_version			17
#define __HYPERVISOR_console_io				18
#define __HYPERVISOR_physdev_op_compat			19
#define __HYPERVISOR_grant_table_op			20
#define __HYPERVISOR_vm_assist				21
#define __HYPERVISOR_update_va_mapping_otherdomain	22
#define __HYPERVISOR_iret				23 /* x86 only */
#define __HYPERVISOR_vcpu_op				24
#define __HYPERVISOR_set_segment_base			25 /* x86/64 only */
#define __HYPERVISOR_mmuext_op				26
#define __HYPERVISOR_acm_op				27
#define __HYPERVISOR_nmi_op				28
#define __HYPERVISOR_sched_op				29
#define __HYPERVISOR_callback_op			30
#define __HYPERVISOR_xenoprof_op			31
#define __HYPERVISOR_event_channel_op			32
#define __HYPERVISOR_physdev_op				33
#define __HYPERVISOR_hvm_op				34
#define __HYPERVISOR_tmem_op				38

/* Architecture-specific hypercall definitions. */
#define __HYPERVISOR_arch_0				48
#define __HYPERVISOR_arch_1				49
#define __HYPERVISOR_arch_2				50
#define __HYPERVISOR_arch_3				51
#define __HYPERVISOR_arch_4				52
#define __HYPERVISOR_arch_5				53
#define __HYPERVISOR_arch_6				54
#define __HYPERVISOR_arch_7				55

#define N(x)	[__HYPERVISOR_##x] = "("#x")"
static const char *xen_hypercall_names[] = {
	N(set_trap_table),
	N(mmu_update),
	N(set_gdt),
	N(stack_switch),
	N(set_callbacks),
	N(fpu_taskswitch),
	N(sched_op_compat),
	N(dom0_op),
	N(set_debugreg),
	N(get_debugreg),
	N(update_descriptor),
	N(memory_op),
	N(multicall),
	N(update_va_mapping),
	N(set_timer_op),
	N(event_channel_op_compat),
	N(xen_version),
	N(console_io),
	N(physdev_op_compat),
	N(grant_table_op),
	N(vm_assist),
	N(update_va_mapping_otherdomain),
	N(iret),
	N(vcpu_op),
	N(set_segment_base),
	N(mmuext_op),
	N(acm_op),
	N(nmi_op),
	N(sched_op),
	N(callback_op),
	N(xenoprof_op),
	N(event_channel_op),
	N(physdev_op),
	N(hvm_op),

/* Architecture-specific hypercall definitions. */
	N(arch_0),
	N(arch_1),
	N(arch_2),
	N(arch_3),
	N(arch_4),
	N(arch_5),
	N(arch_6),
	N(arch_7),
};
#undef N

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

static const char *xen_hypercall_name(unsigned op)
{
	if (op < ARRAY_SIZE(xen_hypercall_names) &&
	    xen_hypercall_names[op] != NULL)
		return xen_hypercall_names[op];

	return "";
}

unsigned long long process_xen_hypercall_name(struct trace_seq *s,
					      unsigned long long *args)
{
	unsigned int op = args[0];

	trace_seq_printf(s, "%s", xen_hypercall_name(op));
	return 0;
}

int TEP_PLUGIN_LOADER(struct tep_handle *tep)
{
	tep_register_print_function(tep,
				    process_xen_hypercall_name,
				    TEP_FUNC_ARG_STRING,
				    "xen_hypercall_name",
				    TEP_FUNC_ARG_INT,
				    TEP_FUNC_ARG_VOID);
	return 0;
}

void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
{
	tep_unregister_print_function(tep, process_xen_hypercall_name,
				      "xen_hypercall_name");
}