From owner-svn-src-stable-12@freebsd.org Tue Jun 4 15:11:15 2019 Return-Path: Delivered-To: svn-src-stable-12@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 9CDD015B386B; Tue, 4 Jun 2019 15:11:15 +0000 (UTC) (envelope-from br@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 41BAE6CF8D; Tue, 4 Jun 2019 15:11:15 +0000 (UTC) (envelope-from br@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 1DA731F2AE; Tue, 4 Jun 2019 15:11:15 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54FBEoS024907; Tue, 4 Jun 2019 15:11:15 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54FBExp024906; Tue, 4 Jun 2019 15:11:14 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041511.x54FBExp024906@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 15:11:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348613 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348613 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 41BAE6CF8D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.938,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-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 15:11:16 -0000 Author: br Date: Tue Jun 4 15:11:14 2019 New Revision: 348613 URL: https://svnweb.freebsd.org/changeset/base/348613 Log: MFC 339774: o Add pmap lock around pmap_fault_fixup() to ensure other thread will not modify l3 pte after we loaded old value and before we stored new value. o Preset A(accessed), D(dirty) bits for kernel mappings. Sponsored by: DARPA, AFRL Modified: stable/12/sys/riscv/riscv/pmap.c Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 13:45:30 2019 (r348612) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 15:11:14 2019 (r348613) @@ -1923,16 +1923,21 @@ pmap_fault_fixup(pmap_t pmap, vm_offset_t va, vm_prot_ pt_entry_t orig_l3; pt_entry_t new_l3; pt_entry_t *l3; + int rv; + rv = 0; + + PMAP_LOCK(pmap); + l3 = pmap_l3(pmap, va); if (l3 == NULL) - return (0); + goto done; orig_l3 = pmap_load(l3); if ((orig_l3 & PTE_V) == 0 || ((prot & VM_PROT_WRITE) != 0 && (orig_l3 & PTE_W) == 0) || ((prot & VM_PROT_READ) != 0 && (orig_l3 & PTE_R) == 0)) - return (0); + goto done; new_l3 = orig_l3 | PTE_A; if ((prot & VM_PROT_WRITE) != 0) @@ -1941,7 +1946,8 @@ pmap_fault_fixup(pmap_t pmap, vm_offset_t va, vm_prot_ if (orig_l3 != new_l3) { pmap_load_store(l3, new_l3); pmap_invalidate_page(pmap, va); - return (1); + rv = 1; + goto done; } /* @@ -1949,7 +1955,10 @@ pmap_fault_fixup(pmap_t pmap, vm_offset_t va, vm_prot_ * the PTE shouldn't have resulted in a fault. */ - return (0); +done: + PMAP_UNLOCK(pmap); + + return (rv); } /* @@ -1992,6 +2001,8 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, v new_l3 |= PTE_W; if ((va >> 63) == 0) new_l3 |= PTE_U; + else + new_l3 |= PTE_A | PTE_D; new_l3 |= (pn << PTE_PPN0_S); if ((flags & PMAP_ENTER_WIRED) != 0)