svn commit: r322706 - head/sys/i386/i386

Konstantin Belousov kib at FreeBSD.org
Sat Aug 19 21:00:04 UTC 2017


Author: kib
Date: Sat Aug 19 21:00:02 2017
New Revision: 322706
URL: https://svnweb.freebsd.org/changeset/base/322706

Log:
  Use the known valid segment when accessing memory in #UD handler.
  Make sure that %eflags.D flag is cleared for hook.
  Improve comments.
  
  When #UD dtrace code checks for a registered hook before checking that
  the exception was raised from kernel mode, we might run with the user
  %ds, trapping on access.  Exception entry from userspace automatically
  load valid %ss, which we can use there instead.
  
  Noted and reviewed by:	bde
  Sponsored by:	The FreeBSD Foundation
  MFC after:	3 days

Modified:
  head/sys/i386/i386/exception.s

Modified: head/sys/i386/i386/exception.s
==============================================================================
--- head/sys/i386/i386/exception.s	Sat Aug 19 19:33:16 2017	(r322705)
+++ head/sys/i386/i386/exception.s	Sat Aug 19 21:00:02 2017	(r322706)
@@ -183,12 +183,16 @@ calltrap:
 #ifdef KDTRACE_HOOKS
 	SUPERALIGN_TEXT
 IDTVEC(ill)
-	/* Check if there is no DTrace hook registered. */
-	cmpl	$0,dtrace_invop_jump_addr
+	/*
+	 * Check if a DTrace hook is registered.  The default (data) segment
+	 * cannot be used for this since %ds is not known good until we
+	 * verify that the entry was from kernel mode.
+	 */
+	cmpl	$0,%ss:dtrace_invop_jump_addr
 	je	norm_ill
 
 	/*
-	 * Check if this is a user fault. If so, just handle it as a normal
+	 * Check if this is a user fault.  If so, just handle it as a normal
 	 * trap.
 	 */
 	cmpl	$GSEL_KPL, 4(%esp)	/* Check the code segment */
@@ -200,7 +204,8 @@ IDTVEC(ill)
 	 * This is a kernel instruction fault that might have been caused
 	 * by a DTrace provider.
 	 */
-	pushal				/* Push all registers onto the stack. */
+	pushal
+	cld
 
 	/*
 	 * Set our jump address for the jump back in the event that


More information about the svn-src-all mailing list