@@ -1653,6 +1653,10 @@ static void do_attach(struct iommu_dev_data *dev_data,
1653
1653
domain -> dev_iommu [iommu -> index ] += 1 ;
1654
1654
domain -> dev_cnt += 1 ;
1655
1655
1656
+ /* Override supported page sizes */
1657
+ if (domain -> flags & PD_GIOV_MASK )
1658
+ domain -> domain .pgsize_bitmap = AMD_IOMMU_PGSIZES_V2 ;
1659
+
1656
1660
/* Update device table */
1657
1661
set_dte_entry (iommu , dev_data -> devid , domain ,
1658
1662
ats , dev_data -> iommu_v2 );
@@ -2032,6 +2036,24 @@ static int protection_domain_init_v1(struct protection_domain *domain, int mode)
2032
2036
return 0 ;
2033
2037
}
2034
2038
2039
+ static int protection_domain_init_v2 (struct protection_domain * domain )
2040
+ {
2041
+ spin_lock_init (& domain -> lock );
2042
+ domain -> id = domain_id_alloc ();
2043
+ if (!domain -> id )
2044
+ return - ENOMEM ;
2045
+ INIT_LIST_HEAD (& domain -> dev_list );
2046
+
2047
+ domain -> flags |= PD_GIOV_MASK ;
2048
+
2049
+ if (domain_enable_v2 (domain , 1 )) {
2050
+ domain_id_free (domain -> id );
2051
+ return - ENOMEM ;
2052
+ }
2053
+
2054
+ return 0 ;
2055
+ }
2056
+
2035
2057
static struct protection_domain * protection_domain_alloc (unsigned int type )
2036
2058
{
2037
2059
struct io_pgtable_ops * pgtbl_ops ;
@@ -2059,6 +2081,9 @@ static struct protection_domain *protection_domain_alloc(unsigned int type)
2059
2081
case AMD_IOMMU_V1 :
2060
2082
ret = protection_domain_init_v1 (domain , mode );
2061
2083
break ;
2084
+ case AMD_IOMMU_V2 :
2085
+ ret = protection_domain_init_v2 (domain );
2086
+ break ;
2062
2087
default :
2063
2088
ret = - EINVAL ;
2064
2089
}
0 commit comments