From nobody Fri Nov 19 19:06:04 2021 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 B99871899309; Fri, 19 Nov 2021 19:06:04 +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 4HwmND4Qhvz4RLS; Fri, 19 Nov 2021 19:06:04 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 7031A5C25; Fri, 19 Nov 2021 19:06:04 +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 1AJJ64dE097392; Fri, 19 Nov 2021 19:06:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AJJ64aZ097391; Fri, 19 Nov 2021 19:06:04 GMT (envelope-from git) Date: Fri, 19 Nov 2021 19:06:04 GMT Message-Id: <202111191906.1AJJ64aZ097391@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: 90d4da622592 - main - amd64: provide PHYS_IN_DMAP() and VIRT_IN_DMAP() 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: 90d4da62259299a8d91fed1121be97ac5b7b6b3c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=90d4da62259299a8d91fed1121be97ac5b7b6b3c commit 90d4da62259299a8d91fed1121be97ac5b7b6b3c Author: Mitchell Horne AuthorDate: 2021-11-17 15:29:02 +0000 Commit: Mitchell Horne CommitDate: 2021-11-19 19:05:52 +0000 amd64: provide PHYS_IN_DMAP() and VIRT_IN_DMAP() It is useful for quickly checking an address against the DMAP region. These definitions exist already on arm64 and riscv. Reviewed by: kib, markj MFC after: 3 days Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D32962 --- sys/amd64/include/vmparam.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/amd64/include/vmparam.h b/sys/amd64/include/vmparam.h index 6cb8b3f0071a..c841cc41f17b 100644 --- a/sys/amd64/include/vmparam.h +++ b/sys/amd64/include/vmparam.h @@ -239,16 +239,19 @@ * because the result is not actually accessed until later, but the early * vt fb startup needs to be reworked. */ +#define PHYS_IN_DMAP(pa) (dmaplimit == 0 || (pa) < dmaplimit) +#define VIRT_IN_DMAP(va) ((va) >= DMAP_MIN_ADDRESS && \ + (va) < (DMAP_MIN_ADDRESS + dmaplimit)) + #define PMAP_HAS_DMAP 1 #define PHYS_TO_DMAP(x) ({ \ - KASSERT(dmaplimit == 0 || (x) < dmaplimit, \ + KASSERT(PHYS_IN_DMAP(x), \ ("physical address %#jx not covered by the DMAP", \ (uintmax_t)x)); \ (x) | DMAP_MIN_ADDRESS; }) #define DMAP_TO_PHYS(x) ({ \ - KASSERT((x) < (DMAP_MIN_ADDRESS + dmaplimit) && \ - (x) >= DMAP_MIN_ADDRESS, \ + KASSERT(VIRT_IN_DMAP(x), \ ("virtual address %#jx not covered by the DMAP", \ (uintmax_t)x)); \ (x) & ~DMAP_MIN_ADDRESS; })