18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci#include <stdio.h> 38c2ecf20Sopenharmony_ci#include <stdlib.h> 48c2ecf20Sopenharmony_ci#include <string.h> 58c2ecf20Sopenharmony_ci#include "event-parse.h" 68c2ecf20Sopenharmony_ci#include "trace-seq.h" 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#define __HYPERVISOR_set_trap_table 0 98c2ecf20Sopenharmony_ci#define __HYPERVISOR_mmu_update 1 108c2ecf20Sopenharmony_ci#define __HYPERVISOR_set_gdt 2 118c2ecf20Sopenharmony_ci#define __HYPERVISOR_stack_switch 3 128c2ecf20Sopenharmony_ci#define __HYPERVISOR_set_callbacks 4 138c2ecf20Sopenharmony_ci#define __HYPERVISOR_fpu_taskswitch 5 148c2ecf20Sopenharmony_ci#define __HYPERVISOR_sched_op_compat 6 158c2ecf20Sopenharmony_ci#define __HYPERVISOR_dom0_op 7 168c2ecf20Sopenharmony_ci#define __HYPERVISOR_set_debugreg 8 178c2ecf20Sopenharmony_ci#define __HYPERVISOR_get_debugreg 9 188c2ecf20Sopenharmony_ci#define __HYPERVISOR_update_descriptor 10 198c2ecf20Sopenharmony_ci#define __HYPERVISOR_memory_op 12 208c2ecf20Sopenharmony_ci#define __HYPERVISOR_multicall 13 218c2ecf20Sopenharmony_ci#define __HYPERVISOR_update_va_mapping 14 228c2ecf20Sopenharmony_ci#define __HYPERVISOR_set_timer_op 15 238c2ecf20Sopenharmony_ci#define __HYPERVISOR_event_channel_op_compat 16 248c2ecf20Sopenharmony_ci#define __HYPERVISOR_xen_version 17 258c2ecf20Sopenharmony_ci#define __HYPERVISOR_console_io 18 268c2ecf20Sopenharmony_ci#define __HYPERVISOR_physdev_op_compat 19 278c2ecf20Sopenharmony_ci#define __HYPERVISOR_grant_table_op 20 288c2ecf20Sopenharmony_ci#define __HYPERVISOR_vm_assist 21 298c2ecf20Sopenharmony_ci#define __HYPERVISOR_update_va_mapping_otherdomain 22 308c2ecf20Sopenharmony_ci#define __HYPERVISOR_iret 23 /* x86 only */ 318c2ecf20Sopenharmony_ci#define __HYPERVISOR_vcpu_op 24 328c2ecf20Sopenharmony_ci#define __HYPERVISOR_set_segment_base 25 /* x86/64 only */ 338c2ecf20Sopenharmony_ci#define __HYPERVISOR_mmuext_op 26 348c2ecf20Sopenharmony_ci#define __HYPERVISOR_acm_op 27 358c2ecf20Sopenharmony_ci#define __HYPERVISOR_nmi_op 28 368c2ecf20Sopenharmony_ci#define __HYPERVISOR_sched_op 29 378c2ecf20Sopenharmony_ci#define __HYPERVISOR_callback_op 30 388c2ecf20Sopenharmony_ci#define __HYPERVISOR_xenoprof_op 31 398c2ecf20Sopenharmony_ci#define __HYPERVISOR_event_channel_op 32 408c2ecf20Sopenharmony_ci#define __HYPERVISOR_physdev_op 33 418c2ecf20Sopenharmony_ci#define __HYPERVISOR_hvm_op 34 428c2ecf20Sopenharmony_ci#define __HYPERVISOR_tmem_op 38 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* Architecture-specific hypercall definitions. */ 458c2ecf20Sopenharmony_ci#define __HYPERVISOR_arch_0 48 468c2ecf20Sopenharmony_ci#define __HYPERVISOR_arch_1 49 478c2ecf20Sopenharmony_ci#define __HYPERVISOR_arch_2 50 488c2ecf20Sopenharmony_ci#define __HYPERVISOR_arch_3 51 498c2ecf20Sopenharmony_ci#define __HYPERVISOR_arch_4 52 508c2ecf20Sopenharmony_ci#define __HYPERVISOR_arch_5 53 518c2ecf20Sopenharmony_ci#define __HYPERVISOR_arch_6 54 528c2ecf20Sopenharmony_ci#define __HYPERVISOR_arch_7 55 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#define N(x) [__HYPERVISOR_##x] = "("#x")" 558c2ecf20Sopenharmony_cistatic const char *xen_hypercall_names[] = { 568c2ecf20Sopenharmony_ci N(set_trap_table), 578c2ecf20Sopenharmony_ci N(mmu_update), 588c2ecf20Sopenharmony_ci N(set_gdt), 598c2ecf20Sopenharmony_ci N(stack_switch), 608c2ecf20Sopenharmony_ci N(set_callbacks), 618c2ecf20Sopenharmony_ci N(fpu_taskswitch), 628c2ecf20Sopenharmony_ci N(sched_op_compat), 638c2ecf20Sopenharmony_ci N(dom0_op), 648c2ecf20Sopenharmony_ci N(set_debugreg), 658c2ecf20Sopenharmony_ci N(get_debugreg), 668c2ecf20Sopenharmony_ci N(update_descriptor), 678c2ecf20Sopenharmony_ci N(memory_op), 688c2ecf20Sopenharmony_ci N(multicall), 698c2ecf20Sopenharmony_ci N(update_va_mapping), 708c2ecf20Sopenharmony_ci N(set_timer_op), 718c2ecf20Sopenharmony_ci N(event_channel_op_compat), 728c2ecf20Sopenharmony_ci N(xen_version), 738c2ecf20Sopenharmony_ci N(console_io), 748c2ecf20Sopenharmony_ci N(physdev_op_compat), 758c2ecf20Sopenharmony_ci N(grant_table_op), 768c2ecf20Sopenharmony_ci N(vm_assist), 778c2ecf20Sopenharmony_ci N(update_va_mapping_otherdomain), 788c2ecf20Sopenharmony_ci N(iret), 798c2ecf20Sopenharmony_ci N(vcpu_op), 808c2ecf20Sopenharmony_ci N(set_segment_base), 818c2ecf20Sopenharmony_ci N(mmuext_op), 828c2ecf20Sopenharmony_ci N(acm_op), 838c2ecf20Sopenharmony_ci N(nmi_op), 848c2ecf20Sopenharmony_ci N(sched_op), 858c2ecf20Sopenharmony_ci N(callback_op), 868c2ecf20Sopenharmony_ci N(xenoprof_op), 878c2ecf20Sopenharmony_ci N(event_channel_op), 888c2ecf20Sopenharmony_ci N(physdev_op), 898c2ecf20Sopenharmony_ci N(hvm_op), 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* Architecture-specific hypercall definitions. */ 928c2ecf20Sopenharmony_ci N(arch_0), 938c2ecf20Sopenharmony_ci N(arch_1), 948c2ecf20Sopenharmony_ci N(arch_2), 958c2ecf20Sopenharmony_ci N(arch_3), 968c2ecf20Sopenharmony_ci N(arch_4), 978c2ecf20Sopenharmony_ci N(arch_5), 988c2ecf20Sopenharmony_ci N(arch_6), 998c2ecf20Sopenharmony_ci N(arch_7), 1008c2ecf20Sopenharmony_ci}; 1018c2ecf20Sopenharmony_ci#undef N 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_cistatic const char *xen_hypercall_name(unsigned op) 1068c2ecf20Sopenharmony_ci{ 1078c2ecf20Sopenharmony_ci if (op < ARRAY_SIZE(xen_hypercall_names) && 1088c2ecf20Sopenharmony_ci xen_hypercall_names[op] != NULL) 1098c2ecf20Sopenharmony_ci return xen_hypercall_names[op]; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci return ""; 1128c2ecf20Sopenharmony_ci} 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ciunsigned long long process_xen_hypercall_name(struct trace_seq *s, 1158c2ecf20Sopenharmony_ci unsigned long long *args) 1168c2ecf20Sopenharmony_ci{ 1178c2ecf20Sopenharmony_ci unsigned int op = args[0]; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci trace_seq_printf(s, "%s", xen_hypercall_name(op)); 1208c2ecf20Sopenharmony_ci return 0; 1218c2ecf20Sopenharmony_ci} 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ciint TEP_PLUGIN_LOADER(struct tep_handle *tep) 1248c2ecf20Sopenharmony_ci{ 1258c2ecf20Sopenharmony_ci tep_register_print_function(tep, 1268c2ecf20Sopenharmony_ci process_xen_hypercall_name, 1278c2ecf20Sopenharmony_ci TEP_FUNC_ARG_STRING, 1288c2ecf20Sopenharmony_ci "xen_hypercall_name", 1298c2ecf20Sopenharmony_ci TEP_FUNC_ARG_INT, 1308c2ecf20Sopenharmony_ci TEP_FUNC_ARG_VOID); 1318c2ecf20Sopenharmony_ci return 0; 1328c2ecf20Sopenharmony_ci} 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_civoid TEP_PLUGIN_UNLOADER(struct tep_handle *tep) 1358c2ecf20Sopenharmony_ci{ 1368c2ecf20Sopenharmony_ci tep_unregister_print_function(tep, process_xen_hypercall_name, 1378c2ecf20Sopenharmony_ci "xen_hypercall_name"); 1388c2ecf20Sopenharmony_ci} 139