git: 4b4e8cb53abc - main - smmu: set guest address space range to 48-bit, which is a hardware limit in our configuration.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 21 Dec 2022 15:54:08 UTC
The branch main has been updated by br: URL: https://cgit.FreeBSD.org/src/commit/?id=4b4e8cb53abc1651e2f85c939c81393f05bd5fb9 commit 4b4e8cb53abc1651e2f85c939c81393f05bd5fb9 Author: Ruslan Bukin <br@FreeBSD.org> AuthorDate: 2022-12-20 11:25:18 +0000 Commit: Ruslan Bukin <br@FreeBSD.org> CommitDate: 2022-12-21 15:53:05 +0000 smmu: set guest address space range to 48-bit, which is a hardware limit in our configuration. Reviewed by: andrew Sponsored by: UKRI Differential Revision: https://reviews.freebsd.org/D37756 --- sys/arm64/iommu/iommu.c | 9 +++++---- sys/arm64/iommu/smmu.c | 14 +++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/sys/arm64/iommu/iommu.c b/sys/arm64/iommu/iommu.c index d24cad94e966..3451a002bef6 100644 --- a/sys/arm64/iommu/iommu.c +++ b/sys/arm64/iommu/iommu.c @@ -136,8 +136,9 @@ iommu_domain_alloc(struct iommu_unit *iommu) if (iodom == NULL) return (NULL); + KASSERT(iodom->end != 0, ("domain end is not set")); + iommu_domain_init(iommu, iodom, &domain_map_ops); - iodom->end = VM_MAXUSER_ADDRESS; iodom->iommu = iommu; iommu_gas_init_domain(iodom); @@ -168,11 +169,11 @@ iommu_domain_free(struct iommu_domain *iodom) } static void -iommu_tag_init(struct bus_dma_tag_iommu *t) +iommu_tag_init(struct iommu_domain *iodom, struct bus_dma_tag_iommu *t) { bus_addr_t maxaddr; - maxaddr = BUS_SPACE_MAXADDR; + maxaddr = MIN(iodom->end, BUS_SPACE_MAXADDR); t->common.ref_count = 0; t->common.impl = &bus_dma_iommu_impl; @@ -223,7 +224,7 @@ iommu_ctx_init(device_t requester, struct iommu_ctx *ioctx) tag->ctx = ioctx; tag->ctx->domain = iodom; - iommu_tag_init(tag); + iommu_tag_init(iodom, tag); return (error); } diff --git a/sys/arm64/iommu/smmu.c b/sys/arm64/iommu/smmu.c index 57f6826faa5e..e307440e725e 100644 --- a/sys/arm64/iommu/smmu.c +++ b/sys/arm64/iommu/smmu.c @@ -149,6 +149,9 @@ __FBSDID("$FreeBSD$"); #define SMMU_Q_ALIGN (64 * 1024) +#define MAXADDR_48BIT 0xFFFFFFFFFFFFUL +#define MAXADDR_52BIT 0xFFFFFFFFFFFFFUL + static struct resource_spec smmu_spec[] = { { SYS_RES_MEMORY, 0, RF_ACTIVE }, { SYS_RES_IRQ, 0, RF_ACTIVE }, @@ -1702,6 +1705,7 @@ smmu_map(device_t dev, struct iommu_domain *iodom, static struct iommu_domain * smmu_domain_alloc(device_t dev, struct iommu_unit *iommu) { + struct iommu_domain *iodom; struct smmu_domain *domain; struct smmu_unit *unit; struct smmu_softc *sc; @@ -1742,7 +1746,15 @@ smmu_domain_alloc(device_t dev, struct iommu_unit *iommu) LIST_INSERT_HEAD(&unit->domain_list, domain, next); IOMMU_UNLOCK(iommu); - return (&domain->iodom); + iodom = &domain->iodom; + + /* + * Use 48-bit address space regardless of VAX bit + * as we need 64k IOMMU_PAGE_SIZE for 52-bit space. + */ + iodom->end = MAXADDR_48BIT; + + return (iodom); } static void