Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Dec 2016 19:28:15 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r310485 - in stable: 10/sys/amd64/amd64 10/sys/i386/i386 11/sys/amd64/amd64 11/sys/i386/i386
Message-ID:  <201612231928.uBNJSFGT095997@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Fri Dec 23 19:28:15 2016
New Revision: 310485
URL: https://svnweb.freebsd.org/changeset/base/310485

Log:
  MFC 308820,308821: Fixes for fatal page faults on x86.
  
  308820:
  Report page faults due to reserved bits in PTEs as a separate fault type.
  
  Rather than reporting a page fault due to a bad PTE as a protection
  violation with the "rsv" flag, treat these faults as a separate type of
  fault altogether.
  
  308821:
  MFamd64: Various fatal page fault fixes.
  
  - If a page fault is triggered due to reserved bits in a PTE, treat it
    as a fatal fault and panic.
  - If PG_NX is in use, report whether a fatal page fault is due to an
    instruction fetch or a data access.
  - If a fatal page fault is due to reserved bits in a PTE, report that as
    the page fault type rather than a protection violation.

Modified:
  stable/11/sys/amd64/amd64/trap.c
  stable/11/sys/i386/i386/trap.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/sys/amd64/amd64/trap.c
  stable/10/sys/i386/i386/trap.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/11/sys/amd64/amd64/trap.c
==============================================================================
--- stable/11/sys/amd64/amd64/trap.c	Fri Dec 23 18:29:10 2016	(r310484)
+++ stable/11/sys/amd64/amd64/trap.c	Fri Dec 23 19:28:15 2016	(r310485)
@@ -761,11 +761,11 @@ trap_fatal(frame, eva)
 #endif
 	if (type == T_PAGEFLT) {
 		printf("fault virtual address	= 0x%lx\n", eva);
-		printf("fault code		= %s %s %s%s, %s\n",
+		printf("fault code		= %s %s %s, %s\n",
 			code & PGEX_U ? "user" : "supervisor",
 			code & PGEX_W ? "write" : "read",
 			code & PGEX_I ? "instruction" : "data",
-			code & PGEX_RSV ? " rsv" : "",
+			code & PGEX_RSV ? "reserved bits in PTE" :
 			code & PGEX_P ? "protection violation" : "page not present");
 	}
 	printf("instruction pointer	= 0x%lx:0x%lx\n",

Modified: stable/11/sys/i386/i386/trap.c
==============================================================================
--- stable/11/sys/i386/i386/trap.c	Fri Dec 23 18:29:10 2016	(r310484)
+++ stable/11/sys/i386/i386/trap.c	Fri Dec 23 19:28:15 2016	(r310485)
@@ -857,6 +857,14 @@ trap_pfault(frame, usermode, eva)
 	}
 
 	/*
+	 * If the trap was caused by errant bits in the PTE then panic.
+	 */
+	if (frame->tf_err & PGEX_RSV) {
+		trap_fatal(frame, eva);
+		return (-1);
+	}
+
+	/*
 	 * PGEX_I is defined only if the execute disable bit capability is
 	 * supported and enabled.
 	 */
@@ -926,9 +934,15 @@ trap_fatal(frame, eva)
 #endif
 	if (type == T_PAGEFLT) {
 		printf("fault virtual address	= 0x%x\n", eva);
-		printf("fault code		= %s %s, %s\n",
+		printf("fault code		= %s %s%s, %s\n",
 			code & PGEX_U ? "user" : "supervisor",
 			code & PGEX_W ? "write" : "read",
+#if defined(PAE) || defined(PAE_TABLES)
+			pg_nx != 0 ?
+			(code & PGEX_I ? " instruction" : " data") :
+#endif
+			"",
+			code & PGEX_RSV ? "reserved bits in PTE" :
 			code & PGEX_P ? "protection violation" : "page not present");
 	}
 	printf("instruction pointer	= 0x%x:0x%x\n",



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201612231928.uBNJSFGT095997>