diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2010-01-01 13:17:53 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2010-01-01 13:17:53 +0000 |
commit | 7c56b31e12e0fdf46b104587471be48822867433 (patch) | |
tree | b3be38f9c470250e170babd40ac620645be20d66 /sys/arch | |
parent | 48ad91b3516c5418c7308c6ffdb411dd8f4ab9b1 (diff) |
Make sure page is cache invalidated in pmap_unmap_direct(), for the next use
of this page may use different cache indexes.
ok kettenis@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/sh/include/pmap.h | 6 | ||||
-rw-r--r-- | sys/arch/sh/sh/pmap.c | 32 |
2 files changed, 33 insertions, 5 deletions
diff --git a/sys/arch/sh/include/pmap.h b/sys/arch/sh/include/pmap.h index c2cd8bb4165..8b0a70ad3b6 100644 --- a/sys/arch/sh/include/pmap.h +++ b/sys/arch/sh/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.5 2008/06/26 05:42:12 ray Exp $ */ +/* $OpenBSD: pmap.h,v 1.6 2010/01/01 13:17:50 miod Exp $ */ /* $NetBSD: pmap.h,v 1.28 2006/04/10 23:12:11 uwe Exp $ */ /*- @@ -86,8 +86,8 @@ void pmap_prefer(vaddr_t, vaddr_t *); #endif /* SH4 */ #define __HAVE_PMAP_DIRECT -#define pmap_map_direct(pg) SH3_PHYS_TO_P1SEG(VM_PAGE_TO_PHYS(pg)) -#define pmap_unmap_direct(va) PHYS_TO_VM_PAGE(SH3_P1SEG_TO_PHYS((va))) +vaddr_t pmap_map_direct(vm_page_t); +vm_page_t pmap_unmap_direct(vaddr_t); /* MD pmap utils. */ pt_entry_t *__pmap_pte_lookup(pmap_t, vaddr_t); diff --git a/sys/arch/sh/sh/pmap.c b/sys/arch/sh/sh/pmap.c index 90722030914..c4c990ecd19 100644 --- a/sys/arch/sh/sh/pmap.c +++ b/sys/arch/sh/sh/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.12 2009/07/23 19:20:56 miod Exp $ */ +/* $OpenBSD: pmap.c,v 1.13 2010/01/01 13:17:52 miod Exp $ */ /* $NetBSD: pmap.c,v 1.55 2006/08/07 23:19:36 tsutsui Exp $ */ /*- @@ -931,7 +931,7 @@ __pmap_pv_page_free(struct pool *pool, void *v) /* Invalidate cache for next use of this page */ if (SH_HAS_VIRTUAL_ALIAS) - sh_icache_sync_range_index(va, PAGE_SIZE); + sh_dcache_inv_range(va, PAGE_SIZE); uvm_pagefree(PHYS_TO_VM_PAGE(SH3_P1SEG_TO_PHYS(va))); } @@ -1095,3 +1095,31 @@ __pmap_asid_free(int asid) i = asid >> 5; __pmap_asid.map[i] &= ~(1 << (asid - (i << 5))); } + +/* + * Routines used by PMAP_MAP_DIRECT() and PMAP_UNMAP_DIRECT() to provide + * directly-translated pages. + * + * Because of cache virtual aliases, it is necessary to evict these pages + * from the cache, when `unmapping' them (as they might be reused by a + * different allocator). We also rely upon all users of pages to either + * use them with pmap_enter()/pmap_remove(), to enforce proper cache handling, + * or to invoke sh_dcache_inv_range() themselves, as done for page tables. + */ +vaddr_t +pmap_map_direct(vm_page_t pg) +{ + return SH3_PHYS_TO_P1SEG(VM_PAGE_TO_PHYS(pg)); +} + +vm_page_t +pmap_unmap_direct(vaddr_t va) +{ + paddr_t pa = SH3_P1SEG_TO_PHYS(va); + vm_page_t pg = PHYS_TO_VM_PAGE(pa); + + if (SH_HAS_VIRTUAL_ALIAS) + sh_dcache_inv_range(va, PAGE_SIZE); + + return pg; +} |