From nobody Mon Sep 02 08:50:35 2024 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 4Wy2XC6DRhz5MnqY; Mon, 02 Sep 2024 08:50:35 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Wy2XC5YWBz421c; Mon, 2 Sep 2024 08:50:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725267035; 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=wZ+TyEe0i75FreZwL9xORTfDOdomffbl5Wm7TAYtUPI=; b=O67F+DHd30Ag5dJFRGrMOAgYauomVpOeqd/m5v7FeO3w4zGF9rgUN4eUhLvWwwyvgxYKgx eOdXLWgXhOAu/8pWw9antyhsrZnkyMBfnCoybr7tli7gEO7rRgrGlXHzOLotF3c6kBjrjV alTCEjVHsHDD9atV6twwmCzOdfTHTUIk3jTPeMChs0k/FUjAJi78LuTSnBbEWAQbWmTSeD nPTy/OcHJM+QJCy4eOREJVsZHgIIZXt3McNlzpb5tOXDGolcxVNd68Z2orz5uRJiVPBzhS e3romfLxwuxHD1GwESTF1D06meeLDGrSVUIsH5l3z4becThXnAGKtMWZRjCsWA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725267035; a=rsa-sha256; cv=none; b=xWk2hOPpGo050tPVVcW7jwoF0eh1lBW1sx6lRaQv5cHseC97z4edoHdbVQR7blgnhcpPSA lNivUmXbPrSVWYL7zYuiyzPoKakGIEzhGAIODqUmiZg/uzVWAoGtdagVoDUF0XrBEJHSyZ EWmdbsanvH2XRvqMvk+TiGQkYpGQbLDBq0w/lrqVFxa9QJoMbwkhCcdntLN1xoAqg8rZOW ePhmTp7Hhvae0dSRCG5dH2kiMO+oSbOGvE+KXDP1s70gBqmdjrcMroC5kOrU/YqwXfO5D3 j5N4OMIPdfoXTRZyy+shqB2wYNx2DDSE9uYoR9HRK1UXqnC4OKU8+Qx6kONqRA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725267035; 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=wZ+TyEe0i75FreZwL9xORTfDOdomffbl5Wm7TAYtUPI=; b=vsS7Wy5ZCauObQcyZ/tnL5eS+qfbEOgQAlqhfLeJW6hNpUvrVcD2WDQ6LNsYuJMcXFygy1 QGLI9/i2qR1Mt13L7g1p1KWhRQqFPOF0EZMvx+ndZIZyZxxX298LJuLGGdrzMl3nZ5dX6m Ggs9iACh0Iix7hT2TlmqOA6HZKNzdUhEAguMtVetcBSBNzxDsUvDgVAKc9+my8TrXS6ca2 YDDpiJNDDHjXrlY1FHNUnZ2wrlSbDsFA2o08IyB9DFTWXRTfA1XO/j++fwbeMdoNS1WU+9 t5UHKsJYLwArAtDn10iabN5Ngp1Hd5+Ts7uSwCQ86IC872fWg3zs8a1IDUXpoQ== 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 4Wy2XC4zC6z156d; Mon, 2 Sep 2024 08:50:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4828oZsA006798; Mon, 2 Sep 2024 08:50:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4828oZal006795; Mon, 2 Sep 2024 08:50:35 GMT (envelope-from git) Date: Mon, 2 Sep 2024 08:50:35 GMT Message-Id: <202409020850.4828oZal006795@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: bdbb0be0436a - stable/14 - vm: Add kva_alloc_aligned 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: bdbb0be0436a6db70c043a3cd8710de59b497e88 Auto-Submitted: auto-generated The branch stable/14 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=bdbb0be0436a6db70c043a3cd8710de59b497e88 commit bdbb0be0436a6db70c043a3cd8710de59b497e88 Author: Andrew Turner AuthorDate: 2023-11-29 12:54:49 +0000 Commit: Andrew Turner CommitDate: 2024-09-02 08:43:18 +0000 vm: Add kva_alloc_aligned Add a function like kva_alloc that allows us to specify the alignment of the virtual address space returned. Reviewed by: alc, kib, markj Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D42788 (cherry picked from commit 839999e7efdc980d5ada92ea93719c7e29765809) --- sys/vm/vm_extern.h | 1 + sys/vm/vm_kern.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h index 4bcd8ac601ae..566c837aab7e 100644 --- a/sys/vm/vm_extern.h +++ b/sys/vm/vm_extern.h @@ -49,6 +49,7 @@ struct domainset; /* These operate on kernel virtual addresses only. */ vm_offset_t kva_alloc(vm_size_t); +vm_offset_t kva_alloc_aligned(vm_size_t, vm_size_t); void kva_free(vm_offset_t, vm_size_t); /* These operate on pageable virtual addresses. */ diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c index 35dbae20449f..387d73d2e46e 100644 --- a/sys/vm/vm_kern.c +++ b/sys/vm/vm_kern.c @@ -157,6 +157,27 @@ kva_alloc(vm_size_t size) return (addr); } +/* + * kva_alloc_aligned: + * + * Allocate a virtual address range as in kva_alloc where the base + * address is aligned to align. + */ +vm_offset_t +kva_alloc_aligned(vm_size_t size, vm_size_t align) +{ + vm_offset_t addr; + + TSENTER(); + size = round_page(size); + if (vmem_xalloc(kernel_arena, size, align, 0, 0, VMEM_ADDR_MIN, + VMEM_ADDR_MAX, M_BESTFIT | M_NOWAIT, &addr)) + return (0); + TSEXIT(); + + return (addr); +} + /* * kva_free: *