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