From owner-svn-src-head@freebsd.org Wed Jan 2 15:36:36 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AC32C1424F56; Wed, 2 Jan 2019 15:36:36 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5395791A33; Wed, 2 Jan 2019 15:36:36 +0000 (UTC) (envelope-from markj@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 47B55B8F0; Wed, 2 Jan 2019 15:36:36 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x02FaaWL055813; Wed, 2 Jan 2019 15:36:36 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x02FaZtB055811; Wed, 2 Jan 2019 15:36:35 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201901021536.x02FaZtB055811@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 2 Jan 2019 15:36:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r342686 - in head/sys: amd64/amd64 i386/i386 X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in head/sys: amd64/amd64 i386/i386 X-SVN-Commit-Revision: 342686 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5395791A33 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.975,0]; NEURAL_HAM_LONG(-1.00)[-0.998,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jan 2019 15:36:36 -0000 Author: markj Date: Wed Jan 2 15:36:35 2019 New Revision: 342686 URL: https://svnweb.freebsd.org/changeset/base/342686 Log: Avoid setting PG_U unconditionally in pmap_enter_quick_locked(). This KPI may in principle be used to create kernel mappings, in which case we certainly should not be setting PG_U. In any case, PG_U must be set on all layers in the page tables to grant user mode access, and we were only setting it on leaf entries. Thus, this change should have no functional impact. Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Modified: head/sys/amd64/amd64/pmap.c head/sys/i386/i386/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Wed Jan 2 15:13:08 2019 (r342685) +++ head/sys/amd64/amd64/pmap.c Wed Jan 2 15:36:35 2019 (r342686) @@ -5453,8 +5453,7 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, v vm_prot_t prot, vm_page_t mpte, struct rwlock **lockp) { struct spglist free; - pt_entry_t *pte, PG_V; - vm_paddr_t pa; + pt_entry_t newpte, *pte, PG_V; KASSERT(va < kmi.clean_sva || va >= kmi.clean_eva || (m->oflags & VPO_UNMANAGED) != 0, @@ -5544,17 +5543,15 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, v */ pmap_resident_count_inc(pmap, 1); - pa = VM_PAGE_TO_PHYS(m) | pmap_cache_bits(pmap, m->md.pat_mode, 0); + newpte = VM_PAGE_TO_PHYS(m) | PG_V | + pmap_cache_bits(pmap, m->md.pat_mode, 0); + if ((m->oflags & VPO_UNMANAGED) == 0) + newpte |= PG_MANAGED; if ((prot & VM_PROT_EXECUTE) == 0) - pa |= pg_nx; - - /* - * Now validate mapping with RO protection - */ - if ((m->oflags & VPO_UNMANAGED) != 0) - pte_store(pte, pa | PG_V | PG_U); - else - pte_store(pte, pa | PG_V | PG_U | PG_MANAGED); + newpte |= pg_nx; + if (va < VM_MAXUSER_ADDRESS) + newpte |= PG_U; + pte_store(pte, newpte); return (mpte); } Modified: head/sys/i386/i386/pmap.c ============================================================================== --- head/sys/i386/i386/pmap.c Wed Jan 2 15:13:08 2019 (r342685) +++ head/sys/i386/i386/pmap.c Wed Jan 2 15:36:35 2019 (r342686) @@ -4095,8 +4095,7 @@ static vm_page_t pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot, vm_page_t mpte) { - pt_entry_t *pte; - vm_paddr_t pa; + pt_entry_t newpte, *pte; struct spglist free; KASSERT(pmap != kernel_pmap || va < kmi.clean_sva || @@ -4179,19 +4178,17 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, v */ pmap->pm_stats.resident_count++; - pa = VM_PAGE_TO_PHYS(m) | pmap_cache_bits(pmap, m->md.pat_mode, 0); + newpte = VM_PAGE_TO_PHYS(m) | PG_V | + pmap_cache_bits(pmap, m->md.pat_mode, 0); + if ((m->oflags & VPO_UNMANAGED) == 0) + newpte |= PG_MANAGED; #if defined(PAE) || defined(PAE_TABLES) if ((prot & VM_PROT_EXECUTE) == 0) - pa |= pg_nx; + newpte |= pg_nx; #endif - - /* - * Now validate mapping with RO protection - */ - if ((m->oflags & VPO_UNMANAGED) != 0) - pte_store(pte, pa | PG_V | PG_U); - else - pte_store(pte, pa | PG_V | PG_U | PG_MANAGED); + if (pmap != kernel_pmap) + newpte |= PG_U; + pte_store(pte, newpte); sched_unpin(); return (mpte); }