Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 1 | /* |
| 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. |
| 5 | * |
| 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. |
| 10 | * |
| 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. |
| 14 | * |
| 15 | * Copyright IBM Corp. 2008 |
| 16 | * |
| 17 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> |
| 18 | */ |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 19 | #ifndef __POWERPC_KVM_PARA_H__ |
| 20 | #define __POWERPC_KVM_PARA_H__ |
| 21 | |
David Howells | c3617f7 | 2012-10-09 09:47:26 +0100 | [diff] [blame] | 22 | #include <uapi/asm/kvm_para.h> |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 23 | |
Alexander Graf | 2a342ed | 2010-07-29 14:47:48 +0200 | [diff] [blame] | 24 | #ifdef CONFIG_KVM_GUEST |
| 25 | |
Alexander Graf | 26e673c | 2010-09-03 10:22:19 +0200 | [diff] [blame] | 26 | #include <linux/of.h> |
| 27 | |
Alexander Graf | 2a342ed | 2010-07-29 14:47:48 +0200 | [diff] [blame] | 28 | static inline int kvm_para_available(void) |
| 29 | { |
| 30 | struct device_node *hyper_node; |
| 31 | |
| 32 | hyper_node = of_find_node_by_path("/hypervisor"); |
| 33 | if (!hyper_node) |
| 34 | return 0; |
| 35 | |
| 36 | if (!of_device_is_compatible(hyper_node, "linux,kvm")) |
| 37 | return 0; |
| 38 | |
| 39 | return 1; |
| 40 | } |
| 41 | |
Alexander Graf | 2a342ed | 2010-07-29 14:47:48 +0200 | [diff] [blame] | 42 | #else |
| 43 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 44 | static inline int kvm_para_available(void) |
| 45 | { |
| 46 | return 0; |
| 47 | } |
| 48 | |
Alexander Graf | 2a342ed | 2010-07-29 14:47:48 +0200 | [diff] [blame] | 49 | #endif |
| 50 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 51 | static inline unsigned int kvm_arch_para_features(void) |
| 52 | { |
Alexander Graf | 2a342ed | 2010-07-29 14:47:48 +0200 | [diff] [blame] | 53 | unsigned long r; |
| 54 | |
| 55 | if (!kvm_para_available()) |
| 56 | return 0; |
| 57 | |
Bharat Bhushan | b1f0d94 | 2013-10-08 09:32:20 +0530 | [diff] [blame] | 58 | if(epapr_hypercall0_1(KVM_HCALL_TOKEN(KVM_HC_FEATURES), &r)) |
Alexander Graf | 2a342ed | 2010-07-29 14:47:48 +0200 | [diff] [blame] | 59 | return 0; |
| 60 | |
| 61 | return r; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 62 | } |
| 63 | |
Eric B Munson | 3b5d56b | 2012-03-10 14:37:26 -0500 | [diff] [blame] | 64 | static inline bool kvm_check_and_clear_guest_paused(void) |
| 65 | { |
| 66 | return false; |
| 67 | } |
| 68 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 69 | #endif /* __POWERPC_KVM_PARA_H__ */ |