Thomas Gleixner | d94d71c | 2019-05-29 07:12:40 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 2 | /* |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 3 | * |
| 4 | * Copyright IBM Corp. 2008 |
| 5 | * |
| 6 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> |
| 7 | */ |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 8 | #ifndef __POWERPC_KVM_PARA_H__ |
| 9 | #define __POWERPC_KVM_PARA_H__ |
| 10 | |
David Howells | c3617f7 | 2012-10-09 09:47:26 +0100 | [diff] [blame] | 11 | #include <uapi/asm/kvm_para.h> |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 12 | |
Alexander Graf | 2a342ed | 2010-07-29 14:47:48 +0200 | [diff] [blame] | 13 | #ifdef CONFIG_KVM_GUEST |
| 14 | |
Alexander Graf | 26e673c | 2010-09-03 10:22:19 +0200 | [diff] [blame] | 15 | #include <linux/of.h> |
| 16 | |
Alexander Graf | 2a342ed | 2010-07-29 14:47:48 +0200 | [diff] [blame] | 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 | |
Alexander Graf | 2a342ed | 2010-07-29 14:47:48 +0200 | [diff] [blame] | 31 | #else |
| 32 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 33 | static inline int kvm_para_available(void) |
| 34 | { |
| 35 | return 0; |
| 36 | } |
| 37 | |
Alexander Graf | 2a342ed | 2010-07-29 14:47:48 +0200 | [diff] [blame] | 38 | #endif |
| 39 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 40 | static inline unsigned int kvm_arch_para_features(void) |
| 41 | { |
Alexander Graf | 2a342ed | 2010-07-29 14:47:48 +0200 | [diff] [blame] | 42 | unsigned long r; |
| 43 | |
| 44 | if (!kvm_para_available()) |
| 45 | return 0; |
| 46 | |
Bharat Bhushan | b1f0d94 | 2013-10-08 09:32:20 +0530 | [diff] [blame] | 47 | if(epapr_hypercall0_1(KVM_HCALL_TOKEN(KVM_HC_FEATURES), &r)) |
Alexander Graf | 2a342ed | 2010-07-29 14:47:48 +0200 | [diff] [blame] | 48 | return 0; |
| 49 | |
| 50 | return r; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 51 | } |
| 52 | |
Wanpeng Li | a4429e5 | 2018-02-13 09:05:40 +0800 | [diff] [blame] | 53 | static inline unsigned int kvm_arch_para_hints(void) |
| 54 | { |
| 55 | return 0; |
| 56 | } |
| 57 | |
Eric B Munson | 3b5d56b | 2012-03-10 14:37:26 -0500 | [diff] [blame] | 58 | static inline bool kvm_check_and_clear_guest_paused(void) |
| 59 | { |
| 60 | return false; |
| 61 | } |
| 62 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 63 | #endif /* __POWERPC_KVM_PARA_H__ */ |