From nobody Tue Oct 25 15:33:04 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 4MxbYY1dDkz4g6w8; Tue, 25 Oct 2022 15:33:05 +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 4MxbYY168zz43hp; Tue, 25 Oct 2022 15:33:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666711985; 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=jRaHiNXnCN9EMfWV+727Vv2wuW0OIpKWhgE6Cow2OD0=; b=TURLgIYfLoeQeP3Hvt6qHrp29Nw/O/S84KxMtuj/9adjkVUtu0QcGOG91FGEqWYLGrcTUa 2KPXfYNKWscoCU7lXtvhO8FuvLTBygmuKuHU/IPlnI+sZtIh/2vM8iba3DHYr34pchT9VO dyLUMn+eC5VtQDcZqyTv785qS3yQ1tasbrKeU0aG87677AXDG69V28f1U6b7FkOPCJ2+YT 9mDmhVpiUjIn00m7fldiWrLPLSkaNOeNQk9VmQaTHQLtHBT06Lc7vx3FIquZ9LJL7lapEb yS0UnIUHBbFXxxrauyLZjp1YVQK7VsYD7AY/XFlY5d7n3Gzksxy6ZcqwE2hwmw== 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 4MxbYY0DFHzjY6; Tue, 25 Oct 2022 15:33:05 +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 29PFX4gG051319; Tue, 25 Oct 2022 15:33:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29PFX4sq051318; Tue, 25 Oct 2022 15:33:04 GMT (envelope-from git) Date: Tue, 25 Oct 2022 15:33:04 GMT Message-Id: <202210251533.29PFX4sq051318@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: deb1e3b71998 - main - physmem: Add physmem_excluded to query if a region is excluded 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: deb1e3b719985466b0cc84825846519acdd0a2e7 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666711985; 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=jRaHiNXnCN9EMfWV+727Vv2wuW0OIpKWhgE6Cow2OD0=; b=xP7BNg+S8VgxBPKfhnh7PjH61HhOJ0eG8rGFhFzaOdzsWYtQox5fnTWQGUyluO+g+aizqi VYg2HQ8egMs1eT9WEDUHSypvmvJuyNChpibpAFa3WyyXnYrdUeEu2LG/byNyo65qXiXR2O uCSQPBKBHfL1fwrFyECqB+d01OxS4BiZW0D/H1ON495nrByp9++GG3ywV3ryl532MG67mF 7e4iFobgiq2E0mmUh1aTmEGH3Grqfdc+Z6mWtl1uiCS5u7vKEhPsf4auORhzMi/JFdcl/d gx0K/5yCw0guB62z6RV9OxRFhyM8ZWRHCyX2nZDnqY6jaiK3G8J5FPUBZ34peg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666711985; a=rsa-sha256; cv=none; b=C1kj3Ejvb7ZUadrmExx5O3FcsMFjT7lfHajT2UucuuFeQ3S9+LCJYhcZtPsDKaLjHTQDem 4DY+viTfgMBZxQC/iGiBfptiIipplH4wJRCUtBuhO7TV6Jg0otZk1ojakI3Zcns+FNGM5X Flg92S0ksuoxtoYaF8FLWUgpUZVl9Ev+LuY5obGny9v6SSw+G+dU9DjQxjCNVQtfghHvZS B9eRmrSBsS02VIjtNvA9hjpn1WhAVpEZliUk/k3/kG+fwQsyX2C+GPkQIsXfZhv14e7Oze oZpYTMkj25cY8qCQY61+Tv81OZvoDmOkw+LfG2v/ldrPWJaEkghC+76LBTDjgQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=deb1e3b719985466b0cc84825846519acdd0a2e7 commit deb1e3b719985466b0cc84825846519acdd0a2e7 Author: Warner Losh AuthorDate: 2022-10-06 03:55:26 +0000 Commit: Warner Losh CommitDate: 2022-10-25 15:32:49 +0000 physmem: Add physmem_excluded to query if a region is excluded In order to safely reuse excluded memory when it's reserved for special purpose, we need to test whether or not the memory has been reserved early in boot. physmem_excluded will return true when the entire range is excluded, false otherwise. Sponsored by: Netflix --- sys/kern/subr_physmem.c | 14 ++++++++++++++ sys/sys/physmem.h | 1 + 2 files changed, 15 insertions(+) diff --git a/sys/kern/subr_physmem.c b/sys/kern/subr_physmem.c index 5caff7da4f50..498ad2440f40 100644 --- a/sys/kern/subr_physmem.c +++ b/sys/kern/subr_physmem.c @@ -483,6 +483,20 @@ physmem_avail(vm_paddr_t *avail, size_t maxavail) return (regions_to_avail(avail, EXFLAG_NOALLOC, maxavail, 0, NULL, NULL)); } +bool +physmem_excluded(vm_paddr_t pa, vm_size_t sz) +{ + const struct region *exp; + size_t exi; + + for (exi = 0, exp = exregions; exi < excnt; ++exi, ++exp) { + if (pa < exp->addr || pa + sz > exp->addr + exp->size) + continue; + return (true); + } + return (false); +} + #ifdef _KERNEL /* * Process all the regions added earlier into the global avail lists. diff --git a/sys/sys/physmem.h b/sys/sys/physmem.h index f9ba69228c95..dcf12b589d05 100644 --- a/sys/sys/physmem.h +++ b/sys/sys/physmem.h @@ -54,6 +54,7 @@ void physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t flags); size_t physmem_avail(vm_paddr_t *avail, size_t maxavail); void physmem_init_kernel_globals(void); void physmem_print_tables(void); +bool physmem_excluded(vm_paddr_t pa, vm_size_t sz); /* * Convenience routines for FDT.