From nobody Mon Sep 02 09:12:34 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 4Wy31Z2zrHz5Mqc7; Mon, 02 Sep 2024 09:12:34 +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 4Wy31Z1GV5z4CRQ; Mon, 2 Sep 2024 09:12:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725268354; 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=jLEHXvnlEU6I86I7i0y3KxRoKfE2Vw/AhHLVJ/6BRqc=; b=gjpxgzupbHrwEQaT9ym2b7Ga0kWg4m49R7/IKGs9xEJbOyk0WjImAzw0N+eHidKl/I6CPZ YRZrKWXlBYslrTq4G+wDXUoCZvm5PDlZqFrKQ9fVdcIVjcPiu6AMAlb8AxcvQLizKp0act +ThQ9VKkggLHUTJIAE3w5HLcBV6dTHNM2me5WPvbWjybg57bZXUWkWE5+EF1BwvNytpDMp l6ZH4GhpHJEXn3MEYBlvOS01/D8fhbMjE9jF7q2cznJcgjAZ9NcHMKi8HugQT8u3RDbY09 WSRyPXtoTG1neYg2g12DIKG5/ScSSLq6Oi5Bf5uJX7v3nJGiPnegszzxiKioxQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725268354; a=rsa-sha256; cv=none; b=tIOuJNathBoXHfqLyUHZbu7YEbbbM0Y6WrK6NNaZLbPettXc0/m5yAX+p3oSp3nsKP+2l+ gkKe51A5lA3qHB4L3RMtS+NKECOWHpiYl7wzBc+I57hGdw9mVPu9AftzVB2JGhSnMz+qn0 6yTWAsphg8Bxp6ADg95kcMUl+RvP4uXcnq5Brqo4b31oRoffAc89LjMtQP2XSrN4uXpvL4 /76ud7ifoa0DEoZo9icXVHysbDMSYlgpn27EbdrfQjg2vSfS0gARIWwnbRBjCr9XOxv+x6 ECJa5DLmlzUUbyPCdK8Eo6Fa8/x6jFdcE4V4J75z+3pKRveQdyxRBfO+zaXpNQ== 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=1725268354; 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=jLEHXvnlEU6I86I7i0y3KxRoKfE2Vw/AhHLVJ/6BRqc=; b=epL7gRfu4An9U9dycj5WbnWecDfFlwA/GK3R1iOnexvme68a3zDvrlBaKIpG0uwDikiSTx iohnmNieuQ9BdtwW2VeBgoZRML30HxyetOfShNX0fjxOGiYInZAeBJtBFbU78TdySPU46z tOW02E8xfkehavSHKA3vyBWkOl2P63IaKJjvf//s6hldHu/keIxYdTJRX3wpOEeqU9tPXI zLS8RB3NHgAMBqnFOo9EZb2emhnSg8prxuy1/kzmOE3Ekr/aXvTCafusb1FJDy8wINNW7M scjqJ1bQP8p5qG+ujmHgYXK+2CHOEeKG9dB/uo764qQKpSb3VVFg3CvhB8Zr/w== 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 4Wy31Z0qvTz167t; Mon, 2 Sep 2024 09:12:34 +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 4829CYf4049389; Mon, 2 Sep 2024 09:12:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4829CYrC049386; Mon, 2 Sep 2024 09:12:34 GMT (envelope-from git) Date: Mon, 2 Sep 2024 09:12:34 GMT Message-Id: <202409020912.4829CYrC049386@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: 8876ff3c4aae - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 8876ff3c4aae7713f57eceede0173732c73c01d6 Auto-Submitted: auto-generated The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=8876ff3c4aae7713f57eceede0173732c73c01d6 commit 8876ff3c4aae7713f57eceede0173732c73c01d6 Author: Andrew Turner AuthorDate: 2023-11-29 12:54:49 +0000 Commit: Andrew Turner CommitDate: 2024-09-02 09:11:57 +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 a1aba0ba5b26..c867d3c20eb2 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 ba3badf29c3b..defc862a4ac5 100644 --- a/sys/vm/vm_kern.c +++ b/sys/vm/vm_kern.c @@ -154,6 +154,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: *