@@ -1814,11 +1814,11 @@ static int iopt_pages_fill_from_domain(struct iopt_pages *pages,
1814
1814
return 0 ;
1815
1815
}
1816
1816
1817
- static int iopt_pages_fill_from_mm (struct iopt_pages * pages ,
1818
- struct pfn_reader_user * user ,
1819
- unsigned long start_index ,
1820
- unsigned long last_index ,
1821
- struct page * * out_pages )
1817
+ static int iopt_pages_fill (struct iopt_pages * pages ,
1818
+ struct pfn_reader_user * user ,
1819
+ unsigned long start_index ,
1820
+ unsigned long last_index ,
1821
+ struct page * * out_pages )
1822
1822
{
1823
1823
unsigned long cur_index = start_index ;
1824
1824
int rc ;
@@ -1892,8 +1892,8 @@ int iopt_pages_fill_xarray(struct iopt_pages *pages, unsigned long start_index,
1892
1892
1893
1893
/* hole */
1894
1894
cur_pages = out_pages + (span .start_hole - start_index );
1895
- rc = iopt_pages_fill_from_mm (pages , & user , span .start_hole ,
1896
- span .last_hole , cur_pages );
1895
+ rc = iopt_pages_fill (pages , & user , span .start_hole ,
1896
+ span .last_hole , cur_pages );
1897
1897
if (rc )
1898
1898
goto out_clean_xa ;
1899
1899
rc = pages_to_xarray (& pages -> pinned_pfns , span .start_hole ,
@@ -1973,6 +1973,10 @@ static int iopt_pages_rw_page(struct iopt_pages *pages, unsigned long index,
1973
1973
struct page * page = NULL ;
1974
1974
int rc ;
1975
1975
1976
+ if (IS_ENABLED (CONFIG_IOMMUFD_TEST ) &&
1977
+ WARN_ON (pages -> type != IOPT_ADDRESS_USER ))
1978
+ return - EINVAL ;
1979
+
1976
1980
if (!mmget_not_zero (pages -> source_mm ))
1977
1981
return iopt_pages_rw_slow (pages , index , index , offset , data ,
1978
1982
length , flags );
@@ -2028,6 +2032,15 @@ int iopt_pages_rw_access(struct iopt_pages *pages, unsigned long start_byte,
2028
2032
if ((flags & IOMMUFD_ACCESS_RW_WRITE ) && !pages -> writable )
2029
2033
return - EPERM ;
2030
2034
2035
+ if (pages -> type == IOPT_ADDRESS_FILE )
2036
+ return iopt_pages_rw_slow (pages , start_index , last_index ,
2037
+ start_byte % PAGE_SIZE , data , length ,
2038
+ flags );
2039
+
2040
+ if (IS_ENABLED (CONFIG_IOMMUFD_TEST ) &&
2041
+ WARN_ON (pages -> type != IOPT_ADDRESS_USER ))
2042
+ return - EINVAL ;
2043
+
2031
2044
if (!(flags & IOMMUFD_ACCESS_RW_KTHREAD ) && change_mm ) {
2032
2045
if (start_index == last_index )
2033
2046
return iopt_pages_rw_page (pages , start_index ,
0 commit comments