svn commit: r248199 - projects/amd64_xen_pv/sys/amd64/xen
Cherry G. Mathew
cherry at FreeBSD.org
Tue Mar 12 12:33:51 UTC 2013
Author: cherry
Date: Tue Mar 12 12:33:50 2013
New Revision: 248199
URL: http://svnweb.freebsd.org/changeset/base/248199
Log:
Modify the mmu_map_hold_va() to indicate if it had to allocate backing pages.
'const'ify memrchr() to reflect its level of access to datatypes.
Approved by: gibbs (implicit)
Modified:
projects/amd64_xen_pv/sys/amd64/xen/mmu_map.c
projects/amd64_xen_pv/sys/amd64/xen/mmu_map.h
Modified: projects/amd64_xen_pv/sys/amd64/xen/mmu_map.c
==============================================================================
--- projects/amd64_xen_pv/sys/amd64/xen/mmu_map.c Tue Mar 12 12:23:47 2013 (r248198)
+++ projects/amd64_xen_pv/sys/amd64/xen/mmu_map.c Tue Mar 12 12:33:50 2013 (r248199)
@@ -173,7 +173,7 @@ pmap_get_pt(uintptr_t va, pd_entry_t *pd
* stateful api.
*/
-static const uint64_t SANE = 0xcafebabe;
+static const uint32_t SANE = 0xcafebabe;
struct mmu_map_index {
pml4_entry_t *pml4t; /* Page Map Level 4 Table */
@@ -309,7 +309,7 @@ mmu_map_inspect_va(struct pmap *pm, void
return true;
}
-void
+bool
mmu_map_hold_va(struct pmap *pm, void *addr, uintptr_t va)
{
KASSERT(addr != NULL && pm != NULL, ("NULL arg(s) given"));
@@ -317,6 +317,7 @@ mmu_map_hold_va(struct pmap *pm, void *a
struct mmu_map_index *pti = addr;
KASSERT(pti->sanity == SANE, ("Uninitialised index cookie used"));
+ bool alloced = false; /* Did we have to alloc backing pages ? */
vm_paddr_t pt;
pti->pml4t = pmap_get_pml4t(pm);
@@ -329,6 +330,7 @@ mmu_map_hold_va(struct pmap *pm, void *a
pml4_entry_t pml4te;
pti->pdpt = (pdp_entry_t *)pti->ptmb.alloc();
+ alloced = true;
pml4tep = &pti->pml4t[pml4t_index(va)];
pml4tep_ma = xpmap_ptom(pti->ptmb.vtop((uintptr_t)pml4tep));
@@ -347,6 +349,7 @@ mmu_map_hold_va(struct pmap *pm, void *a
pdp_entry_t pdpte;
pti->pdt = (pd_entry_t *)pti->ptmb.alloc();
+ alloced = true;
pdptep = &pti->pdpt[pdpt_index(va)];
pdptep_ma = xpmap_ptom(pti->ptmb.vtop((uintptr_t)pdptep));
@@ -359,12 +362,14 @@ mmu_map_hold_va(struct pmap *pm, void *a
pt = pmap_get_pt(va, pti->pdt);
+
if (pt == 0) {
pd_entry_t *pdtep;
vm_paddr_t pdtep_ma;
pd_entry_t pdte;
pti->pt = (pt_entry_t *) pti->ptmb.alloc();
+ alloced = true;
pdtep = &pti->pdt[pdt_index(va)];
pdtep_ma = xpmap_ptom(pti->ptmb.vtop((uintptr_t)pdtep));
@@ -374,6 +379,8 @@ mmu_map_hold_va(struct pmap *pm, void *a
} else {
pti->pt = (pt_entry_t *) pti->ptmb.ptov(pt);
}
+
+ return alloced;
}
/*$FreeBSD: head/lib/libc/string/memrchr.c 178051 2008-04-10 00:12:44Z delphij $*/
@@ -381,16 +388,19 @@ mmu_map_hold_va(struct pmap *pm, void *a
* Reverse memchr()
* Find the last occurrence of 'c' in the buffer 's' of size 'n'.
*/
-static void *
+
+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 = (unsigned char *)s + n;
+ cp = (const unsigned char *)s + n;
do {
if (*(--cp) == (unsigned char)c)
- return((void *)cp);
+ return((const void *)cp);
} while (--n != 0);
}
return(NULL);
Modified: projects/amd64_xen_pv/sys/amd64/xen/mmu_map.h
==============================================================================
--- projects/amd64_xen_pv/sys/amd64/xen/mmu_map.h Tue Mar 12 12:23:47 2013 (r248198)
+++ projects/amd64_xen_pv/sys/amd64/xen/mmu_map.h Tue Mar 12 12:33:50 2013 (r248199)
@@ -131,7 +131,7 @@ bool mmu_map_inspect_va(struct pmap *, m
* Unconditionally allocate resources to setup and "inspect" (as
* above) a given va->pa mapping
*/
-void mmu_map_hold_va(struct pmap *, mmu_map_t, vm_offset_t);
+bool mmu_map_hold_va(struct pmap *, mmu_map_t, vm_offset_t);
/* Optionally release resources after tear down of a va->pa mapping */
void mmu_map_release_va(struct pmap *, mmu_map_t, vm_offset_t);
More information about the svn-src-projects
mailing list