Skip to content

Commit a886d5a

Browse files
LuBaolujoergroedel
authored andcommitted
iommu/vt-d: Report real pgsize bitmap to iommu core
The pgsize bitmap is used to advertise the page sizes our hardware supports to the IOMMU core, which will then use this information to split physically contiguous memory regions it is mapping into page sizes that we support. Traditionally the IOMMU core just handed us the mappings directly, after making sure the size is an order of a 4KiB page and that the mapping has natural alignment. To retain this behavior, we currently advertise that we support all page sizes that are an order of 4KiB. We are about to utilize the new IOMMU map/unmap_pages APIs. We could change this to advertise the real page sizes we support. Signed-off-by: Lu Baolu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 13b6eb6 commit a886d5a

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

drivers/iommu/intel/iommu.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,6 @@
8585
#define LEVEL_STRIDE (9)
8686
#define LEVEL_MASK (((u64)1 << LEVEL_STRIDE) - 1)
8787

88-
/*
89-
* This bitmap is used to advertise the page sizes our hardware support
90-
* to the IOMMU core, which will then use this information to split
91-
* physically contiguous memory regions it is mapping into page sizes
92-
* that we support.
93-
*
94-
* Traditionally the IOMMU core just handed us the mappings directly,
95-
* after making sure the size is an order of a 4KiB page and that the
96-
* mapping has natural alignment.
97-
*
98-
* To retain this behavior, we currently advertise that we support
99-
* all page sizes that are an order of 4KiB.
100-
*
101-
* If at some point we'd like to utilize the IOMMU core's new behavior,
102-
* we could change this to advertise the real page sizes we support.
103-
*/
104-
#define INTEL_IOMMU_PGSIZES (~0xFFFUL)
105-
10688
static inline int agaw_to_level(int agaw)
10789
{
10890
return agaw + 2;
@@ -735,6 +717,23 @@ static int domain_update_device_node(struct dmar_domain *domain)
735717

736718
static void domain_update_iotlb(struct dmar_domain *domain);
737719

720+
/* Return the super pagesize bitmap if supported. */
721+
static unsigned long domain_super_pgsize_bitmap(struct dmar_domain *domain)
722+
{
723+
unsigned long bitmap = 0;
724+
725+
/*
726+
* 1-level super page supports page size of 2MiB, 2-level super page
727+
* supports page size of both 2MiB and 1GiB.
728+
*/
729+
if (domain->iommu_superpage == 1)
730+
bitmap |= SZ_2M;
731+
else if (domain->iommu_superpage == 2)
732+
bitmap |= SZ_2M | SZ_1G;
733+
734+
return bitmap;
735+
}
736+
738737
/* Some capabilities may be different across iommus */
739738
static void domain_update_iommu_cap(struct dmar_domain *domain)
740739
{
@@ -761,6 +760,7 @@ static void domain_update_iommu_cap(struct dmar_domain *domain)
761760
else
762761
domain->domain.geometry.aperture_end = __DOMAIN_MAX_ADDR(domain->gaw);
763762

763+
domain->domain.pgsize_bitmap |= domain_super_pgsize_bitmap(domain);
764764
domain_update_iotlb(domain);
765765
}
766766

@@ -5609,7 +5609,7 @@ const struct iommu_ops intel_iommu_ops = {
56095609
.dev_disable_feat = intel_iommu_dev_disable_feat,
56105610
.is_attach_deferred = intel_iommu_is_attach_deferred,
56115611
.def_domain_type = device_def_domain_type,
5612-
.pgsize_bitmap = INTEL_IOMMU_PGSIZES,
5612+
.pgsize_bitmap = SZ_4K,
56135613
#ifdef CONFIG_INTEL_IOMMU_SVM
56145614
.cache_invalidate = intel_iommu_sva_invalidate,
56155615
.sva_bind_gpasid = intel_svm_bind_gpasid,

0 commit comments

Comments
 (0)