From nobody Wed Jul 06 17:05:01 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E952F1D0C677; Wed, 6 Jul 2022 17:05:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LdQrt0w3vz3CKC; Wed, 6 Jul 2022 17:05:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657127102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XK/bDj8kPlnsdCtAzkIU7B1GK3n0yshiSGbZ09utKzQ=; b=YZONzo9vIW/b5L45Y7PeMCaHeASM2x7d0Iw5ze4yost6LKDLI2wK809BfuXmnB7R3wnxWC B/vN+YqBLvI03Ye3flHT3rXz9SWU8G+uNz9QPA9b8wFGonNSnGedxjHqMH6YlrDIFp0e5o BoxIkP6L54XJCkFs/iSHgKLFE+VMsYk8FeUEAV+hNROfx/OHiq7xwICKoUMztlNuqAz9La MpjPlw+QWwe3J2f65uz9snMN3EOmDQOzKiKntvRNUWdjtfTRCBuSKNAUDHAETSexV8yBcG O6XQU/2DERGE/VB1COZWMbtc2u4z/M+opCVEaWfQze2n4vDdIMr2we8esqnXbw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B671C1E25D; Wed, 6 Jul 2022 17:05:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 266H51Lk083662; Wed, 6 Jul 2022 17:05:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 266H51U5083661; Wed, 6 Jul 2022 17:05:01 GMT (envelope-from git) Date: Wed, 6 Jul 2022 17:05:01 GMT Message-Id: <202207061705.266H51U5083661@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Doug Moore Subject: git: 2d8b9313f47e - stable/13 - iommu_gas: pass size to iommu_map without rounding List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dougm X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2d8b9313f47e0ae9223f060b8363e18eb7ff1908 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657127102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XK/bDj8kPlnsdCtAzkIU7B1GK3n0yshiSGbZ09utKzQ=; b=Bo+91Qnym/MpLnQLjfEUdGRlJttSDS02gosDVLYC7a47nMoR/fX+l3dxDFzRICNKxKSsvB GnWNI3wBzffTEQ4/Sdwsj/OitOdY8mOxevWYB37MWxwLYvop2xOSJS7bIBAnd1Uqy95m9A iEqYA0BLwr7yKHtH7NRpCWL3kxC9VCysVTlQkYkUH7L0YC4w7ggIUL+xjMVGVwUt+XijV2 SbZOyq3u8qL4fWvLsKPCCJBoYRsgZis4uLHcr9PVC9MXXq+aLCNCdglqhWK5ZewvdMnfbT M3eH4GtUP5dWr6HwJ6D8n+/AQM4OmBnTseyqvgVAjlbigfaR/UXmRGxGz6iwyQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657127102; a=rsa-sha256; cv=none; b=lo1Y2+4oTex0Hcnd2kQ9AIDXy6md70i1r1tMhW/c1XaHiFxe9otbzEHDnD6IiUm+V8AYAu 8J2JtJByALz5GDlwPkAnoXyEqXymXHWUYSqNNAI9MGmLX5cX8Ne0bGfuMjjvH5xgoSgjS/ goJ5CWkcw82BqN5YV2BrOylQDIMMTKZT2YAJjmj2luSKDUHBct0t/35W5WIfw7Ykeqwelo rd4GYjH0l+2BABkLnARhOuE3V3abBM/Rx2ited9Ty5qePHyT8EXPXgL0Fc8Pe1VzvWZJeI l1Y3YdmkGE63GQo5sOtUal/hw5EQaF0Ob2Ml94ZRcgTcFW3becHeoZFiuXTLbg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=2d8b9313f47e0ae9223f060b8363e18eb7ff1908 commit 2d8b9313f47e0ae9223f060b8363e18eb7ff1908 Author: Doug Moore AuthorDate: 2022-06-10 18:56:54 +0000 Commit: Doug Moore CommitDate: 2022-07-06 16:41:50 +0000 iommu_gas: pass size to iommu_map without rounding Let the caller to iommu_map pass the size parameter without rounding it up to a multiple of page size. Let iommu_map round it up when necessary, which is not all of the time, so that in some cases less space is reserved. Reviewed by: alc, kib (previous version) Tested by: pho, br Discussed with: andrew MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D35424 (cherry picked from commit 19bb5a7244ff0374f44068a20df9393a1c88de5d) --- sys/arm64/arm64/gicv3_its.c | 3 ++- sys/dev/iommu/busdma_iommu.c | 3 +-- sys/dev/iommu/iommu_gas.c | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sys/arm64/arm64/gicv3_its.c b/sys/arm64/arm64/gicv3_its.c index 35a5642a95dc..2af20e5d03fc 100644 --- a/sys/arm64/arm64/gicv3_its.c +++ b/sys/arm64/arm64/gicv3_its.c @@ -1457,7 +1457,8 @@ gicv3_iommu_init(device_t dev, device_t child, struct iommu_domain **domain) ctx = iommu_get_dev_ctx(child); if (ctx == NULL) return (ENXIO); - error = iommu_map_msi(ctx, PAGE_SIZE, GITS_TRANSLATER, + /* Map the page containing the GITS_TRANSLATER register. */ + error = iommu_map_msi(ctx, PAGE_SIZE, 0, IOMMU_MAP_ENTRY_WRITE, IOMMU_MF_CANWAIT, &sc->ma); *domain = iommu_get_ctx_domain(ctx); diff --git a/sys/dev/iommu/busdma_iommu.c b/sys/dev/iommu/busdma_iommu.c index 89e5e1bcff39..da2318eac393 100644 --- a/sys/dev/iommu/busdma_iommu.c +++ b/sys/dev/iommu/busdma_iommu.c @@ -593,8 +593,7 @@ iommu_bus_dmamap_load_something1(struct bus_dma_tag_iommu *tag, if (seg + 1 < tag->common.nsegments) gas_flags |= IOMMU_MF_CANSPLIT; - error = iommu_map(domain, &tag->common, - round_page(offset + buflen1), + error = iommu_map(domain, &tag->common, buflen1, offset, e_flags, gas_flags, ma + idx, &entry); if (error != 0) break; diff --git a/sys/dev/iommu/iommu_gas.c b/sys/dev/iommu/iommu_gas.c index d1a46ab6ee8f..f7c38e8d65e8 100644 --- a/sys/dev/iommu/iommu_gas.c +++ b/sys/dev/iommu/iommu_gas.c @@ -364,7 +364,8 @@ iommu_gas_match_insert(struct iommu_gas_match_args *a) * The page sized gap is created between consequent * allocations to ensure that out-of-bounds accesses fault. */ - a->entry->end = a->entry->start + a->size; + a->entry->end = a->entry->start + + roundup2(a->size + a->offset, IOMMU_PAGE_SIZE); found = iommu_gas_rb_insert(a->domain, a->entry); KASSERT(found, ("found dup %p start %jx size %jx", @@ -381,7 +382,8 @@ iommu_gas_lowermatch(struct iommu_gas_match_args *a, struct iommu_map_entry *ent * If the subtree doesn't have free space for the requested allocation * plus two guard pages, give up. */ - if (entry->free_down < a->size + a->offset + 2 * IOMMU_PAGE_SIZE) + if (entry->free_down < 2 * IOMMU_PAGE_SIZE + + roundup2(a->size + a->offset, IOMMU_PAGE_SIZE)) return (ENOMEM); if (entry->first >= a->common->lowaddr) return (ENOMEM); @@ -415,7 +417,8 @@ iommu_gas_uppermatch(struct iommu_gas_match_args *a, struct iommu_map_entry *ent * If the subtree doesn't have free space for the requested allocation * plus two guard pages, give up. */ - if (entry->free_down < a->size + a->offset + 2 * IOMMU_PAGE_SIZE) + if (entry->free_down < 2 * IOMMU_PAGE_SIZE + + roundup2(a->size + a->offset, IOMMU_PAGE_SIZE)) return (ENOMEM); if (entry->last < a->common->highaddr) return (ENOMEM); @@ -450,7 +453,6 @@ iommu_gas_find_space(struct iommu_domain *domain, IOMMU_DOMAIN_ASSERT_LOCKED(domain); KASSERT(entry->flags == 0, ("dirty entry %p %p", domain, entry)); - KASSERT((size & IOMMU_PAGE_MASK) == 0, ("size %jx", (uintmax_t)size)); a.domain = domain; a.size = size;