at commit 205cccd0
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef IO_URING_MEMMAP_H |
| 3 | #define IO_URING_MEMMAP_H |
| 4 | |
| 5 | #define IORING_MAP_OFF_PARAM_REGION 0x20000000ULL |
| 6 | #define IORING_MAP_OFF_ZCRX_REGION 0x30000000ULL |
| 7 | |
| 8 | #define IORING_OFF_ZCRX_SHIFT 16 |
| 9 | |
| 10 | struct page **io_pin_pages(unsigned long uaddr, unsigned long len, int *npages); |
| 11 | |
| 12 | #ifndef CONFIG_MMU |
| 13 | unsigned int io_uring_nommu_mmap_capabilities(struct file *file); |
| 14 | #endif |
| 15 | unsigned long io_uring_get_unmapped_area(struct file *file, unsigned long addr, |
| 16 | unsigned long len, unsigned long pgoff, |
| 17 | unsigned long flags); |
| 18 | int io_uring_mmap(struct file *file, struct vm_area_struct *vma); |
| 19 | |
| 20 | void io_free_region(struct user_struct *user, struct io_mapped_region *mr); |
| 21 | int io_create_region(struct user_struct *user, struct io_mapped_region *mr, |
| 22 | struct io_uring_region_desc *reg, |
| 23 | unsigned long mmap_offset); |
| 24 | |
| 25 | static inline void *io_region_get_ptr(struct io_mapped_region *mr) |
| 26 | { |
| 27 | return mr->ptr; |
| 28 | } |
| 29 | |
| 30 | static inline bool io_region_is_set(struct io_mapped_region *mr) |
| 31 | { |
| 32 | return !!mr->nr_pages; |
| 33 | } |
| 34 | |
| 35 | static inline void io_region_publish(struct io_ring_ctx *ctx, |
| 36 | struct io_mapped_region *src_region, |
| 37 | struct io_mapped_region *dst_region) |
| 38 | { |
| 39 | /* |
| 40 | * Once published mmap can find it without holding only the ->mmap_lock |
| 41 | * and not ->uring_lock. |
| 42 | */ |
| 43 | guard(mutex)(&ctx->mmap_lock); |
| 44 | *dst_region = *src_region; |
| 45 | } |
| 46 | |
| 47 | static inline size_t io_region_size(struct io_mapped_region *mr) |
| 48 | { |
| 49 | return (size_t) mr->nr_pages << PAGE_SHIFT; |
| 50 | } |
| 51 | |
| 52 | #endif |