From owner-svn-src-projects@FreeBSD.ORG Mon Apr 1 10:45:36 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 1A119407; Mon, 1 Apr 2013 10:45:36 +0000 (UTC) (envelope-from cherry@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E86711F9; Mon, 1 Apr 2013 10:45:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r31AjZmJ029847; Mon, 1 Apr 2013 10:45:35 GMT (envelope-from cherry@svn.freebsd.org) Received: (from cherry@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r31AjZCV029846; Mon, 1 Apr 2013 10:45:35 GMT (envelope-from cherry@svn.freebsd.org) Message-Id: <201304011045.r31AjZCV029846@svn.freebsd.org> From: "Cherry G. Mathew" Date: Mon, 1 Apr 2013 10:45:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r248970 - projects/amd64_xen_pv/sys/amd64/xen X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2013 10:45:36 -0000 Author: cherry Date: Mon Apr 1 10:45:35 2013 New Revision: 248970 URL: http://svnweb.freebsd.org/changeset/base/248970 Log: Use memcchr(9) instead of homebrew (and slow) memrchr(3) (incorrectly used here). This implements the current semantics of searching for zero-ed out backing lower page table, before zapping its higher level table entry. Approved by: gibbs(implicit) Modified: projects/amd64_xen_pv/sys/amd64/xen/mmu_map.c Modified: projects/amd64_xen_pv/sys/amd64/xen/mmu_map.c ============================================================================== --- projects/amd64_xen_pv/sys/amd64/xen/mmu_map.c Mon Apr 1 09:59:38 2013 (r248969) +++ projects/amd64_xen_pv/sys/amd64/xen/mmu_map.c Mon Apr 1 10:45:35 2013 (r248970) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include "opt_smp.h" +#include #include #include #include @@ -383,30 +384,6 @@ mmu_map_hold_va(struct pmap *pm, void *a return alloced; } -/*$FreeBSD: head/lib/libc/string/memrchr.c 178051 2008-04-10 00:12:44Z delphij $*/ -/* - * Reverse memchr() - * Find the last occurrence of 'c' in the buffer 's' of size 'n'. - */ - -static const void * memrchr(const void *, int, size_t); - -static const void * -memrchr(const void *s, int c, size_t n) -{ - const unsigned char *cp; - - if (n != 0) { - cp = (const unsigned char *)s + n; - do { - if (*(--cp) == (unsigned char)c) - return((const void *)cp); - } while (--n != 0); - } - return(NULL); -} - - void mmu_map_release_va(struct pmap *pm, void *addr, uintptr_t va) { @@ -461,7 +438,7 @@ mmu_map_release_va(struct pmap *pm, void } /* We can free the PT only after the PDT entry is zapped */ - if (memrchr(pti->pt, 0, PAGE_SIZE) == ((char *)pti->pt + PAGE_SIZE - 1)) { + if (memcchr(pti->pt, 0, PAGE_SIZE) == NULL) { /* Zap the backing PDT entry */ pdtep_ma = xpmap_ptom(pti->ptmb.vtop((uintptr_t)pdtep)); xen_queue_pt_update(pdtep_ma, 0); @@ -509,7 +486,7 @@ mmu_map_release_va(struct pmap *pm, void } /* We can free the PDT only after the PDPT entry is zapped */ - if (memrchr(pti->pdt, 0, PAGE_SIZE) == ((char *)pti->pdt + PAGE_SIZE - 1)) { + if (memcchr(pti->pt, 0, PAGE_SIZE) == NULL) { pdptep_ma = xpmap_ptom(pti->ptmb.vtop((uintptr_t)pdptep)); xen_queue_pt_update(pdptep_ma, 0); xen_flush_queue(); @@ -551,7 +528,7 @@ mmu_map_release_va(struct pmap *pm, void return; } - if (memrchr(pti->pdpt, 0, PAGE_SIZE) == ((char *)pti->pdpt + PAGE_SIZE - 1)) { + if (memcchr(pti->pt, 0, PAGE_SIZE) == NULL) { pml4tep_ma = xpmap_ptom(pti->ptmb.vtop((uintptr_t)pml4tep) ); xen_queue_pt_update(pml4tep_ma, 0);