Re: MVME177 panic: pmap_enter_ptpage (PR #45915 on 6.x)

Izumi Tsutsui <[email protected]> Tue, 17 Sep 2013 22:40:41 +0900
Newsgroups gmane.os.netbsd.ports.mvme68k,gmane.os.netbsd.ports.m68k
Message-ID <[email protected]>
Andrew Gillham wrote:

> In trying to boot NetBSD/mvme68k 6.x on an MVME177 (50MHz 68060)
> board,

Wow. I'm really glad that we still have a real mvme68k user!

> I'm running into the panic mentioned in PR45915.  Increasing
> the number of kernel PT pages was the fix for most ports, but there is
> a comment about mvme68k:
> 
> "This panic message is m68k pmap specific and some ports might still have
> the issue. At least mvme68k updates physmem after bootstrap PT page allocation."
> 
> I haven't really looked into this beyond reading the PR.  Does anyone
> know if this is an easy fix?  My MVME177 has 64MB of memory if that
> makes a difference.

nptpage is calculated using physmem in mvme68k/pmap_bootrap.c:
http://nxr.netbsd.org/xref/src/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c?r=1.51#138
but physmem is updated later:
http://nxr.netbsd.org/xref/src/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c?r=1.51#411

With a quick glance, probably we can move physmem (and other)
calculations to the top of the function. (patch attached)

> Meanwhile I've booted 5.2 and it seems to work well.  Also 'netboot'
> from 6.x fails with an illegal instruction message, while the 5.x
> version booted fine.

Probably it's my fault on switching to MI libsa changes after 5.0:
http://mail-index.netbsd.org/source-changes/2011/01/02/msg016539.html

All BUGs binaries are converted to raw binaries by objdump -O binary,
so I guess we explicitly have to link SRT0.o (which has an entry point)
first. (patch attached too)

I've also put compiled binaries:
ftp://ftp.NetBSD.org/pub/NetBSD/misc/tsutsui/mvme68k/netbsd-6_20130917/

Thanks,

---
Index: mvme68k/pmap_bootstrap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c,v
retrieving revision 1.51
diff -u -p -r1.51 pmap_bootstrap.c
--- mvme68k/pmap_bootstrap.c	10 Feb 2012 06:28:39 -0000	1.51
+++ mvme68k/pmap_bootstrap.c	17 Sep 2013 13:07:21 -0000
@@ -100,6 +100,42 @@ pmap_bootstrap(paddr_t nextpa, paddr_t f
 #endif
 
 	/*
+	 * Initialize the mem_clusters[] array for the crash dump
+	 * code.  While we're at it, compute the total amount of
+	 * physical memory in the system.
+	 */
+	for (i = 0; i < VM_PHYSSEG_MAX; i++) {
+		if (RELOC(phys_seg_list[i].ps_start, paddr_t) ==
+		    RELOC(phys_seg_list[i].ps_end, paddr_t)) {
+			/*
+			 * No more memory.
+			 */
+			break;
+		}
+
+		/*
+		 * Make sure these are properly rounded.
+		 */
+		RELOC(phys_seg_list[i].ps_start, paddr_t) =
+		    m68k_round_page(RELOC(phys_seg_list[i].ps_start,
+					  paddr_t));
+		RELOC(phys_seg_list[i].ps_end, paddr_t) =
+		    m68k_trunc_page(RELOC(phys_seg_list[i].ps_end,
+					  paddr_t));
+
+		size = RELOC(phys_seg_list[i].ps_end, paddr_t) -
+		    RELOC(phys_seg_list[i].ps_start, paddr_t);
+
+		RELOC(mem_clusters[i].start, u_quad_t) =
+		    RELOC(phys_seg_list[i].ps_start, paddr_t);
+		RELOC(mem_clusters[i].size, u_quad_t) = size;
+
+		RELOC(physmem, int) += size >> PGSHIFT;
+
+		RELOC(mem_cluster_cnt, int) += 1;
+	}
+
+	/*
 	 * Calculate important physical addresses:
 	 *
 	 *	lwp0upa		lwp0 u-area		UPAGES pages
@@ -409,42 +445,6 @@ pmap_bootstrap(paddr_t nextpa, paddr_t f
 	RELOC(lwp0uarea, vaddr_t) = lwp0upa - firstpa;
 
 	/*
-	 * Initialize the mem_clusters[] array for the crash dump
-	 * code.  While we're at it, compute the total amount of
-	 * physical memory in the system.
-	 */
-	for (i = 0; i < VM_PHYSSEG_MAX; i++) {
-		if (RELOC(phys_seg_list[i].ps_start, paddr_t) ==
-		    RELOC(phys_seg_list[i].ps_end, paddr_t)) {
-			/*
-			 * No more memory.
-			 */
-			break;
-		}
-
-		/*
-		 * Make sure these are properly rounded.
-		 */
-		RELOC(phys_seg_list[i].ps_start, paddr_t) =
-		    m68k_round_page(RELOC(phys_seg_list[i].ps_start,
-					  paddr_t));
-		RELOC(phys_seg_list[i].ps_end, paddr_t) =
-		    m68k_trunc_page(RELOC(phys_seg_list[i].ps_end,
-					  paddr_t));
-
-		size = RELOC(phys_seg_list[i].ps_end, paddr_t) -
-		    RELOC(phys_seg_list[i].ps_start, paddr_t);
-
-		RELOC(mem_clusters[i].start, u_quad_t) =
-		    RELOC(phys_seg_list[i].ps_start, paddr_t);
-		RELOC(mem_clusters[i].size, u_quad_t) = size;
-
-		RELOC(physmem, int) += size >> PGSHIFT;
-
-		RELOC(mem_cluster_cnt, int) += 1;
-	}
-
-	/*
 	 * Scoot the start of available on-board RAM forward to
 	 * account for:
 	 *

---
Index: stand/Makefile.booters
===================================================================
RCS file: /cvsroot/src/sys/arch/mvme68k/stand/Makefile.booters,v
retrieving revision 1.22
diff -u -p -r1.22 Makefile.booters
--- stand/Makefile.booters	22 Jan 2011 19:19:20 -0000	1.22
+++ stand/Makefile.booters	17 Sep 2013 13:07:21 -0000
@@ -59,6 +59,8 @@ LIBSA_DIR!=	cd ${LIB_SA_DIR} && ${PRINTO
 LIBSA=		${LIBSA_DIR}/lib/sa/libsa.a
 LIBKERN=	${LIBSA_DIR}/lib/kern/libkern.a
 
+SRTOBJ?= ${LIBSA_DIR}/SRT0.o
+
 LIB_BUG_DIR=	${.CURDIR}/../libbug
 LIBBUG_DIR!=	cd ${LIB_BUG_DIR} && ${PRINTOBJDIR}
 LIBBUG=${LIBBUG_DIR}/libbug.a
Index: stand/libsa/Makefile
===================================================================
RCS file: /cvsroot/src/sys/arch/mvme68k/stand/libsa/Makefile,v
retrieving revision 1.33
diff -u -p -r1.33 Makefile
--- stand/libsa/Makefile	2 Jan 2011 05:30:12 -0000	1.33
+++ stand/libsa/Makefile	17 Sep 2013 13:07:21 -0000
@@ -31,7 +31,9 @@ LIBKERN= ${KERNLIB}
 
 LIBS= ${LIBSA} ${LIBKERN}
 
-all realall: ${LIBS}
+CLEANFILES+= SRT0.o
+
+all realall: ${LIBS} SRT0.o
 
 cleandir distclean: .WAIT cleanlibdir
 
Index: stand/libsa/Makefile.inc
===================================================================
RCS file: /cvsroot/src/sys/arch/mvme68k/stand/libsa/Makefile.inc,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile.inc
--- stand/libsa/Makefile.inc	2 Jan 2011 05:30:12 -0000	1.5
+++ stand/libsa/Makefile.inc	17 Sep 2013 13:07:21 -0000
@@ -9,8 +9,7 @@ SRC_sa=   dev_net.c
 
 SRC_mvme= exec_mvme.c
 
-SRC_here= SRT0.S \
-	  bugdev.c \
+SRC_here= bugdev.c \
 	  chiptotime.c clock.c \
 	  parse_args.c
 

---
Izumi Tsutsui