]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - rpmsg/rpmsg.git/blob - virt/kvm/arm/perf.c
Revert "HACK: ARM: dts: dra7-ipu-common: Revert to CMA pools for IPU early boots"
[rpmsg/rpmsg.git] / virt / kvm / arm / perf.c
1 /*
2  * Based on the x86 implementation.
3  *
4  * Copyright (C) 2012 ARM Ltd.
5  * Author: Marc Zyngier <marc.zyngier@arm.com>
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 version 2 as
9  * published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
20 #include <linux/perf_event.h>
21 #include <linux/kvm_host.h>
23 #include <asm/kvm_emulate.h>
25 static int kvm_is_in_guest(void)
26 {
27         return kvm_arm_get_running_vcpu() != NULL;
28 }
30 static int kvm_is_user_mode(void)
31 {
32         struct kvm_vcpu *vcpu;
34         vcpu = kvm_arm_get_running_vcpu();
36         if (vcpu)
37                 return !vcpu_mode_priv(vcpu);
39         return 0;
40 }
42 static unsigned long kvm_get_guest_ip(void)
43 {
44         struct kvm_vcpu *vcpu;
46         vcpu = kvm_arm_get_running_vcpu();
48         if (vcpu)
49                 return *vcpu_pc(vcpu);
51         return 0;
52 }
54 static struct perf_guest_info_callbacks kvm_guest_cbs = {
55         .is_in_guest    = kvm_is_in_guest,
56         .is_user_mode   = kvm_is_user_mode,
57         .get_guest_ip   = kvm_get_guest_ip,
58 };
60 int kvm_perf_init(void)
61 {
62         return perf_register_guest_info_callbacks(&kvm_guest_cbs);
63 }
65 int kvm_perf_teardown(void)
66 {
67         return perf_unregister_guest_info_callbacks(&kvm_guest_cbs);
68 }