From owner-svn-src-head@freebsd.org Tue Sep 8 18:41:07 2015 Return-Path: Delivered-To: svn-src-head@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 4BB52A00644; Tue, 8 Sep 2015 18:41:07 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::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 234311622; Tue, 8 Sep 2015 18:41:07 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t88If7Jd033365; Tue, 8 Sep 2015 18:41:07 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t88If7G1033364; Tue, 8 Sep 2015 18:41:07 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201509081841.t88If7G1033364@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Tue, 8 Sep 2015 18:41:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287570 - head/sys/arm64/arm64 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 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: Tue, 08 Sep 2015 18:41:07 -0000 Author: andrew Date: Tue Sep 8 18:41:06 2015 New Revision: 287570 URL: https://svnweb.freebsd.org/changeset/base/287570 Log: Add support for pmap_mincore on arm64 by walking the page tables to find the details for the requested address. PR: 202307 Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation Modified: head/sys/arm64/arm64/pmap.c Modified: head/sys/arm64/arm64/pmap.c ============================================================================== --- head/sys/arm64/arm64/pmap.c Tue Sep 8 18:37:16 2015 (r287569) +++ head/sys/arm64/arm64/pmap.c Tue Sep 8 18:41:06 2015 (r287570) @@ -3032,8 +3032,74 @@ pmap_page_set_memattr(vm_page_t m, vm_me int pmap_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t *locked_pa) { + pd_entry_t *l1p, l1; + pd_entry_t *l2p, l2; + pt_entry_t *l3p, l3; + vm_paddr_t pa; + bool managed; + int val; + + PMAP_LOCK(pmap); +retry: + pa = 0; + val = 0; + managed = false; + + l1p = pmap_l1(pmap, addr); + if (l1p == NULL) /* No l1 */ + goto done; + l1 = pmap_load(l1p); + if ((l1 & ATTR_DESCR_MASK) == L1_BLOCK) { + pa = (l1 & ~ATTR_MASK) | (addr & L1_OFFSET); + managed = (l1 & ATTR_SW_MANAGED) == ATTR_SW_MANAGED; + val = MINCORE_SUPER | MINCORE_INCORE; + if (pmap_page_dirty(l1)) + val |= MINCORE_MODIFIED | MINCORE_MODIFIED_OTHER; + if ((l1 & ATTR_AF) == ATTR_AF) + val |= MINCORE_REFERENCED | MINCORE_REFERENCED_OTHER; + goto done; + } + + l2p = pmap_l1_to_l2(l1p, addr); + if (l2p == NULL) /* No l2 */ + goto done; + l2 = pmap_load(l2p); + if ((l2 & ATTR_DESCR_MASK) == L2_BLOCK) { + pa = (l2 & ~ATTR_MASK) | (addr & L2_OFFSET); + managed = (l2 & ATTR_SW_MANAGED) == ATTR_SW_MANAGED; + val = MINCORE_SUPER | MINCORE_INCORE; + if (pmap_page_dirty(l2)) + val |= MINCORE_MODIFIED | MINCORE_MODIFIED_OTHER; + if ((l2 & ATTR_AF) == ATTR_AF) + val |= MINCORE_REFERENCED | MINCORE_REFERENCED_OTHER; + goto done; + } + + l3p = pmap_l2_to_l3(l2p, addr); + if (l3p == NULL) /* No l3 */ + goto done; + l3 = pmap_load(l2p); + if ((l3 & ATTR_DESCR_MASK) == L3_PAGE) { + pa = (l3 & ~ATTR_MASK) | (addr & L3_OFFSET); + managed = (l3 & ATTR_SW_MANAGED) == ATTR_SW_MANAGED; + val = MINCORE_INCORE; + if (pmap_page_dirty(l3)) + val |= MINCORE_MODIFIED | MINCORE_MODIFIED_OTHER; + if ((l3 & ATTR_AF) == ATTR_AF) + val |= MINCORE_REFERENCED | MINCORE_REFERENCED_OTHER; + } + +done: + if ((val & (MINCORE_MODIFIED_OTHER | MINCORE_REFERENCED_OTHER)) != + (MINCORE_MODIFIED_OTHER | MINCORE_REFERENCED_OTHER) && managed) { + /* Ensure that "PHYS_TO_VM_PAGE(pa)->object" doesn't change. */ + if (vm_page_pa_tryrelock(pmap, pa, locked_pa)) + goto retry; + } else + PA_UNLOCK_COND(*locked_pa); + PMAP_UNLOCK(pmap); - panic("ARM64TODO: pmap_mincore"); + return (val); } void