summaryrefslogtreecommitdiff
path: root/virt/kvm/guest_memfd.h
blob: 01bd359d27e307e63cd3d4728ada46fce313d236 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef __KVM_GUEST_MEMFD_H__
#define __KVM_GUEST_MEMFD_H__

#include <linux/kvm_types.h>

#ifdef CONFIG_KVM_GUEST_MEMFD
int kvm_gmem_init(struct module *module);
void kvm_gmem_exit(void);
int kvm_gmem_create(struct kvm *kvm, struct kvm_create_guest_memfd *args);
int kvm_gmem_prepare_memory_region(struct kvm *kvm, struct kvm_memory_slot *slot,
				   unsigned int fd, uoff_t offset);
int kvm_gmem_commit_memory_region(struct kvm *kvm, struct kvm_memory_slot *slot);
void kvm_gmem_unbind(struct kvm_memory_slot *slot);
#else
static inline int kvm_gmem_init(struct module *module)
{
	return 0;
}
static inline void kvm_gmem_exit(void) {};

static inline int kvm_gmem_prepare_memory_region(struct kvm *kvm,
						 struct kvm_memory_slot *slot,
						 unsigned int fd, uoff_t offset)
{
	WARN_ON_ONCE(1);
	return -EIO;
}

static inline int kvm_gmem_commit_memory_region(struct kvm *kvm,
						struct kvm_memory_slot *slot)
{
	WARN_ON_ONCE(1);
	return -EIO;
}

static inline void kvm_gmem_unbind(struct kvm_memory_slot *slot)
{
	WARN_ON_ONCE(1);
}
#endif /* CONFIG_KVM_GUEST_MEMFD */

#endif /* __KVM_GUEST_MEMFD_H__ */