1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 3 #pragma once 4 5 /* 6 * Contains declarations that are STUBBED, that is that are rendered no-ops, in 7 * order to faciliate userland VMA testing. 8 */ 9 10 /* Forward declarations. */ 11 struct mm_struct; 12 struct vm_area_struct; 13 struct vm_area_desc; 14 struct pagetable_move_control; 15 struct mmap_action; 16 struct file; 17 struct anon_vma; 18 struct anon_vma_chain; 19 struct address_space; 20 struct unmap_desc; 21 22 #define __bitwise 23 #define __randomize_layout 24 25 #define FIRST_USER_ADDRESS 0UL 26 #define USER_PGTABLES_CEILING 0UL 27 28 #define vma_policy(vma) NULL 29 30 #define down_write_nest_lock(sem, nest_lock) 31 32 #define data_race(expr) expr 33 34 #define ASSERT_EXCLUSIVE_WRITER(x) 35 36 struct vm_userfaultfd_ctx {}; 37 struct mempolicy {}; 38 struct mmu_gather {}; 39 struct mutex {}; 40 struct vm_fault {}; 41 42 static inline void userfaultfd_unmap_complete(struct mm_struct *mm, 43 struct list_head *uf) 44 { 45 } 46 47 static inline unsigned long move_page_tables(struct pagetable_move_control *pmc) 48 { 49 return 0; 50 } 51 52 static inline void free_pgd_range(struct mmu_gather *tlb, 53 unsigned long addr, unsigned long end, 54 unsigned long floor, unsigned long ceiling) 55 { 56 } 57 58 static inline int ksm_execve(struct mm_struct *mm) 59 { 60 return 0; 61 } 62 63 static inline void ksm_exit(struct mm_struct *mm) 64 { 65 } 66 67 static inline void vma_numab_state_init(struct vm_area_struct *vma) 68 { 69 } 70 71 static inline void vma_numab_state_free(struct vm_area_struct *vma) 72 { 73 } 74 75 static inline void dup_anon_vma_name(struct vm_area_struct *orig_vma, 76 struct vm_area_struct *new_vma) 77 { 78 } 79 80 static inline void free_anon_vma_name(struct vm_area_struct *vma) 81 { 82 } 83 84 static inline int mmap_action_prepare(struct vm_area_desc *desc) 85 { 86 return 0; 87 } 88 89 static inline int mmap_action_complete(struct vm_area_struct *vma, 90 struct mmap_action *action, 91 bool is_compat) 92 { 93 return 0; 94 } 95 96 static inline void fixup_hugetlb_reservations(struct vm_area_struct *vma) 97 { 98 } 99 100 static inline bool shmem_file(struct file *file) 101 { 102 return false; 103 } 104 105 static inline vma_flags_t ksm_vma_flags(struct mm_struct *mm, 106 const struct file *file, vma_flags_t vma_flags) 107 { 108 return vma_flags; 109 } 110 111 static inline void remap_pfn_range_prepare(struct vm_area_desc *desc, unsigned long pfn) 112 { 113 } 114 115 static inline int remap_pfn_range_complete(struct vm_area_struct *vma, unsigned long addr, 116 unsigned long pfn, unsigned long size, pgprot_t pgprot) 117 { 118 return 0; 119 } 120 121 static inline int do_munmap(struct mm_struct *, unsigned long, size_t, 122 struct list_head *uf) 123 { 124 return 0; 125 } 126 127 /* Currently stubbed but we may later wish to un-stub. */ 128 static inline void vm_acct_memory(long pages); 129 130 static inline void mmap_assert_locked(struct mm_struct *mm) 131 { 132 } 133 134 135 static inline void anon_vma_unlock_write(struct anon_vma *anon_vma) 136 { 137 } 138 139 static inline void i_mmap_unlock_write(struct address_space *mapping) 140 { 141 } 142 143 static inline int userfaultfd_unmap_prep(struct vm_area_struct *vma, 144 unsigned long start, 145 unsigned long end, 146 struct list_head *unmaps) 147 { 148 return 0; 149 } 150 151 static inline void userfaultfd_unmap_abort(struct list_head *uf) 152 { 153 } 154 155 static inline void mmap_write_downgrade(struct mm_struct *mm) 156 { 157 } 158 159 static inline void mmap_read_unlock(struct mm_struct *mm) 160 { 161 } 162 163 static inline void mmap_write_unlock(struct mm_struct *mm) 164 { 165 } 166 167 static inline int mmap_write_lock_killable(struct mm_struct *mm) 168 { 169 return 0; 170 } 171 172 static inline bool can_modify_mm(struct mm_struct *mm, 173 unsigned long start, 174 unsigned long end) 175 { 176 return true; 177 } 178 179 static inline void arch_unmap(struct mm_struct *mm, 180 unsigned long start, 181 unsigned long end) 182 { 183 } 184 185 static inline bool mpol_equal(struct mempolicy *a, struct mempolicy *b) 186 { 187 return true; 188 } 189 190 static inline void khugepaged_enter_vma(struct vm_area_struct *vma, 191 vm_flags_t vm_flags) 192 { 193 } 194 195 static inline bool mapping_can_writeback(struct address_space *mapping) 196 { 197 return true; 198 } 199 200 static inline bool vma_is_hugetlb(struct vm_area_struct *vma) 201 { 202 return false; 203 } 204 205 static inline bool vma_soft_dirty_enabled(struct vm_area_struct *vma) 206 { 207 return false; 208 } 209 210 static inline bool userfaultfd_wp(struct vm_area_struct *vma) 211 { 212 return false; 213 } 214 215 static inline void mmap_assert_write_locked(struct mm_struct *mm) 216 { 217 } 218 219 static inline void mutex_lock(struct mutex *lock) 220 { 221 } 222 223 static inline void mutex_unlock(struct mutex *lock) 224 { 225 } 226 227 static inline bool mutex_is_locked(struct mutex *lock) 228 { 229 return true; 230 } 231 232 static inline bool signal_pending(void *p) 233 { 234 return false; 235 } 236 237 static inline bool is_file_hugepages(const struct file *file) 238 { 239 return false; 240 } 241 242 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages) 243 { 244 return 0; 245 } 246 247 static inline bool may_expand_vm(struct mm_struct *mm, 248 const vma_flags_t *vma_flags, 249 unsigned long npages) 250 { 251 return true; 252 } 253 254 static inline int shmem_zero_setup(struct vm_area_struct *vma) 255 { 256 return 0; 257 } 258 259 260 static inline void vm_acct_memory(long pages) 261 { 262 } 263 264 static inline void mapping_rmap_tree_insert(struct vm_area_struct *vma, 265 struct address_space *mapping) 266 { 267 } 268 269 static inline void mapping_rmap_tree_remove(struct vm_area_struct *vma, 270 struct address_space *mapping) 271 { 272 } 273 274 static inline void mapping_rmap_tree_pre_update(struct vm_area_struct *vma, 275 struct address_space *mapping, 276 bool pgoff_unchanged) 277 { 278 } 279 280 static inline void mapping_rmap_tree_post_update(struct vm_area_struct *vma, 281 struct address_space *mapping, 282 bool pgoff_unchanged) 283 { 284 } 285 286 static inline void flush_dcache_mmap_unlock(struct address_space *mapping) 287 { 288 } 289 290 static inline void anon_rmap_tree_insert(struct anon_vma_chain *avc, 291 struct anon_vma *anon_vma) 292 { 293 } 294 295 static inline void anon_rmap_tree_remove(struct anon_vma_chain *avc, 296 struct anon_vma *anon_vma) 297 { 298 } 299 300 static inline void anon_rmap_tree_pre_update_vma(struct vm_area_struct *vma, 301 bool anon_pgoff_unchanged) 302 { 303 } 304 305 static inline void anon_rmap_tree_post_update_vma(struct vm_area_struct *vma, 306 bool anon_pgoff_unchanged) 307 { 308 } 309 310 static inline void uprobe_mmap(struct vm_area_struct *vma) 311 { 312 } 313 314 static inline void uprobe_munmap(struct vm_area_struct *vma, 315 unsigned long start, unsigned long end) 316 { 317 } 318 319 static inline void i_mmap_lock_write(struct address_space *mapping) 320 { 321 } 322 323 static inline void anon_vma_lock_write(struct anon_vma *anon_vma) 324 { 325 } 326 327 static inline void vma_assert_write_locked(const struct vm_area_struct *vma) 328 { 329 } 330 331 static inline void vma_assert_stabilised(const struct vm_area_struct *vma) 332 { 333 } 334 335 static inline void ksm_add_vma(struct vm_area_struct *vma) 336 { 337 } 338 339 static inline void perf_event_mmap(struct vm_area_struct *vma) 340 { 341 } 342 343 static inline bool vma_is_dax(struct vm_area_struct *vma) 344 { 345 return false; 346 } 347 348 static inline struct vm_area_struct *get_gate_vma(struct mm_struct *mm) 349 { 350 return NULL; 351 } 352 353 static inline bool arch_validate_flags(vm_flags_t flags) 354 { 355 return true; 356 } 357 358 static inline void vma_close(struct vm_area_struct *vma) 359 { 360 } 361 362 static inline void zap_vma(struct vm_area_struct *vma) 363 { 364 } 365 366 static inline int mmap_file(struct file *file, struct vm_area_struct *vma) 367 { 368 return 0; 369 } 370 371 static inline int is_hugepage_only_range(struct mm_struct *mm, 372 unsigned long addr, unsigned long len) 373 { 374 return 0; 375 } 376 377 static inline bool capable(int cap) 378 { 379 return true; 380 } 381 382 static inline struct anon_vma_name *anon_vma_name(struct vm_area_struct *vma) 383 { 384 return NULL; 385 } 386 387 static inline bool is_mergeable_vm_userfaultfd_ctx(struct vm_area_struct *vma, 388 struct vm_userfaultfd_ctx vm_ctx) 389 { 390 return true; 391 } 392 393 static inline bool vma_has_uffd_without_event_remap(struct vm_area_struct *vma) 394 { 395 return false; 396 } 397 398 static inline bool anon_vma_name_eq(struct anon_vma_name *anon_name1, 399 struct anon_vma_name *anon_name2) 400 { 401 return true; 402 } 403 404 static inline void might_sleep(void) 405 { 406 } 407 408 static inline void fput(struct file *file) 409 { 410 } 411 412 static inline void mpol_put(struct mempolicy *pol) 413 { 414 } 415 416 static inline void lru_add_drain(void) 417 { 418 } 419 420 static inline void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm) 421 { 422 } 423 424 static inline void update_hiwater_rss(struct mm_struct *mm) 425 { 426 } 427 428 static inline void update_hiwater_vm(struct mm_struct *mm) 429 { 430 } 431 432 static inline void unmap_vmas(struct mmu_gather *tlb, struct unmap_desc *unmap) 433 { 434 } 435 436 static inline void free_pgtables(struct mmu_gather *tlb, struct unmap_desc *unmap) 437 { 438 } 439 440 static inline void mapping_unmap_writable(struct address_space *mapping) 441 { 442 } 443 444 static inline void flush_dcache_mmap_lock(struct address_space *mapping) 445 { 446 } 447 448 static inline void tlb_finish_mmu(struct mmu_gather *tlb) 449 { 450 } 451 452 static inline struct file *get_file(struct file *f) 453 { 454 return f; 455 } 456 457 static inline int vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst) 458 { 459 return 0; 460 } 461 462 static inline void vma_adjust_trans_huge(struct vm_area_struct *vma, 463 unsigned long start, 464 unsigned long end, 465 struct vm_area_struct *next) 466 { 467 } 468 469 static inline void hugetlb_split(struct vm_area_struct *, unsigned long) {} 470 471 static inline bool vma_supports_mlock(const struct vm_area_struct *vma) 472 { 473 return false; 474 } 475