@@ -1942,52 +1942,44 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
1942
1942
return 0 ;
1943
1943
}
1944
1944
1945
- context_clear_entry (context );
1946
-
1947
- id = domain -> id ;
1948
1945
pgd = domain -> pgd ;
1949
1946
1950
- if (domain_type_is_vm_or_si (domain )) {
1951
- if (domain_type_is_vm (domain )) {
1952
- id = __iommu_attach_domain (domain , iommu );
1953
- if (id < 0 ) {
1954
- spin_unlock_irqrestore (& iommu -> lock , flags );
1955
- pr_err ("%s: No free domain ids\n" , iommu -> name );
1956
- return - EFAULT ;
1957
- }
1958
- }
1959
-
1960
- /* Skip top levels of page tables for
1961
- * iommu which has less agaw than default.
1962
- * Unnecessary for PT mode.
1963
- */
1964
- if (translation != CONTEXT_TT_PASS_THROUGH ) {
1965
- for (agaw = domain -> agaw ; agaw != iommu -> agaw ; agaw -- ) {
1966
- pgd = phys_to_virt (dma_pte_addr (pgd ));
1967
- if (!dma_pte_present (pgd )) {
1968
- spin_unlock_irqrestore (& iommu -> lock , flags );
1969
- return - ENOMEM ;
1970
- }
1971
- }
1972
- }
1947
+ id = __iommu_attach_domain (domain , iommu );
1948
+ if (id < 0 ) {
1949
+ spin_unlock_irqrestore (& iommu -> lock , flags );
1950
+ pr_err ("%s: No free domain ids\n" , iommu -> name );
1951
+ return - EFAULT ;
1973
1952
}
1974
1953
1954
+ context_clear_entry (context );
1975
1955
context_set_domain_id (context , id );
1976
1956
1957
+ /*
1958
+ * Skip top levels of page tables for iommu which has less agaw
1959
+ * than default. Unnecessary for PT mode.
1960
+ */
1977
1961
if (translation != CONTEXT_TT_PASS_THROUGH ) {
1962
+ for (agaw = domain -> agaw ; agaw != iommu -> agaw ; agaw -- ) {
1963
+ pgd = phys_to_virt (dma_pte_addr (pgd ));
1964
+ if (!dma_pte_present (pgd )) {
1965
+ spin_unlock_irqrestore (& iommu -> lock , flags );
1966
+ return - ENOMEM ;
1967
+ }
1968
+ }
1969
+
1978
1970
info = iommu_support_dev_iotlb (domain , iommu , bus , devfn );
1979
1971
translation = info ? CONTEXT_TT_DEV_IOTLB :
1980
1972
CONTEXT_TT_MULTI_LEVEL ;
1981
- }
1982
- /*
1983
- * In pass through mode, AW must be programmed to indicate the largest
1984
- * AGAW value supported by hardware. And ASR is ignored by hardware.
1985
- */
1986
- if (unlikely (translation == CONTEXT_TT_PASS_THROUGH ))
1987
- context_set_address_width (context , iommu -> msagaw );
1988
- else {
1973
+
1989
1974
context_set_address_root (context , virt_to_phys (pgd ));
1990
1975
context_set_address_width (context , iommu -> agaw );
1976
+ } else {
1977
+ /*
1978
+ * In pass through mode, AW must be programmed to
1979
+ * indicate the largest AGAW value supported by
1980
+ * hardware. And ASR is ignored by hardware.
1981
+ */
1982
+ context_set_address_width (context , iommu -> msagaw );
1991
1983
}
1992
1984
1993
1985
context_set_translation_type (context , translation );
0 commit comments