Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/i386/i386 Enable the NX bit feature early in i386 M...
details: https://anonhg.NetBSD.org/src/rev/10839047a40f
branches: trunk
changeset: 756684:10839047a40f
user: jym <jym%NetBSD.org@localhost>
date: Wed Jul 28 17:05:51 2010 +0000
description:
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...
diffstat:
sys/arch/i386/i386/mptramp.S | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diffs (45 lines):
diff -r 85ad001906bd -r 10839047a40f sys/arch/i386/i386/mptramp.S
--- a/sys/arch/i386/i386/mptramp.S Wed Jul 28 16:29:11 2010 +0000
+++ b/sys/arch/i386/i386/mptramp.S Wed Jul 28 17:05:51 2010 +0000
@@ -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
Home |
Main Index |
Thread Index |
Old Index