summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2013-02-19 21:02:06 +0000
committermiod <miod@openbsd.org>2013-02-19 21:02:06 +0000
commit347e898ea3a14c5eb783b1d4b015d34c6a36d234 (patch)
treed29890e8670756800f9057fea242e2d4ceaad224
parentIntroduce `option M88410', to be added to 88110 system designs making use of the (diff)
downloadwireguard-openbsd-347e898ea3a14c5eb783b1d4b015d34c6a36d234.tar.xz
wireguard-openbsd-347e898ea3a14c5eb783b1d4b015d34c6a36d234.zip
Introduce a new cmmu method to return the preferred cache mode bits for the
kernel APR. Return write-back for every design but those involving 88410, where write through is returned. Apparently the use of writeback on single-processor kernels using 88410 (197SP, 197DP) has only been working by fat chance, and the last two years of uvm changes, as well as the switch to ELF (causing kernel rodata to move `up') exposes silent memory corruption on (88410-size) aliased addresses. (I am guilty of not using my 197DP board much after making 197LE write-back capable, as 197LE turned out to be faster and more stable, for I would have noticed this earlier). Further thought needs to happen about this. It might be possible to switch to writeback by default again as long as bus_dma maps things write-through on 88410 designs, and perhaps with a part of the kernel mapped with a write-through BATC, since BATC have precedence upon page tables. Right now I'm trying to get a stable release out of the door.
-rw-r--r--sys/arch/m88k/include/cmmu.h4
-rw-r--r--sys/arch/m88k/m88k/m8820x_machdep.c11
-rw-r--r--sys/arch/m88k/m88k/pmap.c13
-rw-r--r--sys/arch/mvme88k/mvme88k/m88110.c22
4 files changed, 40 insertions, 10 deletions
diff --git a/sys/arch/m88k/include/cmmu.h b/sys/arch/m88k/include/cmmu.h
index 5a6ddb9c023..40324d10f5f 100644
--- a/sys/arch/m88k/include/cmmu.h
+++ b/sys/arch/m88k/include/cmmu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmmu.h,v 1.28 2013/02/17 18:07:36 miod Exp $ */
+/* $OpenBSD: cmmu.h,v 1.29 2013/02/19 21:02:06 miod Exp $ */
/*
* Mach Operating System
* Copyright (c) 1993-1992 Carnegie Mellon University
@@ -42,6 +42,7 @@ struct cmmu_p {
cpuid_t (*cpu_number)(void);
+ apr_t (*kapr_cmode)(void);
void (*set_sapr)(apr_t);
void (*set_uapr)(apr_t);
@@ -82,6 +83,7 @@ extern __cpu_simple_lock_t cmmu_cpu_lock;
#define cpu_configuration_print(cpu) (cmmu->cpu_configuration_print)(cpu)
#define cmmu_shutdown (cmmu->shutdown)
#define cmmu_cpu_number (cmmu->cpu_number)
+#define cmmu_kapr_cmode (cmmu->kapr_cmode)
#define cmmu_set_sapr(apr) (cmmu->set_sapr)(apr)
#define cmmu_set_uapr(apr) (cmmu->set_uapr)(apr)
#define cmmu_tlbis(cpu, va, pte) (cmmu->tlb_inv_s)(cpu, va, pte)
diff --git a/sys/arch/m88k/m88k/m8820x_machdep.c b/sys/arch/m88k/m88k/m8820x_machdep.c
index 7756f577fab..0395f99d067 100644
--- a/sys/arch/m88k/m88k/m8820x_machdep.c
+++ b/sys/arch/m88k/m88k/m8820x_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: m8820x_machdep.c,v 1.51 2013/02/17 18:07:36 miod Exp $ */
+/* $OpenBSD: m8820x_machdep.c,v 1.52 2013/02/19 21:02:06 miod Exp $ */
/*
* Copyright (c) 2004, 2007, 2010, 2011, Miodrag Vallat.
*
@@ -90,6 +90,7 @@ extern void m8820x_copypage(vaddr_t, vaddr_t);
cpuid_t m8820x_init(void);
void m8820x_cpu_configuration_print(int);
void m8820x_shutdown(void);
+apr_t m8820x_apr_cmode(void);
void m8820x_set_sapr(apr_t);
void m8820x_set_uapr(apr_t);
void m8820x_tlbis(cpuid_t, vaddr_t, pt_entry_t);
@@ -108,6 +109,7 @@ const struct cmmu_p cmmu8820x = {
m8820x_cpu_configuration_print,
m8820x_shutdown,
m8820x_cpu_number,
+ m8820x_apr_cmode,
m8820x_set_sapr,
m8820x_set_uapr,
m8820x_tlbis,
@@ -526,6 +528,13 @@ m8820x_shutdown()
CMMU_UNLOCK;
}
+/* not used */
+apr_t
+m8820x_apr_cmode()
+{
+ return CACHE_DFL;
+}
+
void
m8820x_set_sapr(apr_t ap)
{
diff --git a/sys/arch/m88k/m88k/pmap.c b/sys/arch/m88k/m88k/pmap.c
index fcfb7cb8427..f3e4d11b63a 100644
--- a/sys/arch/m88k/m88k/pmap.c
+++ b/sys/arch/m88k/m88k/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.69 2013/02/14 05:50:49 miod Exp $ */
+/* $OpenBSD: pmap.c,v 1.70 2013/02/19 21:02:06 miod Exp $ */
/*
* Copyright (c) 2001-2004, 2010, Miodrag Vallat.
@@ -136,7 +136,7 @@ struct pmap kernel_pmap_store;
/* #define CACHE_PT (CPU_IS88100 ? CACHE_INH : CACHE_WT) */
#define CACHE_PT CACHE_WT
-#if defined(M88110) && defined(MULTIPROCESSOR)
+#if defined(M88110) && defined(M88410)
apr_t kernel_apr_cmode = CACHE_DFL; /* might be downgraded to WT */
#define KERNEL_APR_CMODE kernel_apr_cmode
#else
@@ -639,11 +639,10 @@ pmap_bootstrap(paddr_t s_rom, paddr_t e_rom)
#if defined(M88110)
if (CPU_IS88110) {
-#ifdef MULTIPROCESSOR
- /* XXX until whatever causes the kernel to hang without
- XXX is understood and fixed */
- kernel_apr_cmode = CACHE_WT;
-#else
+#if defined(M88410)
+ kernel_apr_cmode = cmmu_kapr_cmode();
+#endif
+#ifndef MULTIPROCESSOR
default_apr &= ~CACHE_GLOBAL;
#endif
}
diff --git a/sys/arch/mvme88k/mvme88k/m88110.c b/sys/arch/mvme88k/mvme88k/m88110.c
index 7f98f4cfb5b..3eb4441663f 100644
--- a/sys/arch/mvme88k/mvme88k/m88110.c
+++ b/sys/arch/mvme88k/mvme88k/m88110.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: m88110.c,v 1.77 2013/02/17 18:07:36 miod Exp $ */
+/* $OpenBSD: m88110.c,v 1.78 2013/02/19 21:02:06 miod Exp $ */
/*
* Copyright (c) 2010, 2011, Miodrag Vallat.
@@ -100,6 +100,8 @@ void m88110_cpu_configuration_print(int);
void m88410_cpu_configuration_print(int);
void m88110_shutdown(void);
cpuid_t m88110_cpu_number(void);
+apr_t m88110_kapr_cmode(void);
+apr_t m88410_kapr_cmode(void);
void m88110_set_sapr(apr_t);
void m88110_set_uapr(apr_t);
void m88110_tlbis(cpuid_t, vaddr_t, pt_entry_t);
@@ -128,6 +130,7 @@ const struct cmmu_p cmmu88110 = {
m88110_cpu_configuration_print,
m88110_shutdown,
m88110_cpu_number,
+ m88110_kapr_cmode,
m88110_set_sapr,
m88110_set_uapr,
m88110_tlbis,
@@ -153,6 +156,7 @@ const struct cmmu_p cmmu88410 = {
m88410_cpu_configuration_print,
m88110_shutdown,
m88110_cpu_number,
+ m88410_kapr_cmode,
m88110_set_sapr,
m88110_set_uapr,
m88110_tlbis,
@@ -440,6 +444,18 @@ m88110_shutdown(void)
{
}
+apr_t
+m88110_kapr_cmode(void)
+{
+ return CACHE_DFL;
+}
+
+apr_t
+m88410_kapr_cmode(void)
+{
+ return CACHE_WT;
+}
+
void
m88110_set_sapr(apr_t ap)
{
@@ -1019,6 +1035,10 @@ m88410_dma_cachectl_local(paddr_t _pa, psize_t _size, int op)
bcopy(lines, (void *)pa1, sz1);
if (sz2 != 0)
bcopy(lines + MC88110_CACHE_LINE, (void *)pa2, sz2);
+ if (sz1 != 0)
+ m88110_cmmu_wbinv_locked(pa1, MC88110_CACHE_LINE);
+ if (sz2 != 0)
+ m88110_cmmu_wbinv_locked(pa2, MC88110_CACHE_LINE);
} else {
while (size != 0) {
count = (pa & PAGE_MASK) == 0 && size >= PAGE_SIZE ?