Subject: A fix for the panic on reboot problem in NetBSD 3.1 (tested in SE/30)
To: None <port-mac68k@netbsd.org>
From: Sungwon Chung <lucky.cimon@gmail.com>
List: port-mac68k
Date: 01/02/2007 04:22:39
Hi,

Here is my personal fix for the 'panic at reboot problem' especially on
030 machines with NetBSD 3.1 (PR 31080). I think an off-by-one error
was introduced in the kernel pmap initialization code after NetBSD 2.1.

When initializing a kernel page table during bootstrapping,
the page table entries corresponding to a region for ROM usage
is set for 'read/write' access right. The other page table
entries for kernel text is set for 'read-only'. It seems to
me that the region for ROM is slightly miscalculated.
I think it makes sense for the reason of the panic on reboot
because there was a source code change in this pmap
initialization code between NetBSD 2.1 and NetBSD 3.0.
Up to NetBSD 2.1, the whole page table entries for kernel text
is set for 'read/write' although it does not seems to be much safe.
Of course, the panic on reboot problem could be solved by
setting the page table entries to read/write.

The fix finally made is simply to change the line 362 of the
'usr/src/sys/arch/mac68k/mac68k/pmap_bootstrap.c'
by adding '+ 1'.


     diff pmap_bootstrap.c.orig pmap_bootstrap.c
     362c362
     <    epte = &pte[m68k_btop(m68k_round_page(start))];
     ---
     >    epte = &pte[m68k_btop(m68k_round_page(start)) + 1];


I tested this fix for 3.1 GENERIC kernel with SE/30.
The fixed kernel was cross-compiled on i386 platform and uploaded at

     http://home.pusan.ac.kr/~swchung/netbsd/netbsd-GENERIC.gz

I wonder whether it can work for other macs such as IIci.

Best,
Sungwon