From nobody Fri Mar 10 05:35:04 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 4PXvrn12Gcz3x6nL; Fri, 10 Mar 2023 05:35: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 4PXvrn0Ty2z4667; Fri, 10 Mar 2023 05:35:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678426505; 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=v8gBE4l0a7uaYuYY6eBcNNUJctML9BGP6Qi1FoGD5i8=; b=GDqo+c8A/gyfBeEgcsJFD7XmdrRYPawjU/rlN9Y5cBZGUTiYsFOukRJw8HMLGPrhQE57L+ 1jJ5GokIkfjnoFl9AxD2Ma1FJIGJInaZ3zmNfN2XjELTmACLpdUKcp78AMIwRfWChx0nw+ BewxSHjCCH905b47kX576KUZiVRTplUH5BKPIDu4L9DL0I7MO7qxWjvOl/1JxCCSnFa81a S86N6WBHQI3H5Qu34HPoWr6TGc5LUUJEhtpZq/slUewpYqHKpXxkyv+WBlSKzJGnI7QcuD IreS1rX6BQNylY4/2aOUbucKvy65l0aeSIJLChHDD08ndntznH35Dnao2jySzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678426505; 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=v8gBE4l0a7uaYuYY6eBcNNUJctML9BGP6Qi1FoGD5i8=; b=aP2LBorfLWbLHX+6OYzVM/XfV/XnetD8gZFGeEZURIFN7Y7j4LaaxfyTb36E0KRbHw+qxX DBbJWlz2RJ2jZZgpgZZ+FD+yEBFImbdvoJc+91/8Eom4L1K0vxMbtj1FZWjUtMBFU8xeIG nkPtWFQjWomDwKhUFwhxhuVnedE9wavIFs2Xmef13WU71CaEZ+wWGay5FebKnjo0UPVE0l Oi66iMkAjFakHhXMtP0Wss22FtLww2T4BZBFf02IEPM6AuYN6z4/2uk0Im3JPZOJMMz8jL L6PhEtMRlDmH0BhjQpkEBx7fSB6QSuKuG+11FzYlZgn9ZgIStq0bs2WJe+utnA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678426505; a=rsa-sha256; cv=none; b=p86kYULXXBAzDbpo4qSBEMoG0zrZucJmVQLjybq4Y0fRrgGt+cpWtCJ+7ZP2W7bDzoimVi 6NrdCbRDo4DcnJnONwAC3Zgcp96C7JBRYK4kD5hL98mBG8fASVnfad914lgDlwhX40r6/W 2CT6J6fMGAscxrBZvyxRMcE3nM04W4X9yJaMNXv93HmabEWYwgIRc+Oa68QhSMXqTi0g4T 4FD8du3MCFNDkGMZ6ZW586JWnc2htRWzBKKAqXUI45LsP1VDFXeUxv2Q4Hemfa2EobV8sV JWc3B3NNZ/GCwP3SjTkkzsbtP8kFo+6qKikIVBPRFfPF0L30dRewjgZ5qyEQ4Q== 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 4PXvrm6fy9zcxv; Fri, 10 Mar 2023 05:35: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 32A5Z41X015316; Fri, 10 Mar 2023 05:35:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32A5Z4xt015315; Fri, 10 Mar 2023 05:35:04 GMT (envelope-from git) Date: Fri, 10 Mar 2023 05:35:04 GMT Message-Id: <202303100535.32A5Z4xt015315@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: cc0fe048ec39 - main - kern: physmem: don't create a new exregion for different flags... 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: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cc0fe048ec39636216ed59fa47eb311b2537cfc5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=cc0fe048ec39636216ed59fa47eb311b2537cfc5 commit cc0fe048ec39636216ed59fa47eb311b2537cfc5 Author: Kyle Evans AuthorDate: 2023-03-10 05:27:39 +0000 Commit: Kyle Evans CommitDate: 2023-03-10 05:27:39 +0000 kern: physmem: don't create a new exregion for different flags... ... if the region we're adding is an exact match to one that we already have. Simply extend the flags of the existing entry as needed so that we don't end up with duplicate regions. It could be that we got the exclusion through two different means, e.g., FDT memreserve and the EFI memory map, and we may derive different characteristics from each. Apply the most restrictive set to the region. Reported by: Mark Millard Reviewed by: mhorne --- sys/kern/subr_physmem.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sys/kern/subr_physmem.c b/sys/kern/subr_physmem.c index 1fb617078625..b76d25ed1ae2 100644 --- a/sys/kern/subr_physmem.c +++ b/sys/kern/subr_physmem.c @@ -376,8 +376,8 @@ insert_region(struct region *regions, size_t rcnt, vm_paddr_t addr, nend = addr + size; ep = regions + rcnt; for (i = 0, rp = regions; i < rcnt; ++i, ++rp) { + rend = rp->addr + rp->size; if (flags == rp->flags) { - rend = rp->addr + rp->size; if (addr <= rp->addr && nend >= rp->addr) { /* * New mapping overlaps at the beginning, shift @@ -404,7 +404,20 @@ insert_region(struct region *regions, size_t rcnt, vm_paddr_t addr, } return (rcnt); } + } else if ((flags != 0) && (rp->flags != 0)) { + /* + * If we're duplicating an entry that already exists + * exactly, just upgrade its flags as needed. We could + * do more if we find that we have differently specified + * flags clipping existing excluding regions, but that's + * probably rare. + */ + if (addr == rp->addr && nend == rend) { + rp->flags |= flags; + return (rcnt); + } } + if (addr < rp->addr) { bcopy(rp, rp + 1, (ep - rp) * sizeof(*rp)); break;