Module Name: src Committed By: maxv Date: Wed Dec 16 18:54:03 UTC 2015
Modified Files: src/sys/arch/i386/i386: trap.c src/sys/arch/x86/x86: cpu.c Log Message: Extend SMEP support to i386 (does not require PAE). To generate a diff of this commit: cvs rdiff -u -r1.275 -r1.276 src/sys/arch/i386/i386/trap.c cvs rdiff -u -r1.118 -r1.119 src/sys/arch/x86/x86/cpu.c 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/trap.c diff -u src/sys/arch/i386/i386/trap.c:1.275 src/sys/arch/i386/i386/trap.c:1.276 --- src/sys/arch/i386/i386/trap.c:1.275 Fri Feb 27 17:45:52 2015 +++ src/sys/arch/i386/i386/trap.c Wed Dec 16 18:54:03 2015 @@ -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 @@ kernelfault: } 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 */ Index: src/sys/arch/x86/x86/cpu.c diff -u src/sys/arch/x86/x86/cpu.c:1.118 src/sys/arch/x86/x86/cpu.c:1.119 --- src/sys/arch/x86/x86/cpu.c:1.118 Sun Dec 13 15:53:06 2015 +++ src/sys/arch/x86/x86/cpu.c Wed Dec 16 18:54:03 2015 @@ -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 @@ cpu_init(struct cpu_info *ci) 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();