1d94d71cbSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2b8b572e1SStephen Rothwell /* 3b8b572e1SStephen Rothwell * 4b8b572e1SStephen Rothwell * Copyright IBM Corp. 2008 5b8b572e1SStephen Rothwell * 6b8b572e1SStephen Rothwell * Authors: Hollis Blanchard <hollisb@us.ibm.com> 7b8b572e1SStephen Rothwell */ 8b8b572e1SStephen Rothwell #ifndef __POWERPC_KVM_PARA_H__ 9b8b572e1SStephen Rothwell #define __POWERPC_KVM_PARA_H__ 10b8b572e1SStephen Rothwell 11c3617f72SDavid Howells #include <uapi/asm/kvm_para.h> 12b8b572e1SStephen Rothwell 132a342ed5SAlexander Graf #ifdef CONFIG_KVM_GUEST 142a342ed5SAlexander Graf 1526e673c3SAlexander Graf #include <linux/of.h> 1626e673c3SAlexander Graf 172a342ed5SAlexander Graf static inline int kvm_para_available(void) 182a342ed5SAlexander Graf { 192a342ed5SAlexander Graf struct device_node *hyper_node; 202a342ed5SAlexander Graf 212a342ed5SAlexander Graf hyper_node = of_find_node_by_path("/hypervisor"); 222a342ed5SAlexander Graf if (!hyper_node) 232a342ed5SAlexander Graf return 0; 242a342ed5SAlexander Graf 252a342ed5SAlexander Graf if (!of_device_is_compatible(hyper_node, "linux,kvm")) 262a342ed5SAlexander Graf return 0; 272a342ed5SAlexander Graf 282a342ed5SAlexander Graf return 1; 292a342ed5SAlexander Graf } 302a342ed5SAlexander Graf 312a342ed5SAlexander Graf #else 322a342ed5SAlexander Graf 33b8b572e1SStephen Rothwell static inline int kvm_para_available(void) 34b8b572e1SStephen Rothwell { 35b8b572e1SStephen Rothwell return 0; 36b8b572e1SStephen Rothwell } 37b8b572e1SStephen Rothwell 382a342ed5SAlexander Graf #endif 392a342ed5SAlexander Graf 40b8b572e1SStephen Rothwell static inline unsigned int kvm_arch_para_features(void) 41b8b572e1SStephen Rothwell { 422a342ed5SAlexander Graf unsigned long r; 432a342ed5SAlexander Graf 442a342ed5SAlexander Graf if (!kvm_para_available()) 45b8b572e1SStephen Rothwell return 0; 462a342ed5SAlexander Graf 47b1f0d94cSBharat Bhushan if(epapr_hypercall0_1(KVM_HCALL_TOKEN(KVM_HC_FEATURES), &r)) 482a342ed5SAlexander Graf return 0; 492a342ed5SAlexander Graf 502a342ed5SAlexander Graf return r; 51b8b572e1SStephen Rothwell } 52b8b572e1SStephen Rothwell 53a4429e53SWanpeng Li static inline unsigned int kvm_arch_para_hints(void) 54a4429e53SWanpeng Li { 55a4429e53SWanpeng Li return 0; 56a4429e53SWanpeng Li } 57a4429e53SWanpeng Li 583b5d56b9SEric B Munson static inline bool kvm_check_and_clear_guest_paused(void) 593b5d56b9SEric B Munson { 603b5d56b9SEric B Munson return false; 613b5d56b9SEric B Munson } 623b5d56b9SEric B Munson 63b8b572e1SStephen Rothwell #endif /* __POWERPC_KVM_PARA_H__ */ 64