svn commit: r338711 - head/sys/amd64/amd64

Konstantin Belousov kib at FreeBSD.org
Mon Sep 17 14:59:06 UTC 2018


Author: kib
Date: Mon Sep 17 14:59:05 2018
New Revision: 338711
URL: https://svnweb.freebsd.org/changeset/base/338711

Log:
  Make the PTI violation check to follow style of the SMAP check.
  No functional changes.
  
  Reviewed by:	alc, markj
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week
  Approved by:	re (rgrimes)
  Differential revision:	https://reviews.freebsd.org/D17181

Modified:
  head/sys/amd64/amd64/trap.c

Modified: head/sys/amd64/amd64/trap.c
==============================================================================
--- head/sys/amd64/amd64/trap.c	Mon Sep 17 14:53:03 2018	(r338710)
+++ head/sys/amd64/amd64/trap.c	Mon Sep 17 14:59:05 2018	(r338711)
@@ -705,6 +705,17 @@ trap_is_smap(struct trapframe *frame)
 	    PGEX_P && (frame->tf_rflags & PSL_AC) == 0);
 }
 
+static bool
+trap_is_pti(struct trapframe *frame)
+{
+
+	return (PCPU_GET(curpmap)->pm_ucr3 != PMAP_NO_CR3 &&
+	    pg_nx != 0 && (frame->tf_err & (PGEX_P | PGEX_W |
+	    PGEX_U | PGEX_I)) == (PGEX_P | PGEX_U | PGEX_I) &&
+	    (curpcb->pcb_saved_ucr3 & ~CR3_PCID_MASK) ==
+	    (PCPU_GET(curpmap)->pm_cr3 & ~CR3_PCID_MASK));
+}
+
 static int
 trap_pfault(struct trapframe *frame, int usermode)
 {
@@ -806,11 +817,7 @@ trap_pfault(struct trapframe *frame, int usermode)
 	 * If nx protection of the usermode portion of kernel page
 	 * tables caused trap, panic.
 	 */
-	if (usermode && PCPU_GET(curpmap)->pm_ucr3 != PMAP_NO_CR3 &&
-	    pg_nx != 0 && (frame->tf_err & (PGEX_P | PGEX_W |
-	    PGEX_U | PGEX_I)) == (PGEX_P | PGEX_U | PGEX_I) &&
-	    (curpcb->pcb_saved_ucr3 & ~CR3_PCID_MASK)==
-	    (PCPU_GET(curpmap)->pm_cr3 & ~CR3_PCID_MASK))
+	if (usermode && trap_is_pti(frame))
 		panic("PTI: pid %d comm %s tf_err %#lx", p->p_pid,
 		    p->p_comm, frame->tf_err);
 


More information about the svn-src-head mailing list