Module Name: src
Committed By: jym
Date: Wed Jul 28 17:05:51 UTC 2010
Modified Files:
src/sys/arch/i386/i386: mptramp.S
Log Message:
Enable the NX bit feature early in i386 MP trampoline code (do not rely on
cpu_init_msrs() to do it). Having NX bit set on a page will raise a #GP
on fetch if NXE is not enabled, which can happen early when structures
(like idlelwp) are allocated with just rw- rights.
NX is enabled with PAE (if host supports it).
Exact same issue as for amd64, some weeks ago. Same player, shoot again...
To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/i386/i386/mptramp.S
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/i386/i386/mptramp.S
diff -u src/sys/arch/i386/i386/mptramp.S:1.21 src/sys/arch/i386/i386/mptramp.S:1.22
--- src/sys/arch/i386/i386/mptramp.S:1.21 Sat Jul 24 00:45:55 2010
+++ src/sys/arch/i386/i386/mptramp.S Wed Jul 28 17:05:51 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: mptramp.S,v 1.21 2010/07/24 00:45:55 jym Exp $ */
+/* $NetBSD: mptramp.S,v 1.22 2010/07/28 17:05:51 jym Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@
*/
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: mptramp.S,v 1.21 2010/07/24 00:45:55 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mptramp.S,v 1.22 2010/07/28 17:05:51 jym Exp $");
#include "opt_mpbios.h" /* for MPDEBUG */
@@ -158,6 +158,7 @@
movl %cr4,%eax
orl $CR4_PSE,%eax
movl %eax,%cr4
+
1:
#ifdef PAE /* Enable PAE */
@@ -181,6 +182,18 @@
#endif
HALT(0x6)
+ /*
+ * If EFER_NXE is not enabled, fetching a page with a NX bit set
+ * will raise a #GP. Avoid that by setting the NXE feature now.
+ */
+ movl _C_LABEL(cpu_feature)+2*4,%eax /* cpu_feature[2] */
+ andl $CPUID_NOX,%eax
+ jz 1f
+ movl $MSR_EFER,%ecx
+ rdmsr
+ orl $EFER_NXE,%eax /* enable No-Execute feature */
+ wrmsr
+
/*
* ok, we are now running with paging enabled and sharing page tables
* with cpu0. figure out which processor we really are, what stack we