memmap.h 1.4 KB

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