GNU Linux-libre 5.4.274-gnu1
[releases.git] / arch / powerpc / include / asm / kvm_para.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  *
4  * Copyright IBM Corp. 2008
5  *
6  * Authors: Hollis Blanchard <hollisb@us.ibm.com>
7  */
8 #ifndef __POWERPC_KVM_PARA_H__
9 #define __POWERPC_KVM_PARA_H__
10
11 #include <uapi/asm/kvm_para.h>
12
13 #ifdef CONFIG_KVM_GUEST
14
15 #include <linux/of.h>
16
17 static inline int kvm_para_available(void)
18 {
19         struct device_node *hyper_node;
20
21         hyper_node = of_find_node_by_path("/hypervisor");
22         if (!hyper_node)
23                 return 0;
24
25         if (!of_device_is_compatible(hyper_node, "linux,kvm"))
26                 return 0;
27
28         return 1;
29 }
30
31 #else
32
33 static inline int kvm_para_available(void)
34 {
35         return 0;
36 }
37
38 #endif
39
40 static inline unsigned int kvm_arch_para_features(void)
41 {
42         unsigned long r;
43
44         if (!kvm_para_available())
45                 return 0;
46
47         if(epapr_hypercall0_1(KVM_HCALL_TOKEN(KVM_HC_FEATURES), &r))
48                 return 0;
49
50         return r;
51 }
52
53 static inline unsigned int kvm_arch_para_hints(void)
54 {
55         return 0;
56 }
57
58 static inline bool kvm_check_and_clear_guest_paused(void)
59 {
60         return false;
61 }
62
63 #endif /* __POWERPC_KVM_PARA_H__ */