summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-06-16 23:04:50 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-06-16 23:04:50 +0000
commit80d7b3f20b71262c9cf927d3f395e9b0eca7d70e (patch)
treecc20a7d17c4d2e675882a16552bb98fabbdd4be5 /sys/arch
parent6eae977c6808a59c29dcc28e6253ec3ddb3f5b5d (diff)
When checking if a page is managed or not, do not invoke IS_VM_PHYSADDR
and then pa_to_pvh, since they amount to the same work; instead let pa_to_pvh return NULL for unmanaged pages and test for this.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/sparc64/sparc64/pmap.c62
1 files changed, 32 insertions, 30 deletions
diff --git a/sys/arch/sparc64/sparc64/pmap.c b/sys/arch/sparc64/sparc64/pmap.c
index bbb59f704ec..14f84bc2ffe 100644
--- a/sys/arch/sparc64/sparc64/pmap.c
+++ b/sys/arch/sparc64/sparc64/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.29 2006/06/02 19:53:32 miod Exp $ */
+/* $OpenBSD: pmap.c,v 1.30 2006/06/16 23:04:49 miod Exp $ */
/* $NetBSD: pmap.c,v 1.107 2001/08/31 16:47:41 eeh Exp $ */
#undef NO_VCACHE /* Don't forget the locked TLB in dostart */
/*
@@ -68,8 +68,6 @@ paddr_t cpu0paddr;/* XXXXXXXXXXXXXXXX */
extern int64_t asmptechk(int64_t *pseg[], int addr); /* DEBUG XXXXX */
-#define IS_VM_PHYSADDR(PA) (vm_physseg_find(atop(PA), NULL) != -1)
-
#if 0
static int pseg_check(struct pmap*, vaddr_t addr, int64_t tte, paddr_t spare);
static int
@@ -252,6 +250,7 @@ extern void pmap_page_cache(struct pmap *pm, paddr_t pa, int mode);
void pmap_pinit(struct pmap *);
void pmap_release(struct pmap *);
+pv_entry_t pa_to_pvh(paddr_t);
/*
* First and last managed physical addresses. XXX only used for dumping the system.
@@ -259,15 +258,18 @@ void pmap_release(struct pmap *);
paddr_t vm_first_phys, vm_num_phys;
u_int64_t first_phys_addr;
-#define pa_index(pa) atop((pa) - first_phys_addr)
-#define pa_to_pvh(pa) \
-({ \
- int bank_, pg_; \
- \
- bank_ = vm_physseg_find(atop((pa)), &pg_); \
- (pv_entry_t)&vm_physmem[bank_].pmseg.pvent[pg_]; \
-})
+pv_entry_t
+pa_to_pvh(paddr_t pa)
+{
+ int bank, pg;
+
+ bank = vm_physseg_find(atop(pa), &pg);
+ if (bank == -1)
+ return (NULL);
+ else
+ return (pv_entry_t)&vm_physmem[bank].pmseg.pvent[pg];
+}
/*
@@ -1733,19 +1735,23 @@ pmap_release(pm)
for(i=0; i<STSZ; i++) {
paddr_t psegentp = (paddr_t)(u_long)&pm->pm_segs[i];
if((pdir = (paddr_t *)(u_long)ldxa((vaddr_t)psegentp,
- ASI_PHYS_CACHED))) {
+ ASI_PHYS_CACHED))) {
for (k=0; k<PDSZ; k++) {
paddr_t pdirentp = (paddr_t)(u_long)&pdir[k];
if ((ptbl = (paddr_t *)(u_long)ldxa(
(vaddr_t)pdirentp, ASI_PHYS_CACHED))) {
for (j=0; j<PTSZ; j++) {
int64_t data;
+ paddr_t pa;
+ pv_entry_t pv;
+
data = ldxa((vaddr_t)&ptbl[j],
ASI_PHYS_CACHED);
- if (data&TLB_V &&
- IS_VM_PHYSADDR(data&TLB_PA_MASK)) {
- paddr_t pa;
- pv_entry_t pv;
+ if (!(data & TLB_V))
+ continue;
+ pa = data & TLB_PA_MASK;
+ pv = pa_to_pvh(pa);
+ if (pv != NULL) {
#ifdef DEBUG
printf("pmap_release: pm=%p page %llx still in use\n", pm,
@@ -1753,8 +1759,6 @@ pmap_release(pm)
Debugger();
#endif
/* Save REF/MOD info */
- pa = data&TLB_PA_MASK;
- pv = pa_to_pvh(pa);
if (data & TLB_ACCESS)
pv->pv_va |=
PV_REF;
@@ -2177,8 +2181,8 @@ pmap_enter(pm, va, pa, prot, flags)
/*
* Construct the TTE.
*/
- if (IS_VM_PHYSADDR(pa)) {
- pv = pa_to_pvh(pa);
+ pv = pa_to_pvh(pa);
+ if (pv != NULL) {
aliased = (pv->pv_va&(PV_ALIAS|PV_NVC));
#ifdef DIAGNOSTIC
if ((flags & VM_PROT_ALL) & ~prot)
@@ -2310,15 +2314,14 @@ pmap_remove(pm, va, endva)
/* We don't really need to do this if the valid bit is not set... */
if ((data = pseg_get(pm, va))) {
paddr_t entry;
+ pv_entry_t pv;
flush |= 1;
/* First remove it from the pv_table */
entry = (data&TLB_PA_MASK);
- if (IS_VM_PHYSADDR(entry)) {
- pv_entry_t pv;
-
+ pv = pa_to_pvh(entry);
+ if (pv != NULL) {
/* Save REF/MOD info */
- pv = pa_to_pvh(entry);
if (data & TLB_ACCESS) pv->pv_va |= PV_REF;
if (data & (TLB_MODIFY)) pv->pv_va |= PV_MOD;
@@ -2372,6 +2375,7 @@ pmap_protect(pm, sva, eva, prot)
{
int s;
paddr_t pa;
+ pv_entry_t pv;
int64_t data;
ASSERT(pm != pmap_kernel() || eva < INTSTACK || sva > EINTSTACK);
@@ -2417,11 +2421,9 @@ pmap_protect(pm, sva, eva, prot)
Debugger();
}
#endif
- if (IS_VM_PHYSADDR(pa)) {
- pv_entry_t pv;
-
+ pv = pa_to_pvh(pa);
+ if (pv != NULL) {
/* Save REF/MOD info */
- pv = pa_to_pvh(pa);
if (data & TLB_ACCESS)
pv->pv_va |= PV_REF;
if (data & (TLB_MODIFY))
@@ -3607,10 +3609,10 @@ pmap_page_cache(pm, pa, mode)
if (pmapdebug & (PDB_ENTER))
printf("pmap_page_uncache(%llx)\n", (unsigned long long)pa);
#endif
- if (!IS_VM_PHYSADDR(pa))
- return;
pv = pa_to_pvh(pa);
+ if (pv == NULL)
+ return;
s = splvm();
while (pv) {