ia64/xen-unstable

changeset 16628:e88253dfefdc

[IA64] xenoprof: make xenoprofile_get_mode() vti domain aware

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Mon Dec 17 09:36:46 2007 -0700 (2007-12-17)
parents d3881629d572
children 9a545d45b192
files xen/arch/ia64/xen/oprofile/xenoprof.c
line diff
     1.1 --- a/xen/arch/ia64/xen/oprofile/xenoprof.c	Mon Dec 17 09:33:52 2007 -0700
     1.2 +++ b/xen/arch/ia64/xen/oprofile/xenoprof.c	Mon Dec 17 09:36:46 2007 -0700
     1.3 @@ -24,29 +24,58 @@
     1.4  #include <xen/sched.h>
     1.5  #include <public/xen.h>
     1.6  #include <xen/xenoprof.h>
     1.7 +#include <asm/vmx.h>    /* for vmx_user_mode() */
     1.8  
     1.9  int
    1.10  xenoprofile_get_mode(struct vcpu *v, struct cpu_user_regs * const regs)
    1.11  {
    1.12      int mode;
    1.13  
    1.14 -    // mode
    1.15 -    // 0: user, 1: kernel, 2: xen
    1.16 -    switch (ring(regs))
    1.17 -    {
    1.18 +    /*
    1.19 +     * mode
    1.20 +     * 0: user, 1: kernel, 2: xen
    1.21 +     * see linux/driver/oprofile/cpu_buffer.h
    1.22 +     */
    1.23 +#define CPU_MODE_USER           0
    1.24 +#define CPU_MODE_KERNEL         1
    1.25 +#define CPU_MODE_XEN            2
    1.26 +    if (VMX_DOMAIN(v)) {
    1.27 +        if (vmx_user_mode(regs)) {
    1.28 +            switch (ring(regs)) {
    1.29 +            case 3:
    1.30 +                mode = CPU_MODE_USER;
    1.31 +                break;
    1.32 +            case 0:
    1.33 +                mode = CPU_MODE_KERNEL;
    1.34 +                break;
    1.35 +            /* case 0: case 1: */
    1.36 +            default:
    1.37 +                gdprintk(XENLOG_ERR, "%s:%d ring%d in vmx is used!\n",
    1.38 +                         __func__, __LINE__, ring(regs));
    1.39 +                mode = CPU_MODE_KERNEL; /* fall back to kernel mode. */
    1.40 +                break;
    1.41 +            }
    1.42 +        } else {
    1.43 +            mode = CPU_MODE_XEN;
    1.44 +            BUG_ON(ring(regs) != 0);
    1.45 +        }
    1.46 +    } else {
    1.47 +        switch (ring(regs)) {
    1.48          case 3:
    1.49 -                mode = 0;
    1.50 -                break;
    1.51 +            mode = CPU_MODE_USER;
    1.52 +            break;
    1.53          case CONFIG_CPL0_EMUL:
    1.54 -                mode = 1;
    1.55 -                break;
    1.56 +            mode = CPU_MODE_KERNEL;
    1.57 +            break;
    1.58          case 0:
    1.59 -                mode = 2;
    1.60 -                break;
    1.61 +            mode = CPU_MODE_XEN;
    1.62 +            break;
    1.63          default:
    1.64 -                gdprintk(XENLOG_ERR, "%s:%d ring%d is used!\n", __func__,
    1.65 -                         __LINE__, 3 - CONFIG_CPL0_EMUL);
    1.66 -                mode = 1; /* fall back to kernel mode. */
    1.67 +            gdprintk(XENLOG_ERR, "%s:%d ring%d in pv is used!\n", __func__,
    1.68 +                     __LINE__, 3 - CONFIG_CPL0_EMUL);
    1.69 +            mode = CPU_MODE_KERNEL; /* fall back to kernel mode. */
    1.70 +            break;
    1.71 +        }
    1.72      }
    1.73      return mode;
    1.74  }