Mirror what is done for amd64 boot and ACPI wakeup code by setting

CR0_WP (write protection bit) early on boot. Although it is set later via
cpu_init(), this can help tracking down invalid writes to pages mapped
as read only from ring 0.

No regression observed when booting under anita (QEMU) or a P4 host.

Depending on your hardware or setup, you may trigger code paths I have
overlooked. So if your machine does not start properly, or you get
page faults early during boot, please report them to me.
This commit is contained in:
jym 2012-04-19 18:07:05 +00:00
parent b053fe262f
commit 9d5d9db055

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.S,v 1.98 2012/04/19 18:00:35 jym Exp $ */
/* $NetBSD: locore.S,v 1.99 2012/04/19 18:07:05 jym Exp $ */
/*
* Copyright-o-rama!
@ -129,7 +129,7 @@
*/
#include <machine/asm.h>
__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.98 2012/04/19 18:00:35 jym Exp $");
__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.99 2012/04/19 18:07:05 jym Exp $");
#include "opt_compat_oldboot.h"
#include "opt_ddb.h"
@ -682,7 +682,7 @@ try586: /* Use the `cpuid' instruction. */
*/
movl %cr0,%eax # get control word
# enable paging & NPX emulation
orl $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_AM),%eax
orl $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_WP|CR0_AM),%eax
movl %eax,%cr0 # and page NOW!
pushl $begin # jump to high mem