Subject: Re: Non-bootable CDs (NetBSD 1.6)
To: None <entropy@tappedin.com>
From: Masanori Kanaoka <kanaoka@ann.hi-ho.ne.jp>
List: port-i386
Date: 10/20/2002 02:26:19
Hi,

       From: maximum entropy <entropy@tappedin.com>
    Subject: Re: Non-bootable CDs (NetBSD 1.6)
      Date : Thu, 17 Oct 2002 23:24:21 -0400 (EDT)
 Message-ID: <200210180324.g9I3OL910572@zippy.local>

$ I submitted a PR for this (with a patch that fixes it) well over a
$ year ago.  So far this patch has been ignored, even though three
$ different developers with commit access have said they would take care
$ of it.  I'm starting to think I must have leprosy or something.
$ 
$ It would be really nice if someone with commit privileges could have a
$ look at it, and get this committed.
$ 
$         http://www.NetBSD.org/cgi-bin/query-pr-single.pl?number=13399
$ 
$ The patch was a little bit out of date last time I checked.  If
$ someone is really going to take care of this, let me know and I will
$ generate a new patch if necessary.

It's my fault. I think that your problem is rare.

I generate your patch against machdep.c rev=1.491.
Would you please check it?

If it's correct,I'll commit it and pull-up to netbsd-1-6.
Best Regards!!
---
 Masanori Kanaoka	kanaoka@ann.hi-ho.ne.jp


Index: machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.491
diff -u -r1.491 machdep.c
--- machdep.c	2002/10/18 00:51:22	1.491
+++ machdep.c	2002/10/19 16:57:08
@@ -2728,6 +2728,7 @@
 	u_int32_t type;
 {
 	extern struct extent *iomem_ex;
+	int i;
 
 	if (seg_end > 0x100000000ULL) {
 		printf("WARNING: skipping large "
@@ -2749,6 +2750,17 @@
 	if (seg_end <= seg_start)
 		return;
 
+	for (i = 0; i < mem_cluster_cnt; i++) {
+		if ((mem_clusters[i].start == round_page(seg_start))
+		    && (mem_clusters[i].size
+			    == trunc_page(seg_end) - mem_clusters[i].start)) {
+#ifdef DEBUG_MEMLOAD
+			printf("WARNING: skipping duplicate segment entry\n");
+#endif
+			return;
+		}
+	}
+
 	/*
 	 * Allocate the physical addresses used by RAM
 	 * from the iomem extent map.  This is done before
@@ -2763,6 +2775,7 @@
 		    "(0x%qx/0x%qx/0x%x) FROM "
 		    "IOMEM EXTENT MAP!\n",
 		    seg_start, seg_end - seg_start, type);
+		return;
 	}
 
 	/*
@@ -2918,6 +2931,10 @@
 		avail_start += realmode_reserved_size;
 	}
 
+#ifdef DEBUG_MEMLOAD
+	printf("mem_cluster_count: %d\n", mem_cluster_cnt);
+#endif
+
 	/*
 	 * Call pmap initialization to make new kernel address space.
 	 * We must do this before loading pages into the VM system.
@@ -3106,14 +3123,18 @@
 					tmp = (16 * 1024 * 1024);
 				else
 					tmp = seg_end;
+
+				if (tmp != seg_start) {
 #ifdef DEBUG_MEMLOAD
-				printf("loading 0x%qx-0x%qx (0x%lx-0x%lx)\n",
-				    seg_start, tmp,
-				    atop(seg_start), atop(tmp));
-#endif
-				uvm_page_physload(atop(seg_start),
-				    atop(tmp), atop(seg_start),
-				    atop(tmp), first16q);
+					printf("loading 0x%qx-0x%qx "
+					    "(0x%lx-0x%lx)\n",
+				    	    seg_start, tmp,
+				  	    atop(seg_start), atop(tmp));
+#endif
+					uvm_page_physload(atop(seg_start),
+				    	    atop(tmp), atop(seg_start),
+				    	    atop(tmp), first16q);
+				}
 				seg_start = tmp;
 			}
 
@@ -3139,14 +3160,18 @@
 					tmp = (16 * 1024 * 1024);
 				else
 					tmp = seg_end1;
+
+				if (tmp != seg_start1) {
 #ifdef DEBUG_MEMLOAD
-				printf("loading 0x%qx-0x%qx (0x%lx-0x%lx)\n",
-				    seg_start1, tmp,
-				    atop(seg_start1), atop(tmp));
-#endif
-				uvm_page_physload(atop(seg_start1),
-				    atop(tmp), atop(seg_start1),
-				    atop(tmp), first16q);
+					printf("loading 0x%qx-0x%qx "
+					    "(0x%lx-0x%lx)\n",
+				    	    seg_start1, tmp,
+				    	    atop(seg_start1), atop(tmp));
+#endif
+					uvm_page_physload(atop(seg_start1),
+				    	    atop(tmp), atop(seg_start1),
+				    	    atop(tmp), first16q);
+				}
 				seg_start1 = tmp;
 			}