1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_KVM_BOOK3S_UVMEM_H__
3 #define __ASM_KVM_BOOK3S_UVMEM_H__
4 
5 #ifdef CONFIG_PPC_UV
6 int kvmppc_uvmem_init(void);
7 void kvmppc_uvmem_free(void);
8 bool kvmppc_uvmem_available(void);
9 int kvmppc_uvmem_slot_init(struct kvm *kvm, const struct kvm_memory_slot *slot);
10 void kvmppc_uvmem_slot_free(struct kvm *kvm,
11 			    const struct kvm_memory_slot *slot);
12 unsigned long kvmppc_h_svm_page_in(struct kvm *kvm,
13 				   unsigned long gra,
14 				   unsigned long flags,
15 				   unsigned long page_shift);
16 unsigned long kvmppc_h_svm_page_out(struct kvm *kvm,
17 				    unsigned long gra,
18 				    unsigned long flags,
19 				    unsigned long page_shift);
20 unsigned long kvmppc_h_svm_init_start(struct kvm *kvm);
21 unsigned long kvmppc_h_svm_init_done(struct kvm *kvm);
22 int kvmppc_send_page_to_uv(struct kvm *kvm, unsigned long gfn);
23 unsigned long kvmppc_h_svm_init_abort(struct kvm *kvm);
24 void kvmppc_uvmem_drop_pages(const struct kvm_memory_slot *free,
25 			     struct kvm *kvm, bool skip_page_out);
26 #else
27 static inline int kvmppc_uvmem_init(void)
28 {
29 	return 0;
30 }
31 
32 static inline void kvmppc_uvmem_free(void) { }
33 
34 static inline bool kvmppc_uvmem_available(void)
35 {
36 	return false;
37 }
38 
39 static inline int
40 kvmppc_uvmem_slot_init(struct kvm *kvm, const struct kvm_memory_slot *slot)
41 {
42 	return 0;
43 }
44 
45 static inline void
46 kvmppc_uvmem_slot_free(struct kvm *kvm, const struct kvm_memory_slot *slot) { }
47 
48 static inline unsigned long
49 kvmppc_h_svm_page_in(struct kvm *kvm, unsigned long gra,
50 		     unsigned long flags, unsigned long page_shift)
51 {
52 	return H_UNSUPPORTED;
53 }
54 
55 static inline unsigned long
56 kvmppc_h_svm_page_out(struct kvm *kvm, unsigned long gra,
57 		      unsigned long flags, unsigned long page_shift)
58 {
59 	return H_UNSUPPORTED;
60 }
61 
62 static inline unsigned long kvmppc_h_svm_init_start(struct kvm *kvm)
63 {
64 	return H_UNSUPPORTED;
65 }
66 
67 static inline unsigned long kvmppc_h_svm_init_done(struct kvm *kvm)
68 {
69 	return H_UNSUPPORTED;
70 }
71 
72 static inline unsigned long kvmppc_h_svm_init_abort(struct kvm *kvm)
73 {
74 	return H_UNSUPPORTED;
75 }
76 
77 static inline int kvmppc_send_page_to_uv(struct kvm *kvm, unsigned long gfn)
78 {
79 	return -EFAULT;
80 }
81 
82 static inline void
83 kvmppc_uvmem_drop_pages(const struct kvm_memory_slot *free,
84 			struct kvm *kvm, bool skip_page_out) { }
85 #endif /* CONFIG_PPC_UV */
86 #endif /* __ASM_KVM_BOOK3S_UVMEM_H__ */
87