1b8b572e1SStephen Rothwell /*
2b8b572e1SStephen Rothwell  * This program is free software; you can redistribute it and/or modify
3b8b572e1SStephen Rothwell  * it under the terms of the GNU General Public License, version 2, as
4b8b572e1SStephen Rothwell  * published by the Free Software Foundation.
5b8b572e1SStephen Rothwell  *
6b8b572e1SStephen Rothwell  * This program is distributed in the hope that it will be useful,
7b8b572e1SStephen Rothwell  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8b8b572e1SStephen Rothwell  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9b8b572e1SStephen Rothwell  * GNU General Public License for more details.
10b8b572e1SStephen Rothwell  *
11b8b572e1SStephen Rothwell  * You should have received a copy of the GNU General Public License
12b8b572e1SStephen Rothwell  * along with this program; if not, write to the Free Software
13b8b572e1SStephen Rothwell  * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
14b8b572e1SStephen Rothwell  *
15b8b572e1SStephen Rothwell  * Copyright IBM Corp. 2008
16b8b572e1SStephen Rothwell  *
17b8b572e1SStephen Rothwell  * Authors: Hollis Blanchard <hollisb@us.ibm.com>
18b8b572e1SStephen Rothwell  */
19b8b572e1SStephen Rothwell #ifndef __POWERPC_KVM_PARA_H__
20b8b572e1SStephen Rothwell #define __POWERPC_KVM_PARA_H__
21b8b572e1SStephen Rothwell 
22c3617f72SDavid Howells #include <uapi/asm/kvm_para.h>
23b8b572e1SStephen Rothwell 
242a342ed5SAlexander Graf #ifdef CONFIG_KVM_GUEST
252a342ed5SAlexander Graf 
2626e673c3SAlexander Graf #include <linux/of.h>
2726e673c3SAlexander Graf 
282a342ed5SAlexander Graf static inline int kvm_para_available(void)
292a342ed5SAlexander Graf {
302a342ed5SAlexander Graf 	struct device_node *hyper_node;
312a342ed5SAlexander Graf 
322a342ed5SAlexander Graf 	hyper_node = of_find_node_by_path("/hypervisor");
332a342ed5SAlexander Graf 	if (!hyper_node)
342a342ed5SAlexander Graf 		return 0;
352a342ed5SAlexander Graf 
362a342ed5SAlexander Graf 	if (!of_device_is_compatible(hyper_node, "linux,kvm"))
372a342ed5SAlexander Graf 		return 0;
382a342ed5SAlexander Graf 
392a342ed5SAlexander Graf 	return 1;
402a342ed5SAlexander Graf }
412a342ed5SAlexander Graf 
422a342ed5SAlexander Graf #else
432a342ed5SAlexander Graf 
44b8b572e1SStephen Rothwell static inline int kvm_para_available(void)
45b8b572e1SStephen Rothwell {
46b8b572e1SStephen Rothwell 	return 0;
47b8b572e1SStephen Rothwell }
48b8b572e1SStephen Rothwell 
492a342ed5SAlexander Graf #endif
502a342ed5SAlexander Graf 
51b8b572e1SStephen Rothwell static inline unsigned int kvm_arch_para_features(void)
52b8b572e1SStephen Rothwell {
532a342ed5SAlexander Graf 	unsigned long r;
542a342ed5SAlexander Graf 
552a342ed5SAlexander Graf 	if (!kvm_para_available())
56b8b572e1SStephen Rothwell 		return 0;
572a342ed5SAlexander Graf 
58b1f0d94cSBharat Bhushan 	if(epapr_hypercall0_1(KVM_HCALL_TOKEN(KVM_HC_FEATURES), &r))
592a342ed5SAlexander Graf 		return 0;
602a342ed5SAlexander Graf 
612a342ed5SAlexander Graf 	return r;
62b8b572e1SStephen Rothwell }
63b8b572e1SStephen Rothwell 
64a4429e53SWanpeng Li static inline unsigned int kvm_arch_para_hints(void)
65a4429e53SWanpeng Li {
66a4429e53SWanpeng Li 	return 0;
67a4429e53SWanpeng Li }
68a4429e53SWanpeng Li 
693b5d56b9SEric B Munson static inline bool kvm_check_and_clear_guest_paused(void)
703b5d56b9SEric B Munson {
713b5d56b9SEric B Munson 	return false;
723b5d56b9SEric B Munson }
733b5d56b9SEric B Munson 
74b8b572e1SStephen Rothwell #endif /* __POWERPC_KVM_PARA_H__ */
75