debuggers.hg

view xen/arch/ia64/xen/oprofile/xenoprof.c @ 22906:700ac6445812

Now add KDB to the non-kdb tree
author Mukesh Rathor
date Thu Feb 03 15:42:41 2011 -0800 (2011-02-03)
parents e88253dfefdc
children
line source
1 /******************************************************************************
2 * xenoprof.c
3 *
4 * Copyright (c) 2006 Isaku Yamahata <yamahata at valinux co jp>
5 * VA Linux Systems Japan K.K.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
23 #include <xen/config.h>
24 #include <xen/sched.h>
25 #include <public/xen.h>
26 #include <xen/xenoprof.h>
27 #include <asm/vmx.h> /* for vmx_user_mode() */
29 int
30 xenoprofile_get_mode(struct vcpu *v, struct cpu_user_regs * const regs)
31 {
32 int mode;
34 /*
35 * mode
36 * 0: user, 1: kernel, 2: xen
37 * see linux/driver/oprofile/cpu_buffer.h
38 */
39 #define CPU_MODE_USER 0
40 #define CPU_MODE_KERNEL 1
41 #define CPU_MODE_XEN 2
42 if (VMX_DOMAIN(v)) {
43 if (vmx_user_mode(regs)) {
44 switch (ring(regs)) {
45 case 3:
46 mode = CPU_MODE_USER;
47 break;
48 case 0:
49 mode = CPU_MODE_KERNEL;
50 break;
51 /* case 0: case 1: */
52 default:
53 gdprintk(XENLOG_ERR, "%s:%d ring%d in vmx is used!\n",
54 __func__, __LINE__, ring(regs));
55 mode = CPU_MODE_KERNEL; /* fall back to kernel mode. */
56 break;
57 }
58 } else {
59 mode = CPU_MODE_XEN;
60 BUG_ON(ring(regs) != 0);
61 }
62 } else {
63 switch (ring(regs)) {
64 case 3:
65 mode = CPU_MODE_USER;
66 break;
67 case CONFIG_CPL0_EMUL:
68 mode = CPU_MODE_KERNEL;
69 break;
70 case 0:
71 mode = CPU_MODE_XEN;
72 break;
73 default:
74 gdprintk(XENLOG_ERR, "%s:%d ring%d in pv is used!\n", __func__,
75 __LINE__, 3 - CONFIG_CPL0_EMUL);
76 mode = CPU_MODE_KERNEL; /* fall back to kernel mode. */
77 break;
78 }
79 }
80 return mode;
81 }
83 /*
84 * Local variables:
85 * mode: C
86 * c-set-style: "BSD"
87 * c-basic-offset: 4
88 * tab-width: 4
89 * indent-tabs-mode: nil
90 * End:
91 */