blob: 9c1f6b4b9bbf478cd45645f97f8aaa09731338b2 [file] [log] [blame]
Thomas Gleixnerd94d71c2019-05-29 07:12:40 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -05002/*
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -05003 *
4 * Copyright IBM Corp. 2008
5 *
6 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
7 */
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -05008#ifndef __POWERPC_KVM_PARA_H__
9#define __POWERPC_KVM_PARA_H__
10
David Howellsc3617f72012-10-09 09:47:26 +010011#include <uapi/asm/kvm_para.h>
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -050012
Alexander Graf2a342ed2010-07-29 14:47:48 +020013#ifdef CONFIG_KVM_GUEST
14
Alexander Graf26e673c2010-09-03 10:22:19 +020015#include <linux/of.h>
16
Alexander Graf2a342ed2010-07-29 14:47:48 +020017static 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
Alexander Graf2a342ed2010-07-29 14:47:48 +020031#else
32
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -050033static inline int kvm_para_available(void)
34{
35 return 0;
36}
37
Alexander Graf2a342ed2010-07-29 14:47:48 +020038#endif
39
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -050040static inline unsigned int kvm_arch_para_features(void)
41{
Alexander Graf2a342ed2010-07-29 14:47:48 +020042 unsigned long r;
43
44 if (!kvm_para_available())
45 return 0;
46
Bharat Bhushanb1f0d942013-10-08 09:32:20 +053047 if(epapr_hypercall0_1(KVM_HCALL_TOKEN(KVM_HC_FEATURES), &r))
Alexander Graf2a342ed2010-07-29 14:47:48 +020048 return 0;
49
50 return r;
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -050051}
52
Wanpeng Lia4429e52018-02-13 09:05:40 +080053static inline unsigned int kvm_arch_para_hints(void)
54{
55 return 0;
56}
57
Eric B Munson3b5d56b2012-03-10 14:37:26 -050058static inline bool kvm_check_and_clear_guest_paused(void)
59{
60 return false;
61}
62
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -050063#endif /* __POWERPC_KVM_PARA_H__ */