changeset 9010:0ef3e6a52225

6787135 Solaris kernel panic: pfn_to_mfn(): illegal PFN 0x8063ef0 6730876 System crashing while running snv_93 on Celestica AMD64 (32bit)
author Stuart Maybee <Stuart.Maybee@Sun.COM>
date Tue, 10 Mar 2009 22:22:00 -0700
parents 77c8b5fd06e7
children cb6d246c25a8
files usr/src/uts/i86pc/vm/vm_machdep.c
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/i86pc/vm/vm_machdep.c	Wed Mar 11 12:47:32 2009 +0800
+++ b/usr/src/uts/i86pc/vm/vm_machdep.c	Tue Mar 10 22:22:00 2009 -0700
@@ -1981,6 +1981,18 @@
 		if (++contig_pfn_cnt == contig_pfn_max)
 			break;
 	}
+	/*
+	 * Sanity check the new list.
+	 */
+	if (contig_pfn_cnt < 2) { /* no contig pfns */
+		contig_pfn_cnt = 0;
+		contig_pfnlist_buildfailed++;
+		kmem_free(contig_pfn_list, contig_pfn_max * sizeof (pfn_t));
+		contig_pfn_list = NULL;
+		contig_pfn_max = 0;
+		ret = 0;
+		goto out;
+	}
 	qsort(contig_pfn_list, contig_pfn_cnt, sizeof (pfn_t), mfn_compare);
 	compact_contig_pfn_list();
 	/*
@@ -2062,8 +2074,13 @@
 			probe_hi = probe_pos;
 		probe_pos = (probe_hi + probe_lo) / 2;
 	}
-	if (probe_pos >= 0)  { /* remove pfn fom list */
-		contig_pfn_cnt--;
+	if (probe_pos >= 0) {
+		/*
+		 * Remove pfn from list and ensure next alloc
+		 * position stays in bounds.
+		 */
+		if (--contig_pfn_cnt <= next_alloc_pfn)
+			next_alloc_pfn = 0;
 		ovbcopy(&contig_pfn_list[probe_pos + 1],
 		    &contig_pfn_list[probe_pos],
 		    (contig_pfn_cnt - probe_pos) * sizeof (pfn_t));