Subject: Re: sh4 pmap bug? (Re: port-dreamcast/34243)
To: None <port-sh3@NetBSD.org>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: port-sh3
Date: 08/24/2006 01:24:32
I wrote:
> Maybe we should check virtual cache index in pmap_pv_enter() and
> allow multiple mappings if VA pages being mapped have the same
> virtual indexes like mips pmap?
Here is an unreliable patch:
---
Index: include/cache.h
===================================================================
RCS file: /cvsroot/src/sys/arch/sh3/include/cache.h,v
retrieving revision 1.7
diff -u -r1.7 cache.h
--- include/cache.h 21 Jan 2006 00:46:36 -0000 1.7
+++ include/cache.h 23 Aug 2006 16:14:26 -0000
@@ -156,6 +156,9 @@
extern int sh_cache_index_mode_icache;
extern int sh_cache_index_mode_dcache;
+extern int sh_cache_alias_mask;
+#define sh_cache_indexof(x) (sh_cache_alias_mask & (x))
+
extern struct sh_cache_ops sh_cache_ops;
#define sh_icache_sync_all() \
Index: sh3/cache.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sh3/sh3/cache.c,v
retrieving revision 1.11
diff -u -r1.11 cache.c
--- sh3/cache.c 2 Jan 2006 23:37:34 -0000 1.11
+++ sh3/cache.c 23 Aug 2006 16:14:26 -0000
@@ -77,6 +77,7 @@
int sh_cache_ram_mode;
int sh_cache_index_mode_icache;
int sh_cache_index_mode_dcache;
+int sh_cache_alias_mask;
void
sh_cache_init()
Index: sh3/cache_sh4.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sh3/sh3/cache_sh4.c,v
retrieving revision 1.15
diff -u -r1.15 cache_sh4.c
--- sh3/cache_sh4.c 24 Dec 2005 23:24:02 -0000 1.15
+++ sh3/cache_sh4.c 23 Aug 2006 16:14:27 -0000
@@ -44,6 +44,7 @@
#include <sh3/cache.h>
#include <sh3/cache_sh4.h>
+#include <sh3/vmparam.h>
#define round_line(x) (((x) + 31) & ~31)
#define trunc_line(x) ((x) & ~31)
@@ -134,6 +135,7 @@
sh_cache_enable_dcache = (r & SH4_CCR_OCE);
sh_cache_ways = ways;
sh_cache_line_size = SH4_CACHE_LINESZ;
+ sh_cache_alias_mask = (dcache_size / ways - 1) & ~PAGE_MASK;
sh_cache_write_through_p0_u0_p3 = (r & SH4_CCR_WT);
sh_cache_write_through_p1 = !(r & SH4_CCR_CB);
sh_cache_write_through = sh_cache_write_through_p0_u0_p3 &&
Index: sh3/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sh3/sh3/pmap.c,v
retrieving revision 1.55
diff -u -r1.55 pmap.c
--- sh3/pmap.c 7 Aug 2006 23:19:36 -0000 1.55
+++ sh3/pmap.c 23 Aug 2006 16:14:27 -0000
@@ -457,10 +457,15 @@
s = splvm();
if (SH_HAS_VIRTUAL_ALIAS) {
/* Remove all other mapping on this physical page */
+ again:
pvh = &pg->mdpage;
- while ((pv = SLIST_FIRST(&pvh->pvh_head)) != NULL) {
- pmap_remove(pv->pv_pmap, pv->pv_va,
- pv->pv_va + PAGE_SIZE);
+ SLIST_FOREACH(pv, &pvh->pvh_head, pv_link) {
+ if (sh_cache_indexof(va) !=
+ sh_cache_indexof(pv->pv_va)) {
+ pmap_remove(pv->pv_pmap, pv->pv_va,
+ pv->pv_va + PAGE_SIZE);
+ goto again;
+ }
}
}
---
Izumi Tsutsui