From owner-svn-src-all@freebsd.org Fri May 27 18:45:12 2016 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 88D5EB4C74B; Fri, 27 May 2016 18:45:12 +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 5A21416BC; Fri, 27 May 2016 18:45:12 +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 u4RIjBIk001764; Fri, 27 May 2016 18:45:11 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4RIjB8a001762; Fri, 27 May 2016 18:45:11 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201605271845.u4RIjB8a001762@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 27 May 2016 18:45:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300863 - head/sys/amd64/amd64 X-SVN-Group: head 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.22 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: Fri, 27 May 2016 18:45:12 -0000 Author: kib Date: Fri May 27 18:45:11 2016 New Revision: 300863 URL: https://svnweb.freebsd.org/changeset/base/300863 Log: In pmap_advise(), avoid leaking DI start for EPT pmaps which needs A/D emulation. Assert that syscalls do not leak DI. Reported by: gjb Sponsored by: The FreeBSD Foundation Modified: head/sys/amd64/amd64/pmap.c head/sys/amd64/amd64/trap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Fri May 27 18:40:38 2016 (r300862) +++ head/sys/amd64/amd64/pmap.c Fri May 27 18:45:11 2016 (r300863) @@ -6060,7 +6060,6 @@ pmap_advise(pmap_t pmap, vm_offset_t sva if (advice != MADV_DONTNEED && advice != MADV_FREE) return; - pmap_delayed_invl_started(); /* * A/D bit emulation requires an alternate code path when clearing @@ -6077,6 +6076,7 @@ pmap_advise(pmap_t pmap, vm_offset_t sva PG_V = pmap_valid_bit(pmap); PG_RW = pmap_rw_bit(pmap); anychanged = FALSE; + pmap_delayed_invl_started(); PMAP_LOCK(pmap); for (; sva < eva; sva = va_next) { pml4e = pmap_pml4e(pmap, sva); Modified: head/sys/amd64/amd64/trap.c ============================================================================== --- head/sys/amd64/amd64/trap.c Fri May 27 18:40:38 2016 (r300862) +++ head/sys/amd64/amd64/trap.c Fri May 27 18:45:11 2016 (r300863) @@ -959,6 +959,10 @@ amd64_syscall(struct thread *td, int tra KASSERT(td->td_pcb->pcb_save == get_pcb_user_save_td(td), ("System call %s returning with mangled pcb_save", syscallname(td->td_proc, sa.code))); + KASSERT(td->td_md.md_invl_gen.gen == 0, + ("System call %s returning with leaked invl_gen %lu", + syscallname(td->td_proc, sa.code), td->td_md.md_invl_gen.gen)); + syscallret(td, error, &sa);