From nobody Tue Apr 08 13:40:42 2025 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 4ZX6fM0BcXz5sQDd; Tue, 08 Apr 2025 13:40:43 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZX6fL2pTFz3Ccj; Tue, 08 Apr 2025 13:40:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744119642; 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=/pYOmCbvPflS8eQx70NzPrqbilTnspOGMb6kRqBTuHU=; b=Bm8VxqndfmgtEP5GRH3Ald6iEG04d2r5qC2S3M+BNdbaBMSEUkSmSpkLrhY2I5lTQEW1Oy ZZaQybWjHUyHGm/yRjtdQHalRWYhUW2GmWlnNs9Gn7CYYVQxlXMdKLsBAKpZbyrjFiFM2O 5roZcGrqnIghR/ciNn2G/5sMBuWeskZKGTnRu7jI+8DHSSF4LFYb4AbVMtc8Ugi1g5Zfcj xsRl8FaAcMKAJ33sBArLC0eIBQKy2SUymy7uktV4YxNa6/mvJQbQ+j2JZ00kpbsAZVvfuL re0u9OBRIwjluUW5kDb7SF/4VxkZfVa6JuFlH02AmRpxqkgnYNcWIw5mY3LGOg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1744119642; a=rsa-sha256; cv=none; b=qPnfhFKKZEyGT/k/jXCh1vYh+vq468Wa7OEFhxJMCdCFuQ+angfXo+0+uck7msXNpI+bZQ V4LaPZILuoBK3nJ0SRBVwKhbYIajUfRWk1qjvUAF/HokRDZXR83c/sHWP1YKS2wKl84G9N WEKu7optwLo9pu2gylntpEtXzYNidB8zDw0FfYGq+8z/SdN07lJxu4QiNpyy0xdAPBERcZ GYiig8vpFoXnxmBIL3Q0EDAw3AhoB4ahj9wCU+WBJn9vENk0TVPqqHQC1EqKw5K40Zzevf 1Z8Ww+uKVD1AfQSeHz13p7Lwlri9n2jXf5TsqsiBqF4g5EYCdtSEZnDq6Tz5MQ== 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=1744119642; 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=/pYOmCbvPflS8eQx70NzPrqbilTnspOGMb6kRqBTuHU=; b=IBP4PU3yLVfD7mop8HU2znfnDcr53NaVLBcnV20sSzleDynUHynr7uSku6PFomsFTfobxN 416VsVQyxK7bVO2fFjltQ1PYrbwlrct3KzugHVpvnX3XF9vHNTbK5Jsska1kS91CyQOToV QVRY+uqskYjAHEPoiB6nXU0w00j8qkd0auZedOyxI53RsRrfth8RuUvkZkdSvoNBbTQ1E+ +WkLEwh7HHYeRKCDYT/9mLCbTqglzBVPAx5jklJx0B6srw7iwQmDX3x9KzFE9MttiM+ZTS pHyJhjBMTFjpJMlOym/egZfGonQrzM0lZn3Td4g5bNqSrb6hZV+QS1HlaTHllg== 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 4ZX6fL1Pk2zZrS; Tue, 08 Apr 2025 13:40:42 +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 538DegFq030722; Tue, 8 Apr 2025 13:40:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 538Degc1030719; Tue, 8 Apr 2025 13:40:42 GMT (envelope-from git) Date: Tue, 8 Apr 2025 13:40:42 GMT Message-Id: <202504081340.538Degc1030719@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: 25e25d6f1b55 - stable/14 - vm_phys_avail_split(): Tolerate split requests at boundaries 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: olce X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 25e25d6f1b55d9b48c1800dc1b5bd5e3d102a049 Auto-Submitted: auto-generated The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=25e25d6f1b55d9b48c1800dc1b5bd5e3d102a049 commit 25e25d6f1b55d9b48c1800dc1b5bd5e3d102a049 Author: Olivier Certner AuthorDate: 2024-11-04 17:05:19 +0000 Commit: Olivier Certner CommitDate: 2025-04-08 13:38:21 +0000 vm_phys_avail_split(): Tolerate split requests at boundaries Previously, such requests would lead to a panic. The only caller so far (vm_phys_early_startup()) actually faces the case where some address can be one of the chunk's boundaries and has to test it by hand. Moreover, a later commit will introduce vm_phys_early_alloc_ex(), which will also have to deal with such boundary cases. Consequently, make this function handle boundaries by not splitting the chunk and returning EJUSTRETURN instead of 0 to distinguish this case from the "was split" result. While here, expand the panic message when the address to split is not in the passed chunk with available details. Reviewed by: markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48630 (cherry picked from commit e1499bfff8b8c128d7b3d330f95e0c67d7c1fa77) --- sys/vm/vm_phys.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/sys/vm/vm_phys.c b/sys/vm/vm_phys.c index 34a003fe0ab0..10ce7e15f12a 100644 --- a/sys/vm/vm_phys.c +++ b/sys/vm/vm_phys.c @@ -1671,7 +1671,13 @@ vm_phys_avail_size(int i) } /* - * Split an entry at the address 'pa'. Return zero on success or errno. + * Split a chunk in phys_avail[] at the address 'pa'. + * + * 'pa' must be within a chunk (slots i and i + 1) or one of its boundaries. + * Returns zero on actual split, in which case the two new chunks occupy slots + * i to i + 3, else EJUSTRETURN if 'pa' was one of the boundaries (and no split + * actually occurred) else ENOSPC if there are not enough slots in phys_avail[] + * to represent the additional chunk caused by the split. */ static int vm_phys_avail_split(vm_paddr_t pa, int i) @@ -1679,8 +1685,12 @@ vm_phys_avail_split(vm_paddr_t pa, int i) int cnt; vm_phys_avail_check(i); - if (pa <= phys_avail[i] || pa >= phys_avail[i + 1]) - panic("vm_phys_avail_split: invalid address"); + if (pa < phys_avail[i] || pa > phys_avail[i + 1]) + panic("%s: Address %#jx not in range at slot %d [%#jx;%#jx].", + __func__, (uintmax_t)pa, i, + (uintmax_t)phys_avail[i], (uintmax_t)phys_avail[i + 1]); + if (pa == phys_avail[i] || pa == phys_avail[i + 1]) + return (EJUSTRETURN); cnt = vm_phys_avail_count(); if (cnt >= PHYS_AVAIL_ENTRIES) return (ENOSPC); @@ -1842,12 +1852,10 @@ vm_phys_early_startup(void) for (i = 0; mem_affinity[i].end != 0; i++) { idx = vm_phys_avail_find(mem_affinity[i].start); - if (idx != -1 && - phys_avail[idx] != mem_affinity[i].start) + if (idx != -1) vm_phys_avail_split(mem_affinity[i].start, idx); idx = vm_phys_avail_find(mem_affinity[i].end); - if (idx != -1 && - phys_avail[idx] != mem_affinity[i].end) + if (idx != -1) vm_phys_avail_split(mem_affinity[i].end, idx); } }