From nobody Wed Feb 19 14:14:24 2025 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 4YydgP3jCgz5pQdV; Wed, 19 Feb 2025 14:14:25 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YydgP0P5dz3nBm; Wed, 19 Feb 2025 14:14:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1739974465; 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=9+uSu3vPIB5siU1aWNSYDD3L9F7ja6O+m9lNNSvypt8=; b=go/iWzYBD3s7HOlXadurwzUttekqnpRP/qdpdk3RfJC9uH29iDjzCjmRMjyrAjZVbILxz8 yEw1ehgK8KwjQ3Ug3SSmXXRq9VjD/p3JjZ7RzWHNMAc+ybXkhT0CxsoUoLSnO/Kc+/haoI 9OuYXJro4YCwx4k3a+l0Kh0eYtizdTI7OFdyGUeegiOkNdmxo+FTEt+LdOC9sHWJl4MrP5 Mkl1zofCZvenR6eh/wo3Tdd7/nBwxJd/elJT6qF0mpqMBYRu6lORQoP0rFqD6WgwTC0gWn U09uwlT6JTCfLDHYf3iP2vciJli0HLXrDt4kqwwrMw77olOAh+rP9ehmV4T5VA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1739974465; a=rsa-sha256; cv=none; b=iZ9m7FBrnofML3arvmJs8JyiE0o1KKp3PbeDKHmFYibRsUcXIk6HkegERbPk6ExqORukKk XEns/i7AXaGgyqwmYbF5zAJ/CPP7sHVxD+cowWmqTN/XtvP9hiwYG7WTFGP7KWAkekXC22 ZBcqqNPIyTXllO01R3FlTjdqta/jjaiGzwRX+t3XEg1IWtSQLv6n2gmRUJMktixncb0A5U ehZvMcXuj5ybsP27zJUvh34EQb8QssZIpTjFkW2tFEdY8Qf0SCCCB+Fulllo2UofkP4MrR +K1tAcitnyQ3/O8Bj3/HyS6tCkoW8x1lT2bNX3Qsf3VzzBM3A9pa/4lJ0+LiLw== 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=1739974465; 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=9+uSu3vPIB5siU1aWNSYDD3L9F7ja6O+m9lNNSvypt8=; b=aP8eAH6xwJ7HeS9x1WboGVawZ2jmuc3/lht6D3a40rAz2bQlYQHV6XUN4WtxiIbIPsEFPD xK2hm83NyoVfHsjBGv3exEFkmOQG6LKpXMJ9MXHaFME0hyErq//tiCJ15IPBWGUBBzuWsm U8pMzwVpqmAnOMYErud2uCEHtMMVVBfKZYIoodPbP3De9vRkRnH21wFFFBqzDFGUIKKBrq ab6PwuP6cwrDhN9GMlSSGL4h0j8niKERCf9fO+kGM2EMvhMs+B5b9QWABhP3sLCyT1pnK/ RjSQQTZ+0qe1ab8VWQcAoMsLWPktY2hlKTAvromuWPzCz9YbvWpQ5PdO8dEjGA== 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 4YydgN5sWXz181r; Wed, 19 Feb 2025 14:14:24 +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 51JEEOoh038198; Wed, 19 Feb 2025 14:14:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 51JEEOHQ038195; Wed, 19 Feb 2025 14:14:24 GMT (envelope-from git) Date: Wed, 19 Feb 2025 14:14:24 GMT Message-Id: <202502191414.51JEEOHQ038195@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: e1499bfff8b8 - main - vm_phys_avail_split(): Tolerate split requests at boundaries 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: e1499bfff8b8c128d7b3d330f95e0c67d7c1fa77 Auto-Submitted: auto-generated The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=e1499bfff8b8c128d7b3d330f95e0c67d7c1fa77 commit e1499bfff8b8c128d7b3d330f95e0c67d7c1fa77 Author: Olivier Certner AuthorDate: 2024-11-04 17:05:19 +0000 Commit: Olivier Certner CommitDate: 2025-02-19 14:13:27 +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 --- 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 e2b5a6e21365..82272be1a6c9 100644 --- a/sys/vm/vm_phys.c +++ b/sys/vm/vm_phys.c @@ -1854,7 +1854,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) @@ -1862,8 +1868,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); @@ -2025,12 +2035,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); } }