xref: /linux/virt/kvm/guest_memfd.h (revision 67f8bc848ee31831336bd478e57d2f993551902e)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef __KVM_GUEST_MEMFD_H__
3 #define __KVM_GUEST_MEMFD_H__
4 
5 #include <linux/kvm_types.h>
6 
7 #ifdef CONFIG_KVM_GUEST_MEMFD
8 int kvm_gmem_init(struct module *module);
9 void kvm_gmem_exit(void);
10 int kvm_gmem_create(struct kvm *kvm, struct kvm_create_guest_memfd *args);
11 int kvm_gmem_bind(struct kvm *kvm, struct kvm_memory_slot *slot,
12 		  unsigned int fd, uoff_t offset);
13 void kvm_gmem_unbind(struct kvm_memory_slot *slot);
14 #else
15 static inline int kvm_gmem_init(struct module *module)
16 {
17 	return 0;
18 }
19 static inline void kvm_gmem_exit(void) {};
20 static inline int kvm_gmem_bind(struct kvm *kvm,
21 					 struct kvm_memory_slot *slot,
22 					 unsigned int fd, uoff_t offset)
23 {
24 	WARN_ON_ONCE(1);
25 	return -EIO;
26 }
27 
28 static inline void kvm_gmem_unbind(struct kvm_memory_slot *slot)
29 {
30 	WARN_ON_ONCE(1);
31 }
32 #endif /* CONFIG_KVM_GUEST_MEMFD */
33 
34 #endif /* __KVM_GUEST_MEMFD_H__ */
35