From owner-dev-commits-src-all@freebsd.org Sun Jun 6 20:45:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3015863D7D3; Sun, 6 Jun 2021 20:45:12 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FypRD0dKjz3tw8; Sun, 6 Jun 2021 20:45:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E77AF2202; Sun, 6 Jun 2021 20:45:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 156KjBF5051981; Sun, 6 Jun 2021 20:45:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 156KjBuC051980; Sun, 6 Jun 2021 20:45:11 GMT (envelope-from git) Date: Sun, 6 Jun 2021 20:45:11 GMT Message-Id: <202106062045.156KjBuC051980@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 4e4035ef1fb5 - main - arm64: Fix pmap_copy()'s handling of 2MB mappings MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4e4035ef1fb5e2f9da6b658ffae8a54862b4d018 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jun 2021 20:45:12 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4e4035ef1fb5e2f9da6b658ffae8a54862b4d018 commit 4e4035ef1fb5e2f9da6b658ffae8a54862b4d018 Author: Mark Johnston AuthorDate: 2021-06-06 20:40:45 +0000 Commit: Mark Johnston CommitDate: 2021-06-06 20:44:46 +0000 arm64: Fix pmap_copy()'s handling of 2MB mappings When copying mappings from parent to child, we clear the accessed and dirty bits. This is done for both 4KB and 2MB PTEs. However, pmap_demote_l2() asserts that writable superpages must be dirty. This is to avoid races with the MMU setting the dirty bit during promotion and demotion. pmap_copy() can create clean, writable superpage mappings, so it violates this assertion. Modify pmap_copy() to preserve the accessed and dirty bits when copying 2MB mappings, like we do on amd64. Fixes: ca2cae0b4dd Reported by: Jenkins via mhorne Reviewed by: alc, kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30643 --- sys/arm64/arm64/pmap.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index c26c3d8fce17..ffc83be852bd 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -4573,11 +4573,8 @@ pmap_copy(pmap_t dst_pmap, pmap_t src_pmap, vm_offset_t dst_addr, vm_size_t len, ((srcptepaddr & ATTR_SW_MANAGED) == 0 || pmap_pv_insert_l2(dst_pmap, addr, srcptepaddr, PMAP_ENTER_NORECLAIM, &lock))) { - mask = ATTR_AF | ATTR_SW_WIRED; - nbits = 0; - if ((srcptepaddr & ATTR_SW_DBM) != 0) - nbits |= ATTR_S1_AP_RW_BIT; - pmap_store(l2, (srcptepaddr & ~mask) | nbits); + mask = ATTR_SW_WIRED; + pmap_store(l2, srcptepaddr & ~mask); pmap_resident_count_inc(dst_pmap, L2_SIZE / PAGE_SIZE); atomic_add_long(&pmap_l2_mappings, 1);