#include <linux/err.h>
#include <linux/errno.h>
#include <linux/iommu.h>
#include <linux/iommufd.h>
#include <linux/lockdep.h>
#include <linux/sched/mm.h>
#include <linux/slab.h>
#include <uapi/linux/iommufd.h>
#include "double_span.h"
#include "io_pagetable.h"
struct iopt_pages_list { … };
struct iopt_area *iopt_area_contig_init(struct iopt_area_contig_iter *iter,
struct io_pagetable *iopt,
unsigned long iova,
unsigned long last_iova)
{ … }
struct iopt_area *iopt_area_contig_next(struct iopt_area_contig_iter *iter)
{ … }
static bool __alloc_iova_check_hole(struct interval_tree_double_span_iter *span,
unsigned long length,
unsigned long iova_alignment,
unsigned long page_offset)
{ … }
static bool __alloc_iova_check_used(struct interval_tree_span_iter *span,
unsigned long length,
unsigned long iova_alignment,
unsigned long page_offset)
{ … }
static int iopt_alloc_iova(struct io_pagetable *iopt, unsigned long *iova,
unsigned long uptr, unsigned long length)
{ … }
static int iopt_check_iova(struct io_pagetable *iopt, unsigned long iova,
unsigned long length)
{ … }
static int iopt_insert_area(struct io_pagetable *iopt, struct iopt_area *area,
struct iopt_pages *pages, unsigned long iova,
unsigned long start_byte, unsigned long length,
int iommu_prot)
{ … }
static struct iopt_area *iopt_area_alloc(void)
{ … }
static int iopt_alloc_area_pages(struct io_pagetable *iopt,
struct list_head *pages_list,
unsigned long length, unsigned long *dst_iova,
int iommu_prot, unsigned int flags)
{ … }
static void iopt_abort_area(struct iopt_area *area)
{ … }
void iopt_free_pages_list(struct list_head *pages_list)
{ … }
static int iopt_fill_domains_pages(struct list_head *pages_list)
{ … }
int iopt_map_pages(struct io_pagetable *iopt, struct list_head *pages_list,
unsigned long length, unsigned long *dst_iova,
int iommu_prot, unsigned int flags)
{ … }
int iopt_map_user_pages(struct iommufd_ctx *ictx, struct io_pagetable *iopt,
unsigned long *iova, void __user *uptr,
unsigned long length, int iommu_prot,
unsigned int flags)
{ … }
struct iova_bitmap_fn_arg { … };
static int __iommu_read_and_clear_dirty(struct iova_bitmap *bitmap,
unsigned long iova, size_t length,
void *opaque)
{ … }
static int
iommu_read_and_clear_dirty(struct iommu_domain *domain,
struct io_pagetable *iopt, unsigned long flags,
struct iommu_hwpt_get_dirty_bitmap *bitmap)
{ … }
int iommufd_check_iova_range(struct io_pagetable *iopt,
struct iommu_hwpt_get_dirty_bitmap *bitmap)
{ … }
int iopt_read_and_clear_dirty_data(struct io_pagetable *iopt,
struct iommu_domain *domain,
unsigned long flags,
struct iommu_hwpt_get_dirty_bitmap *bitmap)
{ … }
static int iopt_clear_dirty_data(struct io_pagetable *iopt,
struct iommu_domain *domain)
{ … }
int iopt_set_dirty_tracking(struct io_pagetable *iopt,
struct iommu_domain *domain, bool enable)
{ … }
int iopt_get_pages(struct io_pagetable *iopt, unsigned long iova,
unsigned long length, struct list_head *pages_list)
{ … }
static int iopt_unmap_iova_range(struct io_pagetable *iopt, unsigned long start,
unsigned long last, unsigned long *unmapped)
{ … }
int iopt_unmap_iova(struct io_pagetable *iopt, unsigned long iova,
unsigned long length, unsigned long *unmapped)
{ … }
int iopt_unmap_all(struct io_pagetable *iopt, unsigned long *unmapped)
{ … }
int iopt_set_allow_iova(struct io_pagetable *iopt,
struct rb_root_cached *allowed_iova)
{ … }
int iopt_reserve_iova(struct io_pagetable *iopt, unsigned long start,
unsigned long last, void *owner)
{ … }
static void __iopt_remove_reserved_iova(struct io_pagetable *iopt, void *owner)
{ … }
void iopt_remove_reserved_iova(struct io_pagetable *iopt, void *owner)
{ … }
void iopt_init_table(struct io_pagetable *iopt)
{ … }
void iopt_destroy_table(struct io_pagetable *iopt)
{ … }
static void iopt_unfill_domain(struct io_pagetable *iopt,
struct iommu_domain *domain)
{ … }
static int iopt_fill_domain(struct io_pagetable *iopt,
struct iommu_domain *domain)
{ … }
static int iopt_check_iova_alignment(struct io_pagetable *iopt,
unsigned long new_iova_alignment)
{ … }
int iopt_table_add_domain(struct io_pagetable *iopt,
struct iommu_domain *domain)
{ … }
static int iopt_calculate_iova_alignment(struct io_pagetable *iopt)
{ … }
void iopt_table_remove_domain(struct io_pagetable *iopt,
struct iommu_domain *domain)
{ … }
static int iopt_area_split(struct iopt_area *area, unsigned long iova)
{ … }
int iopt_cut_iova(struct io_pagetable *iopt, unsigned long *iovas,
size_t num_iovas)
{ … }
void iopt_enable_large_pages(struct io_pagetable *iopt)
{ … }
int iopt_disable_large_pages(struct io_pagetable *iopt)
{ … }
int iopt_add_access(struct io_pagetable *iopt, struct iommufd_access *access)
{ … }
void iopt_remove_access(struct io_pagetable *iopt,
struct iommufd_access *access,
u32 iopt_access_list_id)
{ … }
int iopt_table_enforce_dev_resv_regions(struct io_pagetable *iopt,
struct device *dev,
phys_addr_t *sw_msi_start)
{ … }