Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Extend SMEP support to i386 (does not require PAE).



details:   https://anonhg.NetBSD.org/src/rev/d0f6a907cafb
branches:  trunk
changeset: 812466:d0f6a907cafb
user:      maxv <maxv%NetBSD.org@localhost>
date:      Wed Dec 16 18:54:03 2015 +0000

description:
Extend SMEP support to i386 (does not require PAE).

diffstat:

 sys/arch/i386/i386/trap.c |  12 ++++++++++--
 sys/arch/x86/x86/cpu.c    |   6 ++----
 2 files changed, 12 insertions(+), 6 deletions(-)

diffs (63 lines):

diff -r 6c6aa95d8903 -r d0f6a907cafb sys/arch/i386/i386/trap.c
--- a/sys/arch/i386/i386/trap.c Wed Dec 16 13:23:38 2015 +0000
+++ b/sys/arch/i386/i386/trap.c Wed Dec 16 18:54:03 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.275 2015/02/27 17:45:52 christos Exp $      */
+/*     $NetBSD: trap.c,v 1.276 2015/12/16 18:54:03 maxv Exp $  */
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.275 2015/02/27 17:45:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.276 2015/12/16 18:54:03 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -553,6 +553,14 @@
                }
 
                cr2 = rcr2();
+
+               if (frame->tf_err & PGEX_X) {
+                       /* SMEP might have brought us here */
+                       if (cr2 > VM_MIN_ADDRESS && cr2 <= VM_MAXUSER_ADDRESS)
+                               panic("prevented execution of %p (SMEP)",
+                                   (void *)cr2);
+               }
+
                goto faultcommon;
 
        case T_PAGEFLT|T_USER: {        /* page fault */
diff -r 6c6aa95d8903 -r d0f6a907cafb sys/arch/x86/x86/cpu.c
--- a/sys/arch/x86/x86/cpu.c    Wed Dec 16 13:23:38 2015 +0000
+++ b/sys/arch/x86/x86/cpu.c    Wed Dec 16 18:54:03 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.118 2015/12/13 15:53:06 maxv Exp $   */
+/*     $NetBSD: cpu.c,v 1.119 2015/12/16 18:54:03 maxv Exp $   */
 
 /*-
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.118 2015/12/13 15:53:06 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.119 2015/12/16 18:54:03 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"                /* for MPDEBUG */
@@ -581,11 +581,9 @@
        if (cpu_feature[1] & CPUID2_XSAVE)
                cr4 |= CR4_OSXSAVE;
 
-#ifdef __x86_64__
        /* If SMEP is supported, enable it */
        if (cpu_feature[5] & CPUID_SEF_SMEP)
                cr4 |= CR4_SMEP;
-#endif
 
        if (cr4) {
                cr4 |= rcr4();



Home | Main Index | Thread Index | Old Index