From owner-svn-src-all@freebsd.org Wed May 8 16:15:29 2019 Return-Path: Delivered-To: svn-src-all@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 7FFA2158C2FE; Wed, 8 May 2019 16:15:29 +0000 (UTC) (envelope-from jhibbits@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 274B1836A3; Wed, 8 May 2019 16:15:29 +0000 (UTC) (envelope-from jhibbits@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 F3E98833F; Wed, 8 May 2019 16:15:28 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x48GFSnS031290; Wed, 8 May 2019 16:15:28 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x48GFScU031289; Wed, 8 May 2019 16:15:28 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201905081615.x48GFScU031289@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Wed, 8 May 2019 16:15:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347354 - head/sys/powerpc/booke X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/powerpc/booke X-SVN-Commit-Revision: 347354 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 274B1836A3 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.977,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Wed, 08 May 2019 16:15:29 -0000 Author: jhibbits Date: Wed May 8 16:15:28 2019 New Revision: 347354 URL: https://svnweb.freebsd.org/changeset/base/347354 Log: powerpc/booke: Rewrite pmap_sync_icache() a bit * Make mmu_booke_sync_icache() use the DMAP on 64-bit prcoesses, no need to map the page into the user's address space. This removes the pvh_global_lock from the equation on 64-bit. * Don't map the page with user-readability on 32-bit. I don't know what the chance of a given user process being able to access the NULL page when another process's page is added there, but it doesn't seem like a good idea to map it to NULL with user read permissions. * Only sync as much as we need to. There are only two significant places where pmap_sync_icache is used: proc_rwmem(), and the SIGILL second-chance for powerpc. The SIGILL second chance is likely the most common, and only syncs 4 bytes, so avoid the other 127 loop iterations (4096 / 32 byte cacheline) in __syncicache(). Modified: head/sys/powerpc/booke/pmap.c Modified: head/sys/powerpc/booke/pmap.c ============================================================================== --- head/sys/powerpc/booke/pmap.c Wed May 8 16:07:43 2019 (r347353) +++ head/sys/powerpc/booke/pmap.c Wed May 8 16:15:28 2019 (r347354) @@ -2871,18 +2871,20 @@ static void mmu_booke_sync_icache(mmu_t mmu, pmap_t pm, vm_offset_t va, vm_size_t sz) { pte_t *pte; + vm_paddr_t pa = 0; + int sync_sz, valid; +#ifndef __powerpc64__ pmap_t pmap; vm_page_t m; vm_offset_t addr; - vm_paddr_t pa = 0; - int active, valid; + int active; +#endif - va = trunc_page(va); - sz = round_page(sz); - +#ifndef __powerpc64__ rw_wlock(&pvh_global_lock); pmap = PCPU_GET(curpmap); active = (pm == kernel_pmap || pm == pmap) ? 1 : 0; +#endif while (sz > 0) { PMAP_LOCK(pm); pte = pte_find(mmu, pm, va); @@ -2890,24 +2892,34 @@ mmu_booke_sync_icache(mmu_t mmu, pmap_t pm, vm_offset_ if (valid) pa = PTE_PA(pte); PMAP_UNLOCK(pm); + sync_sz = PAGE_SIZE - (va & PAGE_MASK); + sync_sz = min(sync_sz, sz); if (valid) { +#ifdef __powerpc64__ + pa += (va & PAGE_MASK); + __syncicache((void *)PHYS_TO_DMAP(pa), sync_sz); +#else if (!active) { /* Create a mapping in the active pmap. */ addr = 0; m = PHYS_TO_VM_PAGE(pa); PMAP_LOCK(pmap); pte_enter(mmu, pmap, m, addr, - PTE_SR | PTE_VALID | PTE_UR, FALSE); - __syncicache((void *)addr, PAGE_SIZE); + PTE_SR | PTE_VALID, FALSE); + addr += (va & PAGE_MASK); + __syncicache((void *)addr, sync_sz); pte_remove(mmu, pmap, addr, PTBL_UNHOLD); PMAP_UNLOCK(pmap); } else - __syncicache((void *)va, PAGE_SIZE); + __syncicache((void *)va, sync_sz); +#endif } - va += PAGE_SIZE; - sz -= PAGE_SIZE; + va += sync_sz; + sz -= sync_sz; } +#ifndef __powerpc64__ rw_wunlock(&pvh_global_lock); +#endif } /*