# Fatal trap 12: page fault while in kernel mode



## beaute (Aug 2, 2010)

I have a FreeBSD box with no GUI, I use command-line for everything. I enabled pf by creating pf.conf in /etc and enabling it in rc.conf. I rebooted to see my new pf settings take effect and all with all my previous jail settings but everytime I boot now the system won't start, or it would start and do system checks and halts. I'm not able to read anything because it's fast but I can read the part where it hangs at the end. 


During boot, one of the system checks I was able to catch is

```
Starting file system checks
/dev/ad4s1a
```
then something about it being 4 and it should be 0. I couldn't read the rest because it was so fast. 

Then here is everything I'm able to read before the system freeze:

```
Starting pflog.
pflog0 promiscuous mode enabled
Enabling pf Aug 2 15:16:50 pflogd[683]: [priv]: msg PRIV_OPEN_LOG received
No ALTQ support in kernel
ALTQ related functions disabled

[b]Fatal trap 12: page fault while in kernel mode
cpuid = 1; apic id = 01
fault virtual address = 0x18
fault code = supervisor read, page not present

[snipped]

Cannot dump. Device not defined or unavailable.
Automatic reboot in 15 seconds - press a key on the consol to abort[/b]
```

It doesn't reboot. It just stays there. And this is everytime I start the machine. I cannot access command-line or enter any function or even disable pf if that's what triggered it. What should I do?


----------



## SirDice (Aug 2, 2010)

These are almost always caused by hardware issues. Make sure your memory is still good. Also check your harddrives for any bad blocks.


----------



## beaute (Aug 2, 2010)

I'm not sure how to check if my RAMs/Disks are good, they're supposed to be since they're very recently purchased for this exact project. 

I did some searching and according to this, pf_enable="YES" could be the reason why I'm getting this error. 

So I booted to super user mode, couldn't mount -a directly had to check disks first, then edited /etc/rc.conf to comment out the pf_enable part, everything worked fine after boot. 

So pf_enable="YES" is causing the fault. 

I tried to start pf manually:
`# /etc/rc.d/pf onestart`

and immediately got the No ALTQ suppot in kernel....etc..etc up until the automatic reboot in 15 seconds portion. 


Any help regarding enabling pf in FreeBSD 8 is appreciated.


----------



## SirDice (Aug 2, 2010)

Are you sure your modules and kernel are in sync?


----------



## beaute (Aug 2, 2010)

I'm not sure how to check whether or not they're in sync but I have upgraded my freebsd base system and updated my source tree, i've also done a recent buildworld to build the base system with my new kernel options, i've the installed and updated FreeBSD applications with portsnap, portversion and portupgrade.

After doing all of this I started enabling things one by one. I enabled jail service and started it from rc.conf, then started pf.conf which caused the crash.

enabling pf in rc.conf everytime causes the fault. the only available fix i found online is it use alternative packet filter x(


----------



## SirDice (Aug 2, 2010)

beaute said:
			
		

> I'm not sure how to check whether or not they're in sync but I have upgraded my freebsd base system and updated my source tree, i've also done a recent buildworld to build the base system with my new kernel options,


Ok. Did you also do the *installkernel* bit, besides the *installworld*?

Another question, which might be related. What network card do you have and which driver do you use for it?


----------



## beaute (Aug 3, 2010)

Yes, I have done installkernel after I have recompiled my kernel with added options (IPSec, VIMAGE, pf, pflog)

I have five network cards, four are Intel PRO/1000 network connection. One I'm not sure but dmesg reads Marvell Yukon.
I use msk and em drivers, em for the intel and msk for the other one. 

It appears that everytime I run pf either manually or through rc.conf, it messes up my filesystem and I cannot boot up. I have to log to super use mode, mount -a won't work until after fsck. This is what I get once I try to do mount -a

```
Warning:R/W mount of / denied. Filesystem is not clean - run fsck. 
mount: /dev/ad4s1a: Operation not permitted.
```

But after fsck I can mount -a or just reboot and everything runs fine.


----------



## SirDice (Aug 3, 2010)

beaute said:
			
		

> I have to log to super use mode, mount -a won't work until after fsck. This is what I get once I try to do mount -a
> 
> ```
> Warning:R/W mount of / denied. Filesystem is not clean - run fsck.
> ...



That's normal and supposed to be like that. When you boot to single user mode only the root filesystem is mounted. Read only.


----------



## beaute (Aug 3, 2010)

Um, when I installed base system (after make installkernel.. reboot to choose single user mode) i was able to mount system normally with 
`# mount -a -t ufs`
I did not have to run fsck nor was I getting file system errors. I then just installed the configuration files with mergemaster. 

I'm only asked to run fsck when I start pf.


----------



## SirDice (Aug 3, 2010)

During a normal shutdown the filesystems are marked "clean". When the machine crashes or it's not shutdown properly the filesystems are "dirty". Dirty filesystems must be fsck'ed before you can mount them.


----------



## wblock@ (Aug 3, 2010)

beaute said:
			
		

> Yes, I have done installkernel after I have recompiled my kernel with added options (IPSec, VIMAGE, pf, pflog)
> 
> I have five network cards, four are Intel PRO/1000 network connection. One I'm not sure but dmesg reads Marvell Yukon.
> I use msk and em drivers, em for the intel and msk for the other one.



The em driver should be fine, but msk may not be all that solid; Marvell apparently doesn't release much information.

Just to make sure everything is on the same page, do a fresh csup and buildworld, kernel (use GENERIC), installworld, mergemaster.  It may also be helpful to look for old files with the check-old and check-old-libs targets in /usr/src.

Testing the GENERIC kernel should show whether the problem is with the custom kernel.  See if pf will start without taking down the system without any rules.  Then start adding one thing at a time: the custom kernel, the pf ruleset, the msk driver.


----------

