Hi,
So it turns out that my allocator is not capable of handling the pmap_prefer
horror. This diff exports the actual parameters of pmap_prefer, so I can
make the allocator deal with this intelligently.
I need compile tests on:
- arm
- hppa
- hppa64
- m68k
- mips64
- sh
- sparc
- sparc64
Since the code is not actually called, it should not affect running of kernels.
Ok?
--
Ariane
Index: arch//arm/include/pmap.h
===================================================================
RCS file: /cvs/src/sys/arch/arm/include/pmap.h,v
retrieving revision 1.17
diff -u -d -p -r1.17 pmap.h
--- arch//arm/include/pmap.h 23 Mar 2011 16:54:34 -0000 1.17
+++ arch//arm/include/pmap.h 5 Apr 2011 16:30:58 -0000
@@ -620,6 +620,14 @@ vaddr_t pmap_prefer(vaddr_t, vaddr_t);
extern uint32_t pmap_alias_dist;
extern uint32_t pmap_alias_bits;
+
+/* pmap prefer alias alignment. */
+#define PMAP_PREFER_ALIGN() (pmap_alias_dist)
+/* pmap prefer offset withing alignment. */
+#define PMAP_PREFER_OFFSET(of) \
+ (PMAP_PREFER_ALIGN() == 0 ? 0 : ((of) & (PMAP_PREFER_ALIGN() - 1)))
+
+
#endif /* _LOCORE */
#endif /* _KERNEL */
Index: arch//hppa/include/pmap.h
===================================================================
RCS file: /cvs/src/sys/arch/hppa/include/pmap.h,v
retrieving revision 1.40
diff -u -d -p -r1.40 pmap.h
--- arch//hppa/include/pmap.h 26 Dec 2010 15:40:59 -0000 1.40
+++ arch//hppa/include/pmap.h 5 Apr 2011 16:30:59 -0000
@@ -101,6 +101,11 @@ pmap_prefer(vaddr_t offs, vaddr_t hint)
return pmap_prefer_hint;
}
+/* pmap prefer alignment */
+#define PMAP_PREFER_ALIGN() (HPPA_PGALIAS)
+/* pmap prefer offset within alignment */
+#define PMAP_PREFER_OFFSET(of) ((of) & HPPA_PGAOFF)
+
#define pmap_sid2pid(s) (((s) + 1) << 1)
#define pmap_kernel() (&kernel_pmap_store)
#define pmap_resident_count(pmap)
((pmap)->pm_stats.resident_count)
Index: arch//hppa64/include/pmap.h
===================================================================
RCS file: /cvs/src/sys/arch/hppa64/include/pmap.h,v
retrieving revision 1.4
diff -u -d -p -r1.4 pmap.h
--- arch//hppa64/include/pmap.h 26 Dec 2010 15:40:59 -0000 1.4
+++ arch//hppa64/include/pmap.h 5 Apr 2011 16:30:59 -0000
@@ -68,6 +68,11 @@ pmap_prefer(vaddr_t offs, vaddr_t hint)
return pmap_prefer_hint;
}
+/* pmap prefer alignment */
+#define PMAP_PREFER_ALIGN() (HPPA_PGALIAS)
+/* pmap prefer offset within alignment */
+#define PMAP_PREFER_OFFSET(of) ((of) & HPPA_PGAOFF)
+
#define PMAP_GROWKERNEL
#define PMAP_STEAL_MEMORY
Index: arch//m68k/include/pmap_motorola.h
===================================================================
RCS file: /cvs/src/sys/arch/m68k/include/pmap_motorola.h,v
retrieving revision 1.22
diff -u -d -p -r1.22 pmap_motorola.h
--- arch//m68k/include/pmap_motorola.h 23 Mar 2011 16:54:35 -0000 1.22
+++ arch//m68k/include/pmap_motorola.h 5 Apr 2011 16:30:59 -0000
@@ -139,6 +139,12 @@ void pmap_kenter_cache(vaddr_t, paddr_t,
#ifdef M68K_MMU_HP
vaddr_t pmap_prefer(vaddr_t, vaddr_t);
#define PMAP_PREFER(foff, va) pmap_prefer((foff), (va))
+
+extern int pmap_aliasmask; /* separation at which VA aliasing is ok */
+/* pmap prefer alignment */
+#define PMAP_PREFER_ALIGN() (pmap_aliasmask ? pmap_aliasmask + 1 : 0)
+/* pmap prefer offset */
+#define PMAP_PREFER_OFFSET(of) ((of) & pmap_aliasmask)
#endif
#endif /* _KERNEL */
Index: arch//m68k/m68k/pmap_motorola.c
===================================================================
RCS file: /cvs/src/sys/arch/m68k/m68k/pmap_motorola.c,v
retrieving revision 1.59
diff -u -d -p -r1.59 pmap_motorola.c
--- arch//m68k/m68k/pmap_motorola.c 6 Dec 2010 20:57:16 -0000 1.59
+++ arch//m68k/m68k/pmap_motorola.c 5 Apr 2011 16:30:59 -0000
@@ -276,9 +276,6 @@ vaddr_t virtual_end; /* VA of last avai
TAILQ_HEAD(pv_page_list, pv_page) pv_page_freelist;
int pv_nfree;
-#if defined(M68K_MMU_HP)
-extern int pmap_aliasmask; /* separation at which VA aliasing is ok */
-#endif
#if defined(M68040) || defined(M68060)
int protostfree; /* prototype (default) free ST map */
#endif
Index: arch//mips64/include/pmap.h
===================================================================
RCS file: /cvs/src/sys/arch/mips64/include/pmap.h,v
retrieving revision 1.25
diff -u -d -p -r1.25 pmap.h
--- arch//mips64/include/pmap.h 23 Mar 2011 16:54:36 -0000 1.25
+++ arch//mips64/include/pmap.h 5 Apr 2011 16:30:59 -0000
@@ -125,6 +125,13 @@ extern struct pmap *const kernel_pmap_pt
#define PMAP_PREFER(pa, va) pmap_prefer(pa, va)
+extern vaddr_t CpuCacheAliasMask; /* from mips64/mips64/cpu.c */
+/* pmap prefer alignment */
+#define PMAP_PREFER_ALIGN() \
+ (CpuCacheAliasMask ? CpuCacheAliasMask + 1 : 0)
+/* pmap prefer offset in alignment */
+#define PMAP_PREFER_OFFSET(of) ((of) & CpuCacheAliasMask)
+
#define pmap_update(x) do { /* nothing */ } while (0)
void pmap_bootstrap(void);
Index: arch//sh/include/pmap.h
===================================================================
RCS file: /cvs/src/sys/arch/sh/include/pmap.h,v
retrieving revision 1.9
diff -u -d -p -r1.9 pmap.h
--- arch//sh/include/pmap.h 26 Dec 2010 15:41:00 -0000 1.9
+++ arch//sh/include/pmap.h 5 Apr 2011 16:31:00 -0000
@@ -81,6 +81,13 @@ pmap_remove_all(struct pmap *pmap)
#ifdef SH4
#define PMAP_PREFER(pa, va) pmap_prefer((pa), (va))
vaddr_t pmap_prefer(vaddr_t, vaddr_t);
+vaddr_t pmap_prefer_align();
+vaddr_t pmap_prefer_offset(vaddr_t);
+
+/* pmap prefer alignment */
+#define PMAP_PREFER_ALIGN() pmap_prefer_align()
+/* pmap prefer offset in alignment */
+#define PMAP_PREFER_OFFSET(of) pmap_prefer_offset(of)
#endif /* SH4 */
#define __HAVE_PMAP_DIRECT
Index: arch//sh/sh/pmap.c
===================================================================
RCS file: /cvs/src/sys/arch/sh/sh/pmap.c,v
retrieving revision 1.17
diff -u -d -p -r1.17 pmap.c
--- arch//sh/sh/pmap.c 14 Dec 2010 20:24:25 -0000 1.17
+++ arch//sh/sh/pmap.c 5 Apr 2011 16:31:00 -0000
@@ -903,6 +903,28 @@ pmap_prefer(vaddr_t foff, vaddr_t va)
return va;
}
+
+/*
+ * pmap_prefer_align()
+ *
+ * Return virtual cache alignment.
+ */
+vaddr_t
+pmap_prefer_align(void)
+{
+ return SH_HAS_VIRTUAL_ALIAS ? sh_cache_prefer_mask + 1 : 0;
+}
+
+/*
+ * pmap_prefer_offset(vaddr_t of)
+ *
+ * Calculate offset in virtual cache.
+ */
+vaddr_t
+pmap_prefer_offset(vaddr_t of)
+{
+ return of & (SH_HAS_VIRTUAL_ALIAS ? sh_cache_prefer_mask : 0);
+}
#endif /* SH4 */
/*
Index: arch//sparc/include/pmap.h
===================================================================
RCS file: /cvs/src/sys/arch/sparc/include/pmap.h,v
retrieving revision 1.51
diff -u -d -p -r1.51 pmap.h
--- arch//sparc/include/pmap.h 23 Mar 2011 16:54:37 -0000 1.51
+++ arch//sparc/include/pmap.h 5 Apr 2011 16:31:00 -0000
@@ -263,6 +263,13 @@ int pmap_dumpmmu(int (*)(dev
#define PMAP_PREFER(fo, ap) pmap_prefer((fo), (ap))
+extern int cache_alias_dist;
+/* pmap prefer alignment */
+#define PMAP_PREFER_ALIGN() cache_alias_dist
+/* pmap prefer offset in alignment */
+#define PMAP_PREFER_OFFSET(of) \
+ ((of) & (cache_alias_dist ? cache_alias_dist - 1 : 0))
+
#define PMAP_EXCLUDE_DECLS /* tells MI pmap.h *not* to include decls */
/* FUNCTION DECLARATIONS FOR COMMON PMAP MODULE */
Index: arch//sparc/sparc/pmap.c
===================================================================
RCS file: /cvs/src/sys/arch/sparc/sparc/pmap.c,v
retrieving revision 1.158
diff -u -d -p -r1.158 pmap.c
--- arch//sparc/sparc/pmap.c 6 Dec 2010 20:57:18 -0000 1.158
+++ arch//sparc/sparc/pmap.c 5 Apr 2011 16:31:00 -0000
@@ -6259,6 +6259,9 @@ pmap_prefer(vaddr_t foff, vaddr_t va)
return va;
}
+/* For PMAP_PREFER_ALIGN */
+int cache_alias_dist = CACHE_ALIAS_DIST;
+
void
pmap_remove_holes(struct vm_map *map)
{
Index: arch//sparc64/include/pmap.h
===================================================================
RCS file: /cvs/src/sys/arch/sparc64/include/pmap.h,v
retrieving revision 1.19
diff -u -d -p -r1.19 pmap.h
--- arch//sparc64/include/pmap.h 26 Dec 2010 15:41:00 -0000 1.19
+++ arch//sparc64/include/pmap.h 5 Apr 2011 16:31:00 -0000
@@ -169,6 +169,11 @@ void pmap_bootstrap(u_long, u_long, u_in
/* make sure all page mappings are modulo 16K to prevent d$ aliasing */
#define PMAP_PREFER(pa, va) ((va) + (((va) ^ (pa)) & VA_ALIAS_MASK))
+/* pmap prefer alignment */
+#define PMAP_PREFER_ALIGN (VA_ALIAS_MASK + 1)
+/* pmap prefer offset in alignment */
+#define PMAP_PREFER_OFFSET(of) ((of) & VA_ALIAS_MASK)
+
#define PMAP_GROWKERNEL /* turn on pmap_growkernel interface */
/* SPARC specific? */