Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Feb 2025 14:14:20 GMT
From:      Olivier Certner <olce@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 125ef4e041fe - main - vm_phys_avail_check(): Check index parity, fix panic messages
Message-ID:  <202502191414.51JEEKYr038057@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by olce:

URL: https://cgit.FreeBSD.org/src/commit/?id=125ef4e041fed40fed2d00b0ddd90fa0eb7b6ac3

commit 125ef4e041fed40fed2d00b0ddd90fa0eb7b6ac3
Author:     Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2024-11-05 08:58:26 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2025-02-19 14:13:21 +0000

    vm_phys_avail_check(): Check index parity, fix panic messages
    
    The passed index must be the start of a chunk in phys_avail[], so must
    be even.  Test for that and print a separate panic message.
    
    While here, fix panic messages: In one, the wrong chunk boundary was
    printed, and in another, the desired but not the actual condition was
    printed, possibly leading to confusion.
    
    Reviewed by:    markj
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D48626
---
 sys/vm/vm_phys.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sys/vm/vm_phys.c b/sys/vm/vm_phys.c
index 0b7de1d34255..01d3d5e22eb0 100644
--- a/sys/vm/vm_phys.c
+++ b/sys/vm/vm_phys.c
@@ -1780,15 +1780,17 @@ vm_phys_avail_count(void)
 static void
 vm_phys_avail_check(int i)
 {
+	if (i % 2 != 0)
+		panic("Chunk start index %d is not even.", i);
 	if (phys_avail[i] & PAGE_MASK)
 		panic("Unaligned phys_avail[%d]: %#jx", i,
 		    (intmax_t)phys_avail[i]);
-	if (phys_avail[i+1] & PAGE_MASK)
+	if (phys_avail[i + 1] & PAGE_MASK)
 		panic("Unaligned phys_avail[%d + 1]: %#jx", i,
-		    (intmax_t)phys_avail[i]);
+		    (intmax_t)phys_avail[i + 1]);
 	if (phys_avail[i + 1] < phys_avail[i])
-		panic("phys_avail[%d] start %#jx < end %#jx", i,
-		    (intmax_t)phys_avail[i], (intmax_t)phys_avail[i+1]);
+		panic("phys_avail[%d]: start %#jx > end %#jx", i,
+		    (intmax_t)phys_avail[i], (intmax_t)phys_avail[i + 1]);
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202502191414.51JEEKYr038057>