stubs.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. #pragma once
  3. /*
  4. * Contains declarations that are STUBBED, that is that are rendered no-ops, in
  5. * order to faciliate userland VMA testing.
  6. */
  7. /* Forward declarations. */
  8. struct mm_struct;
  9. struct vm_area_struct;
  10. struct vm_area_desc;
  11. struct pagetable_move_control;
  12. struct mmap_action;
  13. struct file;
  14. struct anon_vma;
  15. struct anon_vma_chain;
  16. struct address_space;
  17. struct unmap_desc;
  18. #define __bitwise
  19. #define __randomize_layout
  20. #define FIRST_USER_ADDRESS 0UL
  21. #define USER_PGTABLES_CEILING 0UL
  22. #define vma_policy(vma) NULL
  23. #define down_write_nest_lock(sem, nest_lock)
  24. #define data_race(expr) expr
  25. #define ASSERT_EXCLUSIVE_WRITER(x)
  26. struct vm_userfaultfd_ctx {};
  27. struct mempolicy {};
  28. struct mmu_gather {};
  29. struct mutex {};
  30. struct vm_fault {};
  31. static inline void userfaultfd_unmap_complete(struct mm_struct *mm,
  32. struct list_head *uf)
  33. {
  34. }
  35. static inline unsigned long move_page_tables(struct pagetable_move_control *pmc)
  36. {
  37. return 0;
  38. }
  39. static inline void free_pgd_range(struct mmu_gather *tlb,
  40. unsigned long addr, unsigned long end,
  41. unsigned long floor, unsigned long ceiling)
  42. {
  43. }
  44. static inline int ksm_execve(struct mm_struct *mm)
  45. {
  46. return 0;
  47. }
  48. static inline void ksm_exit(struct mm_struct *mm)
  49. {
  50. }
  51. static inline void vma_numab_state_init(struct vm_area_struct *vma)
  52. {
  53. }
  54. static inline void vma_numab_state_free(struct vm_area_struct *vma)
  55. {
  56. }
  57. static inline void dup_anon_vma_name(struct vm_area_struct *orig_vma,
  58. struct vm_area_struct *new_vma)
  59. {
  60. }
  61. static inline void free_anon_vma_name(struct vm_area_struct *vma)
  62. {
  63. }
  64. static inline void mmap_action_prepare(struct mmap_action *action,
  65. struct vm_area_desc *desc)
  66. {
  67. }
  68. static inline int mmap_action_complete(struct mmap_action *action,
  69. struct vm_area_struct *vma)
  70. {
  71. return 0;
  72. }
  73. static inline void fixup_hugetlb_reservations(struct vm_area_struct *vma)
  74. {
  75. }
  76. static inline bool shmem_file(struct file *file)
  77. {
  78. return false;
  79. }
  80. static inline vm_flags_t ksm_vma_flags(const struct mm_struct *mm,
  81. const struct file *file, vm_flags_t vm_flags)
  82. {
  83. return vm_flags;
  84. }
  85. static inline void remap_pfn_range_prepare(struct vm_area_desc *desc, unsigned long pfn)
  86. {
  87. }
  88. static inline int remap_pfn_range_complete(struct vm_area_struct *vma, unsigned long addr,
  89. unsigned long pfn, unsigned long size, pgprot_t pgprot)
  90. {
  91. return 0;
  92. }
  93. static inline int do_munmap(struct mm_struct *, unsigned long, size_t,
  94. struct list_head *uf)
  95. {
  96. return 0;
  97. }
  98. /* Currently stubbed but we may later wish to un-stub. */
  99. static inline void vm_acct_memory(long pages);
  100. static inline void mmap_assert_locked(struct mm_struct *mm)
  101. {
  102. }
  103. static inline void anon_vma_unlock_write(struct anon_vma *anon_vma)
  104. {
  105. }
  106. static inline void i_mmap_unlock_write(struct address_space *mapping)
  107. {
  108. }
  109. static inline int userfaultfd_unmap_prep(struct vm_area_struct *vma,
  110. unsigned long start,
  111. unsigned long end,
  112. struct list_head *unmaps)
  113. {
  114. return 0;
  115. }
  116. static inline void mmap_write_downgrade(struct mm_struct *mm)
  117. {
  118. }
  119. static inline void mmap_read_unlock(struct mm_struct *mm)
  120. {
  121. }
  122. static inline void mmap_write_unlock(struct mm_struct *mm)
  123. {
  124. }
  125. static inline int mmap_write_lock_killable(struct mm_struct *mm)
  126. {
  127. return 0;
  128. }
  129. static inline bool can_modify_mm(struct mm_struct *mm,
  130. unsigned long start,
  131. unsigned long end)
  132. {
  133. return true;
  134. }
  135. static inline void arch_unmap(struct mm_struct *mm,
  136. unsigned long start,
  137. unsigned long end)
  138. {
  139. }
  140. static inline bool mpol_equal(struct mempolicy *a, struct mempolicy *b)
  141. {
  142. return true;
  143. }
  144. static inline void khugepaged_enter_vma(struct vm_area_struct *vma,
  145. vm_flags_t vm_flags)
  146. {
  147. }
  148. static inline bool mapping_can_writeback(struct address_space *mapping)
  149. {
  150. return true;
  151. }
  152. static inline bool is_vm_hugetlb_page(struct vm_area_struct *vma)
  153. {
  154. return false;
  155. }
  156. static inline bool vma_soft_dirty_enabled(struct vm_area_struct *vma)
  157. {
  158. return false;
  159. }
  160. static inline bool userfaultfd_wp(struct vm_area_struct *vma)
  161. {
  162. return false;
  163. }
  164. static inline void mmap_assert_write_locked(struct mm_struct *mm)
  165. {
  166. }
  167. static inline void mutex_lock(struct mutex *lock)
  168. {
  169. }
  170. static inline void mutex_unlock(struct mutex *lock)
  171. {
  172. }
  173. static inline bool mutex_is_locked(struct mutex *lock)
  174. {
  175. return true;
  176. }
  177. static inline bool signal_pending(void *p)
  178. {
  179. return false;
  180. }
  181. static inline bool is_file_hugepages(struct file *file)
  182. {
  183. return false;
  184. }
  185. static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
  186. {
  187. return 0;
  188. }
  189. static inline bool may_expand_vm(struct mm_struct *mm, vm_flags_t flags,
  190. unsigned long npages)
  191. {
  192. return true;
  193. }
  194. static inline int shmem_zero_setup(struct vm_area_struct *vma)
  195. {
  196. return 0;
  197. }
  198. static inline void vm_acct_memory(long pages)
  199. {
  200. }
  201. static inline void vma_interval_tree_insert(struct vm_area_struct *vma,
  202. struct rb_root_cached *rb)
  203. {
  204. }
  205. static inline void vma_interval_tree_remove(struct vm_area_struct *vma,
  206. struct rb_root_cached *rb)
  207. {
  208. }
  209. static inline void flush_dcache_mmap_unlock(struct address_space *mapping)
  210. {
  211. }
  212. static inline void anon_vma_interval_tree_insert(struct anon_vma_chain *avc,
  213. struct rb_root_cached *rb)
  214. {
  215. }
  216. static inline void anon_vma_interval_tree_remove(struct anon_vma_chain *avc,
  217. struct rb_root_cached *rb)
  218. {
  219. }
  220. static inline void uprobe_mmap(struct vm_area_struct *vma)
  221. {
  222. }
  223. static inline void uprobe_munmap(struct vm_area_struct *vma,
  224. unsigned long start, unsigned long end)
  225. {
  226. }
  227. static inline void i_mmap_lock_write(struct address_space *mapping)
  228. {
  229. }
  230. static inline void anon_vma_lock_write(struct anon_vma *anon_vma)
  231. {
  232. }
  233. static inline void vma_assert_write_locked(struct vm_area_struct *vma)
  234. {
  235. }
  236. static inline void ksm_add_vma(struct vm_area_struct *vma)
  237. {
  238. }
  239. static inline void perf_event_mmap(struct vm_area_struct *vma)
  240. {
  241. }
  242. static inline bool vma_is_dax(struct vm_area_struct *vma)
  243. {
  244. return false;
  245. }
  246. static inline struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
  247. {
  248. return NULL;
  249. }
  250. static inline bool arch_validate_flags(vm_flags_t flags)
  251. {
  252. return true;
  253. }
  254. static inline void vma_close(struct vm_area_struct *vma)
  255. {
  256. }
  257. static inline int mmap_file(struct file *file, struct vm_area_struct *vma)
  258. {
  259. return 0;
  260. }
  261. static inline int is_hugepage_only_range(struct mm_struct *mm,
  262. unsigned long addr, unsigned long len)
  263. {
  264. return 0;
  265. }
  266. static inline bool capable(int cap)
  267. {
  268. return true;
  269. }
  270. static inline struct anon_vma_name *anon_vma_name(struct vm_area_struct *vma)
  271. {
  272. return NULL;
  273. }
  274. static inline bool is_mergeable_vm_userfaultfd_ctx(struct vm_area_struct *vma,
  275. struct vm_userfaultfd_ctx vm_ctx)
  276. {
  277. return true;
  278. }
  279. static inline bool anon_vma_name_eq(struct anon_vma_name *anon_name1,
  280. struct anon_vma_name *anon_name2)
  281. {
  282. return true;
  283. }
  284. static inline void might_sleep(void)
  285. {
  286. }
  287. static inline void fput(struct file *file)
  288. {
  289. }
  290. static inline void mpol_put(struct mempolicy *pol)
  291. {
  292. }
  293. static inline void lru_add_drain(void)
  294. {
  295. }
  296. static inline void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm)
  297. {
  298. }
  299. static inline void update_hiwater_rss(struct mm_struct *mm)
  300. {
  301. }
  302. static inline void update_hiwater_vm(struct mm_struct *mm)
  303. {
  304. }
  305. static inline void unmap_vmas(struct mmu_gather *tlb, struct unmap_desc *unmap)
  306. {
  307. }
  308. static inline void free_pgtables(struct mmu_gather *tlb, struct unmap_desc *unmap)
  309. {
  310. }
  311. static inline void mapping_unmap_writable(struct address_space *mapping)
  312. {
  313. }
  314. static inline void flush_dcache_mmap_lock(struct address_space *mapping)
  315. {
  316. }
  317. static inline void tlb_finish_mmu(struct mmu_gather *tlb)
  318. {
  319. }
  320. static inline struct file *get_file(struct file *f)
  321. {
  322. return f;
  323. }
  324. static inline int vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
  325. {
  326. return 0;
  327. }
  328. static inline void vma_adjust_trans_huge(struct vm_area_struct *vma,
  329. unsigned long start,
  330. unsigned long end,
  331. struct vm_area_struct *next)
  332. {
  333. }
  334. static inline void hugetlb_split(struct vm_area_struct *, unsigned long) {}