debuggers.hg

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