1*3a9fd824SRoger Pau Monné /****************************************************************************** 2*3a9fd824SRoger Pau Monné * xenoprof.h 3*3a9fd824SRoger Pau Monné * 4*3a9fd824SRoger Pau Monné * Interface for enabling system wide profiling based on hardware performance 5*3a9fd824SRoger Pau Monné * counters 6*3a9fd824SRoger Pau Monné * 7*3a9fd824SRoger Pau Monné * Permission is hereby granted, free of charge, to any person obtaining a copy 8*3a9fd824SRoger Pau Monné * of this software and associated documentation files (the "Software"), to 9*3a9fd824SRoger Pau Monné * deal in the Software without restriction, including without limitation the 10*3a9fd824SRoger Pau Monné * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11*3a9fd824SRoger Pau Monné * sell copies of the Software, and to permit persons to whom the Software is 12*3a9fd824SRoger Pau Monné * furnished to do so, subject to the following conditions: 13*3a9fd824SRoger Pau Monné * 14*3a9fd824SRoger Pau Monné * The above copyright notice and this permission notice shall be included in 15*3a9fd824SRoger Pau Monné * all copies or substantial portions of the Software. 16*3a9fd824SRoger Pau Monné * 17*3a9fd824SRoger Pau Monné * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18*3a9fd824SRoger Pau Monné * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19*3a9fd824SRoger Pau Monné * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20*3a9fd824SRoger Pau Monné * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21*3a9fd824SRoger Pau Monné * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22*3a9fd824SRoger Pau Monné * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23*3a9fd824SRoger Pau Monné * DEALINGS IN THE SOFTWARE. 24*3a9fd824SRoger Pau Monné * 25*3a9fd824SRoger Pau Monné * Copyright (C) 2005 Hewlett-Packard Co. 26*3a9fd824SRoger Pau Monné * Written by Aravind Menon & Jose Renato Santos 27*3a9fd824SRoger Pau Monné */ 28*3a9fd824SRoger Pau Monné 29*3a9fd824SRoger Pau Monné #ifndef __XEN_PUBLIC_XENOPROF_H__ 30*3a9fd824SRoger Pau Monné #define __XEN_PUBLIC_XENOPROF_H__ 31*3a9fd824SRoger Pau Monné 32*3a9fd824SRoger Pau Monné #include "xen.h" 33*3a9fd824SRoger Pau Monné 34*3a9fd824SRoger Pau Monné /* 35*3a9fd824SRoger Pau Monné * Commands to HYPERVISOR_xenoprof_op(). 36*3a9fd824SRoger Pau Monné */ 37*3a9fd824SRoger Pau Monné #define XENOPROF_init 0 38*3a9fd824SRoger Pau Monné #define XENOPROF_reset_active_list 1 39*3a9fd824SRoger Pau Monné #define XENOPROF_reset_passive_list 2 40*3a9fd824SRoger Pau Monné #define XENOPROF_set_active 3 41*3a9fd824SRoger Pau Monné #define XENOPROF_set_passive 4 42*3a9fd824SRoger Pau Monné #define XENOPROF_reserve_counters 5 43*3a9fd824SRoger Pau Monné #define XENOPROF_counter 6 44*3a9fd824SRoger Pau Monné #define XENOPROF_setup_events 7 45*3a9fd824SRoger Pau Monné #define XENOPROF_enable_virq 8 46*3a9fd824SRoger Pau Monné #define XENOPROF_start 9 47*3a9fd824SRoger Pau Monné #define XENOPROF_stop 10 48*3a9fd824SRoger Pau Monné #define XENOPROF_disable_virq 11 49*3a9fd824SRoger Pau Monné #define XENOPROF_release_counters 12 50*3a9fd824SRoger Pau Monné #define XENOPROF_shutdown 13 51*3a9fd824SRoger Pau Monné #define XENOPROF_get_buffer 14 52*3a9fd824SRoger Pau Monné #define XENOPROF_set_backtrace 15 53*3a9fd824SRoger Pau Monné 54*3a9fd824SRoger Pau Monné /* AMD IBS support */ 55*3a9fd824SRoger Pau Monné #define XENOPROF_get_ibs_caps 16 56*3a9fd824SRoger Pau Monné #define XENOPROF_ibs_counter 17 57*3a9fd824SRoger Pau Monné #define XENOPROF_last_op 17 58*3a9fd824SRoger Pau Monné 59*3a9fd824SRoger Pau Monné #define MAX_OPROF_EVENTS 32 60*3a9fd824SRoger Pau Monné #define MAX_OPROF_DOMAINS 25 61*3a9fd824SRoger Pau Monné #define XENOPROF_CPU_TYPE_SIZE 64 62*3a9fd824SRoger Pau Monné 63*3a9fd824SRoger Pau Monné /* Xenoprof performance events (not Xen events) */ 64*3a9fd824SRoger Pau Monné struct event_log { 65*3a9fd824SRoger Pau Monné uint64_t eip; 66*3a9fd824SRoger Pau Monné uint8_t mode; 67*3a9fd824SRoger Pau Monné uint8_t event; 68*3a9fd824SRoger Pau Monné }; 69*3a9fd824SRoger Pau Monné 70*3a9fd824SRoger Pau Monné /* PC value that indicates a special code */ 71*3a9fd824SRoger Pau Monné #define XENOPROF_ESCAPE_CODE (~xen_mk_ullong(0)) 72*3a9fd824SRoger Pau Monné /* Transient events for the xenoprof->oprofile cpu buf */ 73*3a9fd824SRoger Pau Monné #define XENOPROF_TRACE_BEGIN 1 74*3a9fd824SRoger Pau Monné 75*3a9fd824SRoger Pau Monné /* Xenoprof buffer shared between Xen and domain - 1 per VCPU */ 76*3a9fd824SRoger Pau Monné struct xenoprof_buf { 77*3a9fd824SRoger Pau Monné uint32_t event_head; 78*3a9fd824SRoger Pau Monné uint32_t event_tail; 79*3a9fd824SRoger Pau Monné uint32_t event_size; 80*3a9fd824SRoger Pau Monné uint32_t vcpu_id; 81*3a9fd824SRoger Pau Monné uint64_t xen_samples; 82*3a9fd824SRoger Pau Monné uint64_t kernel_samples; 83*3a9fd824SRoger Pau Monné uint64_t user_samples; 84*3a9fd824SRoger Pau Monné uint64_t lost_samples; 85*3a9fd824SRoger Pau Monné struct event_log event_log[1]; 86*3a9fd824SRoger Pau Monné }; 87*3a9fd824SRoger Pau Monné #ifndef __XEN__ 88*3a9fd824SRoger Pau Monné typedef struct xenoprof_buf xenoprof_buf_t; 89*3a9fd824SRoger Pau Monné DEFINE_XEN_GUEST_HANDLE(xenoprof_buf_t); 90*3a9fd824SRoger Pau Monné #endif 91*3a9fd824SRoger Pau Monné 92*3a9fd824SRoger Pau Monné struct xenoprof_init { 93*3a9fd824SRoger Pau Monné int32_t num_events; 94*3a9fd824SRoger Pau Monné int32_t is_primary; 95*3a9fd824SRoger Pau Monné char cpu_type[XENOPROF_CPU_TYPE_SIZE]; 96*3a9fd824SRoger Pau Monné }; 97*3a9fd824SRoger Pau Monné typedef struct xenoprof_init xenoprof_init_t; 98*3a9fd824SRoger Pau Monné DEFINE_XEN_GUEST_HANDLE(xenoprof_init_t); 99*3a9fd824SRoger Pau Monné 100*3a9fd824SRoger Pau Monné struct xenoprof_get_buffer { 101*3a9fd824SRoger Pau Monné int32_t max_samples; 102*3a9fd824SRoger Pau Monné int32_t nbuf; 103*3a9fd824SRoger Pau Monné int32_t bufsize; 104*3a9fd824SRoger Pau Monné uint64_t buf_gmaddr; 105*3a9fd824SRoger Pau Monné }; 106*3a9fd824SRoger Pau Monné typedef struct xenoprof_get_buffer xenoprof_get_buffer_t; 107*3a9fd824SRoger Pau Monné DEFINE_XEN_GUEST_HANDLE(xenoprof_get_buffer_t); 108*3a9fd824SRoger Pau Monné 109*3a9fd824SRoger Pau Monné struct xenoprof_counter { 110*3a9fd824SRoger Pau Monné uint32_t ind; 111*3a9fd824SRoger Pau Monné uint64_t count; 112*3a9fd824SRoger Pau Monné uint32_t enabled; 113*3a9fd824SRoger Pau Monné uint32_t event; 114*3a9fd824SRoger Pau Monné uint32_t hypervisor; 115*3a9fd824SRoger Pau Monné uint32_t kernel; 116*3a9fd824SRoger Pau Monné uint32_t user; 117*3a9fd824SRoger Pau Monné uint64_t unit_mask; 118*3a9fd824SRoger Pau Monné }; 119*3a9fd824SRoger Pau Monné typedef struct xenoprof_counter xenoprof_counter_t; 120*3a9fd824SRoger Pau Monné DEFINE_XEN_GUEST_HANDLE(xenoprof_counter_t); 121*3a9fd824SRoger Pau Monné 122*3a9fd824SRoger Pau Monné typedef struct xenoprof_passive { 123*3a9fd824SRoger Pau Monné uint16_t domain_id; 124*3a9fd824SRoger Pau Monné int32_t max_samples; 125*3a9fd824SRoger Pau Monné int32_t nbuf; 126*3a9fd824SRoger Pau Monné int32_t bufsize; 127*3a9fd824SRoger Pau Monné uint64_t buf_gmaddr; 128*3a9fd824SRoger Pau Monné } xenoprof_passive_t; 129*3a9fd824SRoger Pau Monné DEFINE_XEN_GUEST_HANDLE(xenoprof_passive_t); 130*3a9fd824SRoger Pau Monné 131*3a9fd824SRoger Pau Monné struct xenoprof_ibs_counter { 132*3a9fd824SRoger Pau Monné uint64_t op_enabled; 133*3a9fd824SRoger Pau Monné uint64_t fetch_enabled; 134*3a9fd824SRoger Pau Monné uint64_t max_cnt_fetch; 135*3a9fd824SRoger Pau Monné uint64_t max_cnt_op; 136*3a9fd824SRoger Pau Monné uint64_t rand_en; 137*3a9fd824SRoger Pau Monné uint64_t dispatched_ops; 138*3a9fd824SRoger Pau Monné }; 139*3a9fd824SRoger Pau Monné typedef struct xenoprof_ibs_counter xenoprof_ibs_counter_t; 140*3a9fd824SRoger Pau Monné DEFINE_XEN_GUEST_HANDLE(xenoprof_ibs_counter_t); 141*3a9fd824SRoger Pau Monné 142*3a9fd824SRoger Pau Monné #endif /* __XEN_PUBLIC_XENOPROF_H__ */ 143*3a9fd824SRoger Pau Monné 144*3a9fd824SRoger Pau Monné /* 145*3a9fd824SRoger Pau Monné * Local variables: 146*3a9fd824SRoger Pau Monné * mode: C 147*3a9fd824SRoger Pau Monné * c-file-style: "BSD" 148*3a9fd824SRoger Pau Monné * c-basic-offset: 4 149*3a9fd824SRoger Pau Monné * tab-width: 4 150*3a9fd824SRoger Pau Monné * indent-tabs-mode: nil 151*3a9fd824SRoger Pau Monné * End: 152*3a9fd824SRoger Pau Monné */ 153