Bug 216606 - kernel crashes early in pmap_map when pxe booted with rootfs in memory
Summary: kernel crashes early in pmap_map when pxe booted with rootfs in memory
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 10.3-STABLE
Hardware: i386 Any
: --- Affects Some People
Assignee: Mark Linimon
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2017-01-30 15:06 UTC by longwitz
Modified: 2017-05-20 21:47 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description longwitz 2017-01-30 15:06:13 UTC
Sometimes I boot one of my servers via pxe and rootfs in memory. This works fine for all FreeBSD 8 Stable servers and all FreeBSD 10.3 Stable amd64 server. But for FreeBSD 10.3 r307955 i386 the kernel crashes early on boot. My loader.conf:

# root partition in memory disk'
mfsroot_load="YES"
mfsroot_type="mfs_root"
mfsroot_name="mfsroot"
exec=".( setting vfs.root.mountfrom: ufs:/dev/md0) cr"
vfs.root.mountfrom="ufs:/dev/md0"

Size of kernel and mfsroot.gz:
-r-xr-xr-x  1 root  wheel  12043460 17 Jan 14:33 kernel
-rw-r--r--  1 root  wheel  15508243 28 Jan 04:15 mfsroot.gz

Some info of the server from a normal boot:
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
CPU: Intel(R) Xeon(TM) CPU 2.80GHz (2791.05-MHz 686-class CPU)
  Origin="GenuineIntel"  Id=0xf29  Family=0xf  Model=0x2  Stepping=9
Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0x4400<CNXT-ID,xTPR>
real memory  = 4294967296 (4096 MB)
avail memory = 3936821248 (3754 MB)

Output on serial console:
DB: no debug ports present
KDB: debugger backends: ddb
KDB: current backend: ddb
MP Configuration Table version 1.4 found at 0xc00f1d40
Table 'FACP' at 0xefff0030
Table 'APIC' at 0xefff00b0
APIC: Found table at 0xefff00b0
APIC: Using the MADT enumerator.
MADT: Found CPU APIC ID 0 ACPI ID 0: enabled
SMP: Added CPU 0 (AP)
MADT: Found CPU APIC ID 6 ACPI ID 1: enabled
SMP: Added CPU 6 (AP)
MADT: Found CPU APIC ID 1 ACPI ID 2: enabled
SMP: Added CPU 1 (AP)
MADT: Found CPU APIC ID 7 ACPI ID 3: enabled
SMP: Added CPU 7 (AP)
Copyright (c) 1992-2016 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 10.3-STABLE #2 r307955: Tue Jan 17 14:33:05 CET 2017
    root@dssresv2.incore:/usr/obj/usr/src/sys/SERVER32 i386
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
kernel trap 12 with interrupts disabled


Fatal trap 12: page fault while in kernel mode
cpuid = 0; apic id = 00
fault virtual address   = 0xbff22000
fault code              = supervisor write, page not present
instruction pointer     = 0x20:0xc0b88660
stack pointer           = 0x28:0xc4422c94
frame pointer           = 0x28:0xc4422cac
code segment            = base rx0, limit 0xfffff, type 0x1b
                        = DPL 0, pres 1, def32 1, gran 1
processor eflags        = resume, IOPL = 0
current process         = 0 ()
[ thread pid 0 tid 0 ]
Stopped at      pmap_map+0xb0:  movl    %ecx,PTmap(,%eax,4)
db> bt
Tracing pid 0 tid 0 td 0xc0e71510
pmap_map(c4422cd8,ebfba000,eff7a000,3,3fbf51c,...) at pmap_map+0xb0/frame 0xc4422cac
vm_page_startup(c4594000,c0890706,c0e0279c,c0c8c4b1,0,...) at vm_page_startup+0x3a5/frame 0xc4422cec
vm_mem_init(0,0,0,0,c0ccf2d8,...) at vm_mem_init+0x18/frame 0xc4422d10
mi_startup() at mi_startup+0xe7/frame 0xc4422d38
begin() at begin+0x22
db> reset

The problem is easy reproducible. If necessary I can give more output
from ddb.
Comment 1 longwitz 2017-02-19 11:08:45 UTC
The problem was caused by the size of my kernel and mfsroot. In my case I need at boot 68 MB of physical memory (17 page table pages). The kernel needs 18 page table pages for the vm_page_array (/sys/i386/include/pmap.h). Therefore the default for NKPT=30 is too low. After raising this to NKPT=36 in the kernel source the crash has gone.

This PR can be closed.
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2017-02-19 16:49:52 UTC
Closed at submitter's request.