From nobody Fri Oct 13 18:27:33 2023 X-Original-To: dev-commits-src-main@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 4S6Zjy1T6Bz4wbZ6; Fri, 13 Oct 2023 18:27: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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4S6Zjy0wwFz4RNN; Fri, 13 Oct 2023 18:27:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697221654; 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=Ts9qm/6xeI9spNVAjewEs2BKOqCbJM727jqGKnFuuGc=; b=hKnITVjanAvWYljc7fQAEyxPruhTJgQwRB94olKRwN1+MofNMk8TSG9J266XAl831NkYTS Bz2lxs+SRUZ9P9o86KitrcmRVeaxPnsNKx6maGA8ZDBJrK5zR+GxZZ6tU/xZa70jbdwfnH NBFUvW9B3Q5/5E/c/jVQCJuwnwgTk8ZuNNiab1hc6kIOqO+H6sZiA/lkPN02rqrcveNX1N jeyUCZ+MX5u2sQZO/TvdS9q8i9931FVUwl02LhKG7xKwQdwV8WfiB0TyvUbmVdKgXitIfd LkFZTnfgLdiT0+A012KzNWX/XVs5UDMVJkBdCppQzYqfiqOmt3wVmtFF07KiBw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697221654; a=rsa-sha256; cv=none; b=cC84MFQgL4f/wR1WrKa0XXlSc20w+jsASNuNbUdyTQ+cdTHJuOoLc3WT4bBSRsp33IhYs5 T+GqoQqq7mvQxzleGygQ+mzzTjLyQlA+L7Mkn4A7Uq3TMGbu/ByBiCn5gzgzQA784gYRqw jA8BcgnWNvj3sKDPnu8FgODbHXABxqIXg5R6bUbSWwiM7bJtArH/0QaxIseUmOIDYzIGYy McVegVJN0ijUzcZD45VEeccKyipbSXGbWnZhnstd8AfXUXXJW8pvjbIOhQy+OKEKNODJN5 ayx3bgmvyEGegzdl84jxkZcEEngT6fmqnlLTrKypmAPHbPJcj4N0TCtfosq5VA== 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=1697221654; 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=Ts9qm/6xeI9spNVAjewEs2BKOqCbJM727jqGKnFuuGc=; b=o6A+XZl3L9UHsfXCcS2kmDUzeGlS0Z3KVwZkN4Ybl/JtN3d1K9ouEn2iLEN83luovbbdw/ B6NwLQzaCT2bkutcpUmCFoZnqQHfOsptmLeHYYSb0P+SPma/Fs+PgzmJbHyBNIEWBQLTIz 5n6KdP8d4BqKanxYAJpz8fNR+YECqZ1oy9Oi+wbixgkPRLLS/Fq23mGWsMsOWa/5h1uSIC wxxjBSaXnrPlTJFSGyMCD8zghMgyGvyy+gaVs/cQJ64OuuLPYaIudfYNX1FK16RkMufTjA qbBiEWFg6LFFz3BCVcRO8M84zv0lSREWutq6EYc66d1HAilSJtHoZgpkuRkMMg== 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 4S6Zjx75P7zyqr; Fri, 13 Oct 2023 18:27:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39DIRX3M082744; Fri, 13 Oct 2023 18:27:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39DIRXsu082741; Fri, 13 Oct 2023 18:27:33 GMT (envelope-from git) Date: Fri, 13 Oct 2023 18:27:33 GMT Message-Id: <202310131827.39DIRXsu082741@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 74e4a8d208f0 - main - pmap: add pmap_kextract(9) man page List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 74e4a8d208f0b3cf2525e3786f3efba71fcdb752 Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=74e4a8d208f0b3cf2525e3786f3efba71fcdb752 commit 74e4a8d208f0b3cf2525e3786f3efba71fcdb752 Author: Mina Galić AuthorDate: 2023-08-23 00:12:49 +0000 Commit: Mitchell Horne CommitDate: 2023-10-13 18:27:24 +0000 pmap: add pmap_kextract(9) man page Add a man page for pmap_kextract(9), with alias to vtophys(9). This man page is based on pmap_extract(9). Add it as cross reference in pmap(9), and add comments above the function implementations. Co-authored-by: Graham Perrin Co-authored-by: mhorne Sponsored by: The FreeBSD Foundation Pull Request: https://github.com/freebsd/freebsd-src/pull/827 --- share/man/man9/Makefile | 2 ++ share/man/man9/pmap.9 | 1 + share/man/man9/pmap_kextract.9 | 65 ++++++++++++++++++++++++++++++++++++++++++ sys/amd64/amd64/pmap.c | 8 +++++- sys/arm64/arm64/pmap.c | 6 ++++ sys/riscv/riscv/pmap.c | 6 ++++ 6 files changed, 87 insertions(+), 1 deletion(-) diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 0b56a47db332..6768f52a38d6 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -268,6 +268,7 @@ MAN= accept_filter.9 \ pmap_copy.9 \ pmap_enter.9 \ pmap_extract.9 \ + pmap_kextract.9 \ pmap_growkernel.9 \ pmap_init.9 \ pmap_is_modified.9 \ @@ -1807,6 +1808,7 @@ MLINKS+=PHOLD.9 PRELE.9 \ PHOLD.9 PROC_ASSERT_NOT_HELD.9 MLINKS+=pmap_copy.9 pmap_copy_page.9 MLINKS+=pmap_extract.9 pmap_extract_and_hold.9 +MLINKS+=pmap_kextract.9 vtophys.9 MLINKS+=pmap_init.9 pmap_init2.9 MLINKS+=pmap_is_modified.9 pmap_ts_referenced.9 MLINKS+=pmap_pinit.9 pmap_pinit0.9 \ diff --git a/share/man/man9/pmap.9 b/share/man/man9/pmap.9 index 3f6a0f63c264..db27fe880afc 100644 --- a/share/man/man9/pmap.9 +++ b/share/man/man9/pmap.9 @@ -97,6 +97,7 @@ operation. .Xr pmap_init2 9 , .Xr pmap_is_modified 9 , .Xr pmap_is_prefaultable 9 , +.Xr pmap_kextract 9 , .Xr pmap_map 9 , .Xr pmap_mincore 9 , .Xr pmap_object_init_pt 9 , diff --git a/share/man/man9/pmap_kextract.9 b/share/man/man9/pmap_kextract.9 new file mode 100644 index 000000000000..dd73446648f2 --- /dev/null +++ b/share/man/man9/pmap_kextract.9 @@ -0,0 +1,65 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.\" Copyright (c) 2023 The FreeBSD Foundation +.\" +.\" This manual page was written by Mina Galić under +.\" sponsorship from the FreeBSD Foundation. +.\" +.Dd August 24, 2023 +.Dt PMAP_KEXTRACT 9 +.Os +.Sh NAME +.Nm pmap_kextract , +.Nm vtophys +.Nd extract a physical address from the kernel page table +.Sh SYNOPSIS +.In sys/param.h +.In vm/vm.h +.In vm/pmap.h +.Ft vm_paddr_t +.Fo pmap_kextract +.Fa "vm_offset_t va" +.Fc +.Ft vm_paddr_t +.Fo vtophys +.Fa "vm_offset_t va" +.Fc +.Sh DESCRIPTION +The +.Fn pmap_kextract +function retrieves the underlying physical memory address corresponding to the given kernel virtual address +.Fa va . +The value of +.Fa va +must correlate to an active mapping in the kernel address space. +.Pp +.Fn vtophys +is an alias for +.Fn pmap_kextract +and behaves identically. +.Sh RETURN VALUES +The +.Fn pmap_kextract +function will return the physical address +.Pq Vt vm_paddr_t +associated with the kernel virtual address +.Fa va . +.Pp +.Fn pmap_kextract +generally does not fail. +However, if supplied with an illegitimate value for +.Fa va , +the function may return zero, an invalid non-zero value, or call +.Xr panic 9 . +.Sh SEE ALSO +.Xr pmap 9 , +.Xr pmap_extract 9 +.Sh AUTHORS +.An -nosplit +This manual page was written by +.An Mina Galić Aq Mt FreeBSD@igalic.co , +based on the +.Xr pmap_extract 9 +page written by +.An Bruce M Simpson Aq Mt bms@spc.org . diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index ff83d8749313..8c438cfb4639 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -3846,7 +3846,7 @@ pmap_flush_cache_phys_range(vm_paddr_t spa, vm_paddr_t epa, vm_memattr_t mattr) * Extract the physical page address associated * with the given map/virtual_address pair. */ -vm_paddr_t +vm_paddr_t pmap_extract(pmap_t pmap, vm_offset_t va) { pdp_entry_t *pdpe; @@ -3933,6 +3933,12 @@ out: return (m); } +/* + * Routine: pmap_kextract + * Function: + * Extract the physical page address associated with the given kernel + * virtual address. + */ vm_paddr_t pmap_kextract(vm_offset_t va) { diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index 6f2afa0b98a3..8c2c6f9d7b81 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -1949,6 +1949,12 @@ pmap_klookup(vm_offset_t va, vm_paddr_t *pa) return (true); } +/* + * Routine: pmap_kextract + * Function: + * Extract the physical page address associated with the given kernel + * virtual address. + */ vm_paddr_t pmap_kextract(vm_offset_t va) { diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index 49ee54b37918..66054898b281 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -970,6 +970,12 @@ pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot) return (m); } +/* + * Routine: pmap_kextract + * Function: + * Extract the physical page address associated with the given kernel + * virtual address. + */ vm_paddr_t pmap_kextract(vm_offset_t va) {