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.
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.
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.
15 * Copyright IBM Corp. 2008
17 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
20 #ifndef __POWERPC_KVM_PARA_H__
21 #define __POWERPC_KVM_PARA_H__
23 #include <linux/types.h>
26 struct kvm_vcpu_arch_shared {
30 __u64 critical; /* Guest may not get interrupts if == r1 */
40 __u32 int_pending; /* Tells the guest if we have an interrupt */
43 #define KVM_SC_MAGIC_R0 0x4b564d21 /* "KVM!" */
44 #define HC_VENDOR_KVM (42 << 16)
45 #define HC_EV_SUCCESS 0
46 #define HC_EV_UNIMPLEMENTED 12
50 #ifdef CONFIG_KVM_GUEST
52 static inline int kvm_para_available(void)
54 struct device_node *hyper_node;
56 hyper_node = of_find_node_by_path("/hypervisor");
60 if (!of_device_is_compatible(hyper_node, "linux,kvm"))
66 extern unsigned long kvm_hypercall(unsigned long *in,
72 static inline int kvm_para_available(void)
77 static unsigned long kvm_hypercall(unsigned long *in,
81 return HC_EV_UNIMPLEMENTED;
86 static inline long kvm_hypercall0_1(unsigned int nr, unsigned long *r2)
92 r = kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
98 static inline long kvm_hypercall0(unsigned int nr)
101 unsigned long out[8];
103 return kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
106 static inline long kvm_hypercall1(unsigned int nr, unsigned long p1)
109 unsigned long out[8];
112 return kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
115 static inline long kvm_hypercall2(unsigned int nr, unsigned long p1,
119 unsigned long out[8];
123 return kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
126 static inline long kvm_hypercall3(unsigned int nr, unsigned long p1,
127 unsigned long p2, unsigned long p3)
130 unsigned long out[8];
135 return kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
138 static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
139 unsigned long p2, unsigned long p3,
143 unsigned long out[8];
149 return kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
153 static inline unsigned int kvm_arch_para_features(void)
157 if (!kvm_para_available())
160 if(kvm_hypercall0_1(KVM_HC_FEATURES, &r))
166 #endif /* __KERNEL__ */
168 #endif /* __POWERPC_KVM_PARA_H__ */