]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - arch/powerpc/include/asm/kvm_para.h
kvm/powerpc: rename kvm_hypercall() to epapr_hypercall()
[karo-tx-linux.git] / arch / powerpc / include / asm / kvm_para.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License, version 2, as
4  * published by the Free Software Foundation.
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9  * GNU General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public License
12  * along with this program; if not, write to the Free Software
13  * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
14  *
15  * Copyright IBM Corp. 2008
16  *
17  * Authors: Hollis Blanchard <hollisb@us.ibm.com>
18  */
19 #ifndef __POWERPC_KVM_PARA_H__
20 #define __POWERPC_KVM_PARA_H__
21
22 #include <uapi/asm/kvm_para.h>
23
24 #ifdef CONFIG_KVM_GUEST
25
26 #include <linux/of.h>
27
28 static inline int kvm_para_available(void)
29 {
30         struct device_node *hyper_node;
31
32         hyper_node = of_find_node_by_path("/hypervisor");
33         if (!hyper_node)
34                 return 0;
35
36         if (!of_device_is_compatible(hyper_node, "linux,kvm"))
37                 return 0;
38
39         return 1;
40 }
41
42 #else
43
44 static inline int kvm_para_available(void)
45 {
46         return 0;
47 }
48
49 #endif
50
51 static inline long kvm_hypercall0_1(unsigned int nr, unsigned long *r2)
52 {
53         unsigned long in[8];
54         unsigned long out[8];
55         unsigned long r;
56
57         r = epapr_hypercall(in, out, KVM_HCALL_TOKEN(nr));
58         *r2 = out[0];
59
60         return r;
61 }
62
63 static inline long kvm_hypercall0(unsigned int nr)
64 {
65         unsigned long in[8];
66         unsigned long out[8];
67
68         return epapr_hypercall(in, out, KVM_HCALL_TOKEN(nr));
69 }
70
71 static inline long kvm_hypercall1(unsigned int nr, unsigned long p1)
72 {
73         unsigned long in[8];
74         unsigned long out[8];
75
76         in[0] = p1;
77         return epapr_hypercall(in, out, KVM_HCALL_TOKEN(nr));
78 }
79
80 static inline long kvm_hypercall2(unsigned int nr, unsigned long p1,
81                                   unsigned long p2)
82 {
83         unsigned long in[8];
84         unsigned long out[8];
85
86         in[0] = p1;
87         in[1] = p2;
88         return epapr_hypercall(in, out, KVM_HCALL_TOKEN(nr));
89 }
90
91 static inline long kvm_hypercall3(unsigned int nr, unsigned long p1,
92                                   unsigned long p2, unsigned long p3)
93 {
94         unsigned long in[8];
95         unsigned long out[8];
96
97         in[0] = p1;
98         in[1] = p2;
99         in[2] = p3;
100         return epapr_hypercall(in, out, KVM_HCALL_TOKEN(nr));
101 }
102
103 static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
104                                   unsigned long p2, unsigned long p3,
105                                   unsigned long p4)
106 {
107         unsigned long in[8];
108         unsigned long out[8];
109
110         in[0] = p1;
111         in[1] = p2;
112         in[2] = p3;
113         in[3] = p4;
114         return epapr_hypercall(in, out, KVM_HCALL_TOKEN(nr));
115 }
116
117
118 static inline unsigned int kvm_arch_para_features(void)
119 {
120         unsigned long r;
121
122         if (!kvm_para_available())
123                 return 0;
124
125         if(kvm_hypercall0_1(KVM_HC_FEATURES, &r))
126                 return 0;
127
128         return r;
129 }
130
131 static inline bool kvm_check_and_clear_guest_paused(void)
132 {
133         return false;
134 }
135
136 #endif /* __POWERPC_KVM_PARA_H__ */