From owner-svn-src-all@freebsd.org Sat Aug 19 21:00:04 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B3D9DE435D; Sat, 19 Aug 2017 21:00:04 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EBCAC64718; Sat, 19 Aug 2017 21:00:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7JL033e020424; Sat, 19 Aug 2017 21:00:03 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7JL03tm020423; Sat, 19 Aug 2017 21:00:03 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708192100.v7JL03tm020423@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 19 Aug 2017 21:00:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322706 - head/sys/i386/i386 X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/i386/i386 X-SVN-Commit-Revision: 322706 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Aug 2017 21:00:04 -0000 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