git: 9dc47f536d3f - stable/14 - vm_phys_avail_check(): Check index parity, fix panic messages
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 08 Apr 2025 13:40:37 UTC
The branch stable/14 has been updated by olce:
URL: https://cgit.FreeBSD.org/src/commit/?id=9dc47f536d3fd43ca4dd6981443753c55acb8f3f
commit 9dc47f536d3fd43ca4dd6981443753c55acb8f3f
Author: Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2024-11-05 08:58:26 +0000
Commit: Olivier Certner <olce@FreeBSD.org>
CommitDate: 2025-04-08 13:38:20 +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
(cherry picked from commit 125ef4e041fed40fed2d00b0ddd90fa0eb7b6ac3)
---
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 cd75ed092691..83038b2af0ea 100644
--- a/sys/vm/vm_phys.c
+++ b/sys/vm/vm_phys.c
@@ -1597,15 +1597,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]);
}
/*