2 * include/linux/userfaultfd_k.h
4 * Copyright (C) 2015 Red Hat, Inc.
8 #ifndef _LINUX_USERFAULTFD_K_H
9 #define _LINUX_USERFAULTFD_K_H
11 #ifdef CONFIG_USERFAULTFD
13 #include <linux/userfaultfd.h> /* linux/include/uapi/linux/userfaultfd.h */
15 #include <linux/fcntl.h>
18 * CAREFUL: Check include/uapi/asm-generic/fcntl.h when defining
19 * new flags, since they might collide with O_* ones. We want
20 * to re-use O_* flags that couldn't possibly have a meaning
21 * from userfaultfd, in order to leave a free define-space for
24 #define UFFD_CLOEXEC O_CLOEXEC
25 #define UFFD_NONBLOCK O_NONBLOCK
27 #define UFFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK)
28 #define UFFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS)
30 extern int handle_userfault(struct vm_area_struct
*vma
, unsigned long address
,
31 unsigned int flags
, unsigned long reason
);
34 static inline bool is_mergeable_vm_userfaultfd_ctx(struct vm_area_struct
*vma
,
35 struct vm_userfaultfd_ctx vm_ctx
)
37 return vma
->vm_userfaultfd_ctx
.ctx
== vm_ctx
.ctx
;
40 static inline bool userfaultfd_missing(struct vm_area_struct
*vma
)
42 return vma
->vm_flags
& VM_UFFD_MISSING
;
45 static inline bool userfaultfd_armed(struct vm_area_struct
*vma
)
47 return vma
->vm_flags
& (VM_UFFD_MISSING
| VM_UFFD_WP
);
50 #else /* CONFIG_USERFAULTFD */
53 static inline int handle_userfault(struct vm_area_struct
*vma
,
54 unsigned long address
,
58 return VM_FAULT_SIGBUS
;
61 static inline bool is_mergeable_vm_userfaultfd_ctx(struct vm_area_struct
*vma
,
62 struct vm_userfaultfd_ctx vm_ctx
)
67 static inline bool userfaultfd_missing(struct vm_area_struct
*vma
)
72 static inline bool userfaultfd_armed(struct vm_area_struct
*vma
)
77 #endif /* CONFIG_USERFAULTFD */
79 #endif /* _LINUX_USERFAULTFD_K_H */