From owner-svn-src-stable@freebsd.org Fri Nov 11 20:31:24 2016 Return-Path: Delivered-To: svn-src-stable@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 ACD7DC3CF60; Fri, 11 Nov 2016 20:31:24 +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 6130D103B; Fri, 11 Nov 2016 20:31:24 +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 uABKVNdN026999; Fri, 11 Nov 2016 20:31:23 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uABKVNpg026998; Fri, 11 Nov 2016 20:31:23 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201611112031.uABKVNpg026998@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 11 Nov 2016 20:31:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r308557 - stable/11/sys/i386/i386 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2016 20:31:24 -0000 Author: kib Date: Fri Nov 11 20:31:23 2016 New Revision: 308557 URL: https://svnweb.freebsd.org/changeset/base/308557 Log: MFC r308029: Handle pmap_enter() over an existing 4/2M page in KVA on i386. Modified: stable/11/sys/i386/i386/pmap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/i386/i386/pmap.c ============================================================================== --- stable/11/sys/i386/i386/pmap.c Fri Nov 11 20:27:00 2016 (r308556) +++ stable/11/sys/i386/i386/pmap.c Fri Nov 11 20:31:23 2016 (r308557) @@ -3466,11 +3466,14 @@ pmap_enter(pmap_t pmap, vm_offset_t va, PMAP_LOCK(pmap); sched_pin(); - /* - * In the case that a page table page is not - * resident, we are creating it here. - */ + pde = pmap_pde(pmap, va); if (va < VM_MAXUSER_ADDRESS) { + /* + * va is for UVA. + * In the case that a page table page is not resident, + * we are creating it here. pmap_allocpte() handles + * demotion. + */ mpte = pmap_allocpte(pmap, va, flags); if (mpte == NULL) { KASSERT((flags & PMAP_ENTER_NOSLEEP) != 0, @@ -3480,19 +3483,28 @@ pmap_enter(pmap_t pmap, vm_offset_t va, PMAP_UNLOCK(pmap); return (KERN_RESOURCE_SHORTAGE); } + } else { + /* + * va is for KVA, so pmap_demote_pde() will never fail + * to install a page table page. PG_V is also + * asserted by pmap_demote_pde(). + */ + KASSERT(pde != NULL && (*pde & PG_V) != 0, + ("KVA %#x invalid pde pdir %#jx", va, + (uintmax_t)pmap->pm_pdir[PTDPTDI])); + if ((*pde & PG_PS) != 0) + pmap_demote_pde(pmap, pde, va); } - - pde = pmap_pde(pmap, va); - if ((*pde & PG_PS) != 0) - panic("pmap_enter: attempted pmap_enter on 4MB page"); pte = pmap_pte_quick(pmap, va); /* - * Page Directory table entry not valid, we need a new PT page + * Page Directory table entry is not valid, which should not + * happen. We should have either allocated the page table + * page or demoted the existing mapping above. */ if (pte == NULL) { panic("pmap_enter: invalid page directory pdir=%#jx, va=%#x", - (uintmax_t)pmap->pm_pdir[PTDPTDI], va); + (uintmax_t)pmap->pm_pdir[PTDPTDI], va); } pa = VM_PAGE_TO_PHYS(m);