ia64/xen-unstable

changeset 16125:a330276d8c90

xentrace/x86: PV guest tracing extensions.
From: George Dunlap <gdunlap@xensource.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Fri Oct 12 13:06:02 2007 +0100 (2007-10-12)
parents ef4119637f52
children 1c4203730ff6
files xen/arch/x86/Makefile xen/arch/x86/mm.c xen/arch/x86/trace.c xen/arch/x86/traps.c xen/arch/x86/x86_32/entry.S xen/arch/x86/x86_64/compat/entry.S xen/arch/x86/x86_64/entry.S xen/include/asm-ia64/trace.h xen/include/asm-powerpc/trace.h xen/include/asm-x86/trace.h xen/include/public/trace.h xen/include/xen/domain.h xen/include/xen/trace.h
line diff
     1.1 --- a/xen/arch/x86/Makefile	Fri Oct 12 11:55:41 2007 +0100
     1.2 +++ b/xen/arch/x86/Makefile	Fri Oct 12 13:06:02 2007 +0100
     1.3 @@ -40,6 +40,7 @@ obj-y += srat.o
     1.4  obj-y += string.o
     1.5  obj-y += sysctl.o
     1.6  obj-y += time.o
     1.7 +obj-y += trace.o
     1.8  obj-y += traps.o
     1.9  obj-y += usercopy.o
    1.10  obj-y += x86_emulate.o
     2.1 --- a/xen/arch/x86/mm.c	Fri Oct 12 11:55:41 2007 +0100
     2.2 +++ b/xen/arch/x86/mm.c	Fri Oct 12 13:06:02 2007 +0100
     2.3 @@ -111,6 +111,7 @@
     2.4  #include <asm/shared.h>
     2.5  #include <public/memory.h>
     2.6  #include <xsm/xsm.h>
     2.7 +#include <xen/trace.h>
     2.8  
     2.9  #define MEM_LOG(_f, _a...) gdprintk(XENLOG_WARNING , _f "\n" , ## _a)
    2.10  
    2.11 @@ -3402,6 +3403,8 @@ static int ptwr_emulated_update(
    2.12              BUG();
    2.13      }
    2.14  
    2.15 +    trace_ptwr_emulation(addr, nl1e);
    2.16 +
    2.17      unmap_domain_page(pl1e);
    2.18  
    2.19      /* Finally, drop the old PTE. */
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/xen/arch/x86/trace.c	Fri Oct 12 13:06:02 2007 +0100
     3.3 @@ -0,0 +1,231 @@
     3.4 +#include <xen/config.h>
     3.5 +#include <xen/init.h>
     3.6 +#include <xen/kernel.h>
     3.7 +#include <xen/lib.h>
     3.8 +#include <xen/domain.h>
     3.9 +#include <xen/sched.h>
    3.10 +#include <xen/trace.h>
    3.11 +
    3.12 +#ifndef __x86_64__
    3.13 +#undef TRC_PV_64_FLAG
    3.14 +#define TRC_PV_64_FLAG 0
    3.15 +#endif
    3.16 +
    3.17 +asmlinkage void trace_hypercall(void)
    3.18 +{
    3.19 +    struct cpu_user_regs *regs = guest_cpu_user_regs();
    3.20 +
    3.21 +    if ( !tb_init_done )
    3.22 +        return;
    3.23 +
    3.24 +#ifdef __x86_64__
    3.25 +    if ( is_pv_32on64_vcpu(current) )
    3.26 +    {
    3.27 +        struct {
    3.28 +            u32 eip,eax;
    3.29 +        } __attribute__((packed)) d;
    3.30 +            
    3.31 +        d.eip = regs->eip;
    3.32 +        d.eax = regs->eax;
    3.33 +
    3.34 +        __trace_var(TRC_PV_HYPERCALL, 1,
    3.35 +                    sizeof(d), (unsigned char *)&d);
    3.36 +    }
    3.37 +    else
    3.38 +#endif
    3.39 +    {
    3.40 +        struct {
    3.41 +            unsigned long eip;
    3.42 +            u32 eax;
    3.43 +        } __attribute__((packed)) d;
    3.44 +        u32 event;
    3.45 +
    3.46 +        event = TRC_PV_HYPERCALL;
    3.47 +        event |= TRC_PV_64_FLAG;
    3.48 +        d.eip = regs->eip;
    3.49 +        d.eax = regs->eax;
    3.50 +
    3.51 +        __trace_var(event, 1/*tsc*/, sizeof(d), (unsigned char*)&d);
    3.52 +    }
    3.53 +}
    3.54 +
    3.55 +void __trace_pv_trap(int trapnr, unsigned long eip,
    3.56 +                     int use_error_code, unsigned error_code)
    3.57 +{
    3.58 +    if ( !tb_init_done )
    3.59 +        return;
    3.60 +
    3.61 +#ifdef __x86_64__
    3.62 +    if ( is_pv_32on64_vcpu(current) )
    3.63 +    {
    3.64 +        struct {
    3.65 +            unsigned eip:32,
    3.66 +                trapnr:15,
    3.67 +                use_error_code:1,
    3.68 +                error_code:16;
    3.69 +        } __attribute__((packed)) d;
    3.70 +
    3.71 +        d.eip = eip;
    3.72 +        d.trapnr = trapnr;
    3.73 +        d.error_code = error_code;
    3.74 +        d.use_error_code=!!use_error_code;
    3.75 +                
    3.76 +        __trace_var(TRC_PV_TRAP, 1,
    3.77 +                    sizeof(d), (unsigned char *)&d);
    3.78 +    }
    3.79 +    else
    3.80 +#endif        
    3.81 +    {
    3.82 +        struct {
    3.83 +            unsigned long eip;
    3.84 +            unsigned trapnr:15,
    3.85 +                use_error_code:1,
    3.86 +                error_code:16;
    3.87 +        } __attribute__((packed)) d;
    3.88 +        unsigned event;
    3.89 +
    3.90 +        d.eip = eip;
    3.91 +        d.trapnr = trapnr;
    3.92 +        d.error_code = error_code;
    3.93 +        d.use_error_code=!!use_error_code;
    3.94 +                
    3.95 +        event = TRC_PV_TRAP;
    3.96 +        event |= TRC_PV_64_FLAG;
    3.97 +        __trace_var(event, 1, sizeof(d), (unsigned char *)&d);
    3.98 +    }
    3.99 +}
   3.100 +
   3.101 +void __trace_pv_page_fault(unsigned long addr, unsigned error_code)
   3.102 +{
   3.103 +    unsigned long eip = guest_cpu_user_regs()->eip;
   3.104 +
   3.105 +    if ( !tb_init_done )
   3.106 +        return;
   3.107 +
   3.108 +#ifdef __x86_64__
   3.109 +    if ( is_pv_32on64_vcpu(current) )
   3.110 +    {
   3.111 +        struct {
   3.112 +            u32 eip, addr, error_code;
   3.113 +        } __attribute__((packed)) d;
   3.114 +
   3.115 +        d.eip = eip;
   3.116 +        d.addr = addr;
   3.117 +        d.error_code = error_code;
   3.118 +                
   3.119 +        __trace_var(TRC_PV_PAGE_FAULT, 1, sizeof(d), (unsigned char *)&d);
   3.120 +    }
   3.121 +    else
   3.122 +#endif        
   3.123 +    {
   3.124 +        struct {
   3.125 +            unsigned long eip, addr;
   3.126 +            u32 error_code;
   3.127 +        } __attribute__((packed)) d;
   3.128 +        unsigned event;
   3.129 +
   3.130 +        d.eip = eip;
   3.131 +        d.addr = addr;
   3.132 +        d.error_code = error_code;
   3.133 +        event = TRC_PV_PAGE_FAULT;
   3.134 +        event |= TRC_PV_64_FLAG;
   3.135 +        __trace_var(event, 1, sizeof(d), (unsigned char *)&d);
   3.136 +    }
   3.137 +}
   3.138 +
   3.139 +void __trace_trap_one_addr(unsigned event, unsigned long va)
   3.140 +{
   3.141 +    if ( !tb_init_done )
   3.142 +        return;
   3.143 +
   3.144 +#ifdef __x86_64__
   3.145 +    if ( is_pv_32on64_vcpu(current) )
   3.146 +    {
   3.147 +        u32 d = va;
   3.148 +        __trace_var(event, 1, sizeof(d), (unsigned char *)&d);
   3.149 +    }
   3.150 +    else
   3.151 +#endif        
   3.152 +    {
   3.153 +        event |= TRC_PV_64_FLAG;
   3.154 +        __trace_var(event, 1, sizeof(va), (unsigned char *)&va);
   3.155 +    }
   3.156 +}
   3.157 +
   3.158 +void __trace_trap_two_addr(unsigned event, unsigned long va1,
   3.159 +                           unsigned long va2)
   3.160 +{
   3.161 +    if ( !tb_init_done )
   3.162 +        return;
   3.163 +
   3.164 +#ifdef __x86_64__
   3.165 +    if ( is_pv_32on64_vcpu(current) )
   3.166 +    {
   3.167 +        struct {
   3.168 +            u32 va1, va2;
   3.169 +        } __attribute__((packed)) d;
   3.170 +        d.va1=va1;
   3.171 +        d.va2=va2;
   3.172 +        __trace_var(event, 1, sizeof(d), (unsigned char *)&d);
   3.173 +    }
   3.174 +    else
   3.175 +#endif        
   3.176 +    {
   3.177 +        struct {
   3.178 +            unsigned long va1, va2;
   3.179 +        } __attribute__((packed)) d;
   3.180 +        d.va1=va1;
   3.181 +        d.va2=va2;
   3.182 +        event |= TRC_PV_64_FLAG;
   3.183 +        __trace_var(event, 1, sizeof(d), (unsigned char *)&d);
   3.184 +    }
   3.185 +}
   3.186 +
   3.187 +void __trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte)
   3.188 +{
   3.189 +    unsigned long eip = guest_cpu_user_regs()->eip;
   3.190 +
   3.191 +    if ( !tb_init_done )
   3.192 +        return;
   3.193 +
   3.194 +    /* We have a couple of different modes to worry about:
   3.195 +     * - 32-on-32: 32-bit pte, 32-bit virtual addresses
   3.196 +     * - pae-on-pae, pae-on-64: 64-bit pte, 32-bit virtual addresses
   3.197 +     * - 64-on-64: 64-bit pte, 64-bit virtual addresses
   3.198 +     * pae-on-64 is the only one that requires extra code; in all other
   3.199 +     * cases, "unsigned long" is the size of a guest virtual address.
   3.200 +     */
   3.201 +
   3.202 +#ifdef __x86_64__
   3.203 +    if ( is_pv_32on64_vcpu(current) )
   3.204 +    {
   3.205 +        struct {
   3.206 +            l1_pgentry_t pte;
   3.207 +            u32 addr, eip;
   3.208 +        } __attribute__((packed)) d;
   3.209 +        d.addr = addr;
   3.210 +        d.eip = eip;
   3.211 +        d.pte = npte;
   3.212 +
   3.213 +        __trace_var(TRC_PV_PTWR_EMULATION_PAE, 1,
   3.214 +                    sizeof(d), (unsigned char *)&d);
   3.215 +    }
   3.216 +    else
   3.217 +#endif        
   3.218 +    {
   3.219 +        struct {
   3.220 +            l1_pgentry_t pte;
   3.221 +            unsigned long addr, eip;
   3.222 +        } d;
   3.223 +        unsigned event;
   3.224 +
   3.225 +        d.addr = addr;
   3.226 +        d.eip = eip;
   3.227 +        d.pte = npte;
   3.228 +
   3.229 +        event = ((CONFIG_PAGING_LEVELS == 3) ?
   3.230 +                 TRC_PV_PTWR_EMULATION_PAE : TRC_PV_PTWR_EMULATION);
   3.231 +        event |= TRC_PV_64_FLAG;
   3.232 +        __trace_var(event, 1/*tsc*/, sizeof(d), (unsigned char *)&d);
   3.233 +    }
   3.234 +}
     4.1 --- a/xen/arch/x86/traps.c	Fri Oct 12 11:55:41 2007 +0100
     4.2 +++ b/xen/arch/x86/traps.c	Fri Oct 12 13:06:02 2007 +0100
     4.3 @@ -46,6 +46,7 @@
     4.4  #include <xen/nmi.h>
     4.5  #include <xen/version.h>
     4.6  #include <xen/kexec.h>
     4.7 +#include <xen/trace.h>
     4.8  #include <asm/paging.h>
     4.9  #include <asm/system.h>
    4.10  #include <asm/io.h>
    4.11 @@ -380,6 +381,8 @@ static int do_guest_trap(
    4.12      struct trap_bounce *tb;
    4.13      const struct trap_info *ti;
    4.14  
    4.15 +    trace_pv_trap(trapnr, regs->eip, use_error_code, regs->error_code);
    4.16 +
    4.17      tb = &v->arch.trap_bounce;
    4.18      ti = &v->arch.guest_context.trap_ctxt[trapnr];
    4.19  
    4.20 @@ -633,6 +636,8 @@ static int emulate_forced_invalid_op(str
    4.21      regs->eip = eip;
    4.22      regs->eflags &= ~X86_EFLAGS_RF;
    4.23  
    4.24 +    trace_trap_one_addr(TRC_PV_FORCED_INVALID_OP, regs->eip);
    4.25 +
    4.26      return EXCRET_fault_fixed;
    4.27  }
    4.28  
    4.29 @@ -752,6 +757,8 @@ void propagate_page_fault(unsigned long 
    4.30      if ( !guest_kernel_mode(v, guest_cpu_user_regs()) )
    4.31          error_code |= PFEC_user_mode;
    4.32  
    4.33 +    trace_pv_page_fault(addr, error_code);
    4.34 +
    4.35      ti = &v->arch.guest_context.trap_ctxt[TRAP_page_fault];
    4.36      tb->flags = TBF_EXCEPTION | TBF_EXCEPTION_ERRCODE;
    4.37      tb->error_code = error_code;
    4.38 @@ -783,7 +790,13 @@ static int handle_gdt_ldt_mapping_fault(
    4.39      if ( likely(is_ldt_area) )
    4.40      {
    4.41          /* LDT fault: Copy a mapping from the guest's LDT, if it is valid. */
    4.42 -        if ( unlikely(map_ldt_shadow_page(offset >> PAGE_SHIFT) == 0) )
    4.43 +        if ( likely(map_ldt_shadow_page(offset >> PAGE_SHIFT)) )
    4.44 +        {
    4.45 +            if ( guest_mode(regs) )
    4.46 +                trace_trap_two_addr(TRC_PV_GDT_LDT_MAPPING_FAULT,
    4.47 +                                    regs->eip, offset);
    4.48 +        }
    4.49 +        else
    4.50          {
    4.51              /* In hypervisor mode? Leave it to the #PF handler to fix up. */
    4.52              if ( !guest_mode(regs) )
    4.53 @@ -939,7 +952,12 @@ static int fixup_page_fault(unsigned lon
    4.54      if ( unlikely(IN_HYPERVISOR_RANGE(addr)) )
    4.55      {
    4.56          if ( paging_mode_external(d) && guest_mode(regs) )
    4.57 -            return paging_fault(addr, regs);
    4.58 +        {
    4.59 +            int ret = paging_fault(addr, regs);
    4.60 +            if ( ret == EXCRET_fault_fixed )
    4.61 +                trace_trap_two_addr(TRC_PV_PAGING_FIXUP, regs->eip, addr);
    4.62 +            return ret;
    4.63 +        }
    4.64          if ( (addr >= GDT_LDT_VIRT_START) && (addr < GDT_LDT_VIRT_END) )
    4.65              return handle_gdt_ldt_mapping_fault(
    4.66                  addr - GDT_LDT_VIRT_START, regs);
    4.67 @@ -955,7 +973,12 @@ static int fixup_page_fault(unsigned lon
    4.68          return EXCRET_fault_fixed;
    4.69  
    4.70      if ( paging_mode_enabled(d) )
    4.71 -        return paging_fault(addr, regs);
    4.72 +    {
    4.73 +        int ret = paging_fault(addr, regs);
    4.74 +        if ( ret == EXCRET_fault_fixed )
    4.75 +            trace_trap_two_addr(TRC_PV_PAGING_FIXUP, regs->eip, addr);
    4.76 +        return ret;
    4.77 +    }
    4.78  
    4.79      return 0;
    4.80  }
    4.81 @@ -1872,13 +1895,19 @@ asmlinkage int do_general_protection(str
    4.82      /* Emulate some simple privileged and I/O instructions. */
    4.83      if ( (regs->error_code == 0) &&
    4.84           emulate_privileged_op(regs) )
    4.85 +    {
    4.86 +        trace_trap_one_addr(TRC_PV_EMULATE_PRIVOP, regs->eip);
    4.87          return 0;
    4.88 +    }
    4.89  
    4.90  #if defined(__i386__)
    4.91      if ( VM_ASSIST(v->domain, VMASST_TYPE_4gb_segments) && 
    4.92           (regs->error_code == 0) && 
    4.93           gpf_emulate_4gb(regs) )
    4.94 +    {
    4.95 +        TRACE_1D(TRC_PV_EMULATE_4GB, regs->eip);
    4.96          return 0;
    4.97 +    }
    4.98  #endif
    4.99  
   4.100      /* Pass on GPF as is. */
   4.101 @@ -2030,6 +2059,8 @@ asmlinkage int do_device_not_available(s
   4.102          do_guest_trap(TRAP_no_device, regs, 0);
   4.103          current->arch.guest_context.ctrlreg[0] &= ~X86_CR0_TS;
   4.104      }
   4.105 +    else
   4.106 +        TRACE_0D(TRC_PV_MATH_STATE_RESTORE);
   4.107  
   4.108      return EXCRET_fault_fixed;
   4.109  }
     5.1 --- a/xen/arch/x86/x86_32/entry.S	Fri Oct 12 11:55:41 2007 +0100
     5.2 +++ b/xen/arch/x86/x86_32/entry.S	Fri Oct 12 13:06:02 2007 +0100
     5.3 @@ -194,6 +194,12 @@ 1:      sti
     5.4          pushl 20(%esp) # ECX
     5.5          pushl 20(%esp) # EBX
     5.6  #endif
     5.7 +        cmpb  $0,tb_init_done
     5.8 +        je    tracing_off
     5.9 +        call  trace_hypercall
    5.10 +        /* Now restore all the registers that trace_hypercall clobbered */
    5.11 +        movl  UREGS_eax+24(%esp),%eax /* Hypercall # */
    5.12 +tracing_off:
    5.13          call *hypercall_table(,%eax,4)
    5.14          addl  $24,%esp     # Discard the shadow parameters
    5.15  #ifndef NDEBUG
     6.1 --- a/xen/arch/x86/x86_64/compat/entry.S	Fri Oct 12 11:55:41 2007 +0100
     6.2 +++ b/xen/arch/x86/x86_64/compat/entry.S	Fri Oct 12 13:06:02 2007 +0100
     6.3 @@ -56,6 +56,18 @@ ENTRY(compat_hypercall)
     6.4          movl  %ebp,%r9d              /* Arg 6        */
     6.5          movl  UREGS_rbx(%rsp),%edi   /* Arg 1        */
     6.6  #endif
     6.7 +        cmpb  $0,tb_init_done(%rip)
     6.8 +        je    compat_tracing_off
     6.9 +        call  trace_hypercall
    6.10 +        /* Now restore all the registers that trace_hypercall clobbered */
    6.11 +        movl  UREGS_rax(%rsp),%eax   /* Hypercall #  */
    6.12 +        movl  UREGS_rbx(%rsp),%edi   /* Arg 1        */
    6.13 +        movl  UREGS_rcx(%rsp),%esi   /* Arg 2        */
    6.14 +        movl  UREGS_rdx(%rsp),%edx   /* Arg 3        */
    6.15 +        movl  UREGS_rsi(%rsp),%ecx   /* Arg 4        */
    6.16 +        movl  UREGS_rdi(%rsp),%r8d   /* Arg 5        */
    6.17 +        movl  UREGS_rbp(%rsp),%r9d   /* Arg 6        */
    6.18 +compat_tracing_off:
    6.19          leaq  compat_hypercall_table(%rip),%r10
    6.20          PERFC_INCR(PERFC_hypercalls, %rax, %rbx)
    6.21          callq *(%r10,%rax,8)
     7.1 --- a/xen/arch/x86/x86_64/entry.S	Fri Oct 12 11:55:41 2007 +0100
     7.2 +++ b/xen/arch/x86/x86_64/entry.S	Fri Oct 12 13:06:02 2007 +0100
     7.3 @@ -148,6 +148,18 @@ ENTRY(syscall_enter)
     7.4          pushq %rax
     7.5          pushq UREGS_rip+8(%rsp)
     7.6  #endif
     7.7 +        cmpb  $0,tb_init_done(%rip)
     7.8 +        je    tracing_off
     7.9 +        call  trace_hypercall
    7.10 +        /* Now restore all the registers that trace_hypercall clobbered */
    7.11 +        movq  UREGS_rax(%rsp),%rax   /* Hypercall #  */
    7.12 +        movq  UREGS_rdi(%rsp),%rdi   /* Arg 1        */
    7.13 +        movq  UREGS_rsi(%rsp),%rsi   /* Arg 2        */
    7.14 +        movq  UREGS_rdx(%rsp),%rdx   /* Arg 3        */
    7.15 +        movq  UREGS_r10(%rsp),%rcx   /* Arg 4        */
    7.16 +        movq  UREGS_rdi(%rsp),%r8    /* Arg 5        */
    7.17 +        movq  UREGS_rbp(%rsp),%r9    /* Arg 6        */
    7.18 +tracing_off:
    7.19          leaq  hypercall_table(%rip),%r10
    7.20          PERFC_INCR(PERFC_hypercalls, %rax, %rbx)
    7.21          callq *(%r10,%rax,8)
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/xen/include/asm-ia64/trace.h	Fri Oct 12 13:06:02 2007 +0100
     8.3 @@ -0,0 +1,4 @@
     8.4 +#ifndef __ASM_TRACE_H__
     8.5 +#define __ASM_TRACE_H__
     8.6 +
     8.7 +#endif /* __ASM_TRACE_H__ */
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/xen/include/asm-powerpc/trace.h	Fri Oct 12 13:06:02 2007 +0100
     9.3 @@ -0,0 +1,4 @@
     9.4 +#ifndef __ASM_TRACE_H__
     9.5 +#define __ASM_TRACE_H__
     9.6 +
     9.7 +#endif /* __ASM_TRACE_H__ */
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/xen/include/asm-x86/trace.h	Fri Oct 12 13:06:02 2007 +0100
    10.3 @@ -0,0 +1,46 @@
    10.4 +#ifndef __ASM_TRACE_H__
    10.5 +#define __ASM_TRACE_H__
    10.6 +
    10.7 +#include <asm/page.h>
    10.8 +
    10.9 +void __trace_pv_trap(int trapnr, unsigned long eip,
   10.10 +                     int use_error_code, unsigned error_code);
   10.11 +static inline void trace_pv_trap(int trapnr, unsigned long eip,
   10.12 +                                 int use_error_code, unsigned error_code)
   10.13 +{
   10.14 +    if ( tb_init_done )
   10.15 +        __trace_pv_trap(trapnr, eip, use_error_code, error_code);
   10.16 +}
   10.17 +
   10.18 +void __trace_pv_page_fault(unsigned long addr, unsigned error_code);
   10.19 +static inline void trace_pv_page_fault(unsigned long addr,
   10.20 +                                       unsigned error_code)
   10.21 +{
   10.22 +    if ( tb_init_done )
   10.23 +        __trace_pv_page_fault(addr, error_code);
   10.24 +}
   10.25 +
   10.26 +void __trace_trap_one_addr(unsigned event, unsigned long va);
   10.27 +static inline void trace_trap_one_addr(unsigned event, unsigned long va)
   10.28 +{
   10.29 +    if ( tb_init_done )
   10.30 +        __trace_trap_one_addr(event, va);
   10.31 +}
   10.32 +
   10.33 +void __trace_trap_two_addr(unsigned event, unsigned long va1,
   10.34 +                           unsigned long va2);
   10.35 +static inline void trace_trap_two_addr(unsigned event, unsigned long va1,
   10.36 +                                       unsigned long va2)
   10.37 +{
   10.38 +    if ( tb_init_done )
   10.39 +        __trace_trap_two_addr(event, va1, va2);
   10.40 +}
   10.41 +
   10.42 +void __trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte);
   10.43 +static inline void trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte)
   10.44 +{
   10.45 +    if ( tb_init_done )
   10.46 +        __trace_ptwr_emulation(addr, npte);
   10.47 +}
   10.48 +
   10.49 +#endif /* __ASM_TRACE_H__ */
    11.1 --- a/xen/include/public/trace.h	Fri Oct 12 11:55:41 2007 +0100
    11.2 +++ b/xen/include/public/trace.h	Fri Oct 12 13:06:02 2007 +0100
    11.3 @@ -36,6 +36,7 @@
    11.4  #define TRC_DOM0OP   0x0004f000    /* Xen DOM0 operation trace */
    11.5  #define TRC_HVM      0x0008f000    /* Xen HVM trace            */
    11.6  #define TRC_MEM      0x0010f000    /* Xen memory trace         */
    11.7 +#define TRC_PV       0x0020f000    /* Xen PV traces            */
    11.8  #define TRC_ALL      0x0ffff000
    11.9  #define TRC_HD_TO_EVENT(x) ((x)&0x0fffffff)
   11.10  #define TRC_HD_CYCLE_FLAG (1UL<<31)
   11.11 @@ -74,6 +75,20 @@
   11.12  #define TRC_MEM_PAGE_GRANT_UNMAP    (TRC_MEM + 2)
   11.13  #define TRC_MEM_PAGE_GRANT_TRANSFER (TRC_MEM + 3)
   11.14  
   11.15 +#define TRC_PV_HYPERCALL             (TRC_PV +  1)
   11.16 +#define TRC_PV_TRAP                  (TRC_PV +  3)
   11.17 +#define TRC_PV_PAGE_FAULT            (TRC_PV +  4)
   11.18 +#define TRC_PV_FORCED_INVALID_OP     (TRC_PV +  5)
   11.19 +#define TRC_PV_EMULATE_PRIVOP        (TRC_PV +  6)
   11.20 +#define TRC_PV_EMULATE_4GB           (TRC_PV +  7)
   11.21 +#define TRC_PV_MATH_STATE_RESTORE    (TRC_PV +  8)
   11.22 +#define TRC_PV_PAGING_FIXUP          (TRC_PV +  9)
   11.23 +#define TRC_PV_GDT_LDT_MAPPING_FAULT (TRC_PV + 10)
   11.24 +#define TRC_PV_PTWR_EMULATION        (TRC_PV + 11)
   11.25 +#define TRC_PV_PTWR_EMULATION_PAE    (TRC_PV + 12)
   11.26 +  /* Indicates that addresses in trace record are 64 bits */
   11.27 +#define TRC_PV_64_FLAG               (0x100) 
   11.28 +
   11.29  /* trace events per subclass */
   11.30  #define TRC_HVM_VMENTRY         (TRC_HVM_ENTRYEXIT + 0x01)
   11.31  #define TRC_HVM_VMEXIT          (TRC_HVM_ENTRYEXIT + 0x02)
    12.1 --- a/xen/include/xen/domain.h	Fri Oct 12 11:55:41 2007 +0100
    12.2 +++ b/xen/include/xen/domain.h	Fri Oct 12 13:06:02 2007 +0100
    12.3 @@ -2,6 +2,8 @@
    12.4  #ifndef __XEN_DOMAIN_H__
    12.5  #define __XEN_DOMAIN_H__
    12.6  
    12.7 +#include <public/xen.h>
    12.8 +
    12.9  typedef union {
   12.10      struct vcpu_guest_context *nat;
   12.11      struct compat_vcpu_guest_context *cmp;
    13.1 --- a/xen/include/xen/trace.h	Fri Oct 12 11:55:41 2007 +0100
    13.2 +++ b/xen/include/xen/trace.h	Fri Oct 12 13:06:02 2007 +0100
    13.3 @@ -21,11 +21,12 @@
    13.4  #ifndef __XEN_TRACE_H__
    13.5  #define __XEN_TRACE_H__
    13.6  
    13.7 +extern int tb_init_done;
    13.8 +
    13.9  #include <xen/config.h>
   13.10  #include <public/sysctl.h>
   13.11  #include <public/trace.h>
   13.12 -
   13.13 -extern int tb_init_done;
   13.14 +#include <asm/trace.h>
   13.15  
   13.16  /* Used to initialise trace buffer functionality */
   13.17  void init_trace_bufs(void);