aboutsummaryrefslogtreecommitdiffstats
path: root/package/qos-scripts/files/usr/bin
ModeNameSize
-rwxr-xr-xqos-start55logstatsplain
-rwxr-xr-xqos-stat401logstatsplain
-rwxr-xr-xqos-stop156logstatsplain
'>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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
#include <xen/config.h>
#include <xen/init.h>
#include <xen/kernel.h>
#include <xen/lib.h>
#include <xen/domain.h>
#include <xen/sched.h>
#include <xen/trace.h>

#ifndef __x86_64__
#undef TRC_PV_64_FLAG
#define TRC_PV_64_FLAG 0
#endif

asmlinkage void trace_hypercall(void)
{
    struct cpu_user_regs *regs = guest_cpu_user_regs();

    if ( !tb_init_done )
        return;

#ifdef __x86_64__
    if ( is_pv_32on64_vcpu(current) )
    {
        struct {
            u32 eip,eax;
        } __attribute__((packed)) d;
            
        d.eip = regs->eip;
        d.eax = regs->eax;

        __trace_var(TRC_PV_HYPERCALL, 1,
                    sizeof(d), (unsigned char *)&d);
    }
    else
#endif
    {
        struct {
            unsigned long eip;
            u32 eax;
        } __attribute__((packed)) d;
        u32 event;

        event = TRC_PV_HYPERCALL;
        event |= TRC_PV_64_FLAG;
        d.eip = regs->eip;
        d.eax = regs->eax;

        __trace_var(event, 1/*tsc*/, sizeof(d), (unsigned char*)&d);
    }
}

void __trace_pv_trap(int trapnr, unsigned long eip,
                     int use_error_code, unsigned error_code)
{
    if ( !tb_init_done )
        return;

#ifdef __x86_64__
    if ( is_pv_32on64_vcpu(current) )
    {
        struct {
            unsigned eip:32,
                trapnr:15,
                use_error_code:1,
                error_code:16;
        } __attribute__((packed)) d;

        d.eip = eip;
        d.trapnr = trapnr;
        d.error_code = error_code;
        d.use_error_code=!!use_error_code;
                
        __trace_var(TRC_PV_TRAP, 1,
                    sizeof(d), (unsigned char *)&d);
    }
    else
#endif        
    {
        struct {
            unsigned long eip;
            unsigned trapnr:15,
                use_error_code:1,
                error_code:16;
        } __attribute__((packed)) d;
        unsigned event;

        d.eip = eip;
        d.trapnr = trapnr;
        d.error_code = error_code;
        d.use_error_code=!!use_error_code;
                
        event = TRC_PV_TRAP;
        event |= TRC_PV_64_FLAG;
        __trace_var(event, 1, sizeof(d), (unsigned char *)&d);
    }
}

void __trace_pv_page_fault(unsigned long addr, unsigned error_code)
{
    unsigned long eip = guest_cpu_user_regs()->eip;

    if ( !tb_init_done )
        return;

#ifdef __x86_64__
    if ( is_pv_32on64_vcpu(current) )
    {
        struct {
            u32 eip, addr, error_code;
        } __attribute__((packed)) d;

        d.eip = eip;
        d.addr = addr;
        d.error_code = error_code;
                
        __trace_var(TRC_PV_PAGE_FAULT, 1, sizeof(d), (unsigned char *)&d);
    }
    else
#endif        
    {
        struct {
            unsigned long eip, addr;
            u32 error_code;
        } __attribute__((packed)) d;
        unsigned event;

        d.eip = eip;
        d.addr = addr;
        d.error_code = error_code;
        event = TRC_PV_PAGE_FAULT;
        event |= TRC_PV_64_FLAG;
        __trace_var(event, 1, sizeof(d), (unsigned char *)&d);
    }
}

void __trace_trap_one_addr(unsigned event, unsigned long va)
{
    if ( !tb_init_done )
        return;

#ifdef __x86_64__
    if ( is_pv_32on64_vcpu(current) )
    {
        u32 d = va;
        __trace_var(event, 1, sizeof(d), (unsigned char *)&d);
    }
    else
#endif        
    {
        event |= TRC_PV_64_FLAG;
        __trace_var(event, 1, sizeof(va), (unsigned char *)&va);
    }
}

void __trace_trap_two_addr(unsigned event, unsigned long va1,
                           unsigned long va2)
{
    if ( !tb_init_done )
        return;

#ifdef __x86_64__
    if ( is_pv_32on64_vcpu(current) )
    {
        struct {
            u32 va1, va2;
        } __attribute__((packed)) d;
        d.va1=va1;
        d.va2=va2;
        __trace_var(event, 1, sizeof(d), (unsigned char *)&d);
    }
    else
#endif        
    {
        struct {
            unsigned long va1, va2;
        } __attribute__((packed)) d;
        d.va1=va1;
        d.va2=va2;
        event |= TRC_PV_64_FLAG;
        __trace_var(event, 1, sizeof(d), (unsigned char *)&d);
    }
}

void __trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte)
{
    unsigned long eip = guest_cpu_user_regs()->eip;

    if ( !tb_init_done )
        return;

    /* We have a couple of different modes to worry about:
     * - 32-on-32: 32-bit pte, 32-bit virtual addresses
     * - pae-on-pae, pae-on-64: 64-bit pte, 32-bit virtual addresses
     * - 64-on-64: 64-bit pte, 64-bit virtual addresses
     * pae-on-64 is the only one that requires extra code; in all other
     * cases, "unsigned long" is the size of a guest virtual address.
     */

#ifdef __x86_64__
    if ( is_pv_32on64_vcpu(current) )
    {
        struct {
            l1_pgentry_t pte;
            u32 addr, eip;
        } __attribute__((packed)) d;
        d.addr = addr;
        d.eip = eip;
        d.pte = npte;

        __trace_var(TRC_PV_PTWR_EMULATION_PAE, 1,
                    sizeof(d), (unsigned char *)&d);
    }
    else
#endif        
    {
        struct {
            l1_pgentry_t pte;
            unsigned long addr, eip;
        } d;
        unsigned event;

        d.addr = addr;
        d.eip = eip;
        d.pte = npte;

        event = ((CONFIG_PAGING_LEVELS == 3) ?
                 TRC_PV_PTWR_EMULATION_PAE : TRC_PV_PTWR_EMULATION);
        event |= TRC_PV_64_FLAG;
        __trace_var(event, 1/*tsc*/, sizeof(d), (unsigned char *)&d);
    }
}