Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sh3/sh3 Protect accesses to PTE/TLB registers with



details:   https://anonhg.NetBSD.org/src/rev/e29add4bea73
branches:  trunk
changeset: 572340:e29add4bea73
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Thu Dec 30 09:48:30 2004 +0000

description:
Protect accesses to PTE/TLB registers with
_cpu_exception_suspend()/_cpu_exception_resume() pair.

Should fix spontaneous reboot problem on heavy load reported by
Christian Groessler on port-dreamcast.

diffstat:

 sys/arch/sh3/sh3/mmu.c     |   7 +++++--
 sys/arch/sh3/sh3/mmu_sh3.c |  20 +++++++++++++++-----
 sys/arch/sh3/sh3/mmu_sh4.c |  20 ++++++++++++++++----
 3 files changed, 36 insertions(+), 11 deletions(-)

diffs (213 lines):

diff -r 35ed940d0071 -r e29add4bea73 sys/arch/sh3/sh3/mmu.c
--- a/sys/arch/sh3/sh3/mmu.c    Thu Dec 30 09:32:13 2004 +0000
+++ b/sys/arch/sh3/sh3/mmu.c    Thu Dec 30 09:48:30 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mmu.c,v 1.9 2003/07/15 03:35:57 lukem Exp $    */
+/*     $NetBSD: mmu.c,v 1.10 2004/12/30 09:48:30 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mmu.c,v 1.9 2003/07/15 03:35:57 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mmu.c,v 1.10 2004/12/30 09:48:30 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -112,6 +112,9 @@
 void
 sh_tlb_set_asid(int asid)
 {
+       int s;
 
+       s = _cpu_exception_suspend();
        _reg_write_4(SH_(PTEH), asid);
+       _cpu_exception_resume(s);
 }
diff -r 35ed940d0071 -r e29add4bea73 sys/arch/sh3/sh3/mmu_sh3.c
--- a/sys/arch/sh3/sh3/mmu_sh3.c        Thu Dec 30 09:32:13 2004 +0000
+++ b/sys/arch/sh3/sh3/mmu_sh3.c        Thu Dec 30 09:48:30 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mmu_sh3.c,v 1.6 2003/07/15 03:35:57 lukem Exp $        */
+/*     $NetBSD: mmu_sh3.c,v 1.7 2004/12/30 09:48:30 tsutsui Exp $      */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mmu_sh3.c,v 1.6 2003/07/15 03:35:57 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mmu_sh3.c,v 1.7 2004/12/30 09:48:30 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -63,10 +63,11 @@
 sh3_tlb_invalidate_addr(int asid, vaddr_t va)
 {
        u_int32_t a, d;
-       int w;
+       int s, w;
 
        d = (va & SH3_MMUAA_D_VPN_MASK_4K) | asid;  /* 4K page */
        va = va & SH3_MMU_VPN_MASK;   /* [16:12] entry index */
+       s = _cpu_exception_suspend();
 
        /* Probe entry and invalidate it. */
        for (w = 0; w < SH3_MMU_WAY; w++) {
@@ -77,14 +78,17 @@
                        break;
                }
        }
+
+       _cpu_exception_resume(s);
 }
 
 void
 sh3_tlb_invalidate_asid(int asid)
 {
        u_int32_t aw, a;
-       int e, w;
+       int s, e, w;
 
+       s = _cpu_exception_suspend();
        /* Invalidate entry attribute to ASID */
        for (w = 0; w < SH3_MMU_WAY; w++) {
                aw = (w << SH3_MMU_WAY_SHIFT);
@@ -96,14 +100,16 @@
                        }
                }
        }
+       _cpu_exception_resume(s);
 }
 
 void
 sh3_tlb_invalidate_all()
 {
        u_int32_t aw, a;
-       int e, w;
+       int s, e, w;
 
+       s = _cpu_exception_suspend();
        /* Zero clear all TLB entry to avoid unexpected VPN match. */
        for (w = 0; w < SH3_MMU_WAY; w++) {
                aw = (w << SH3_MMU_WAY_SHIFT);
@@ -113,15 +119,18 @@
                        _reg_write_4(SH3_MMUDA | a, 0);
                }
        }
+       _cpu_exception_resume(s);
 }
 
 void
 sh3_tlb_update(int asid, vaddr_t va, u_int32_t pte)
 {
        u_int32_t oasid;
+       int s;
 
        KDASSERT(asid < 0x100 && (pte & ~PGOFSET) != 0 && va != 0);
 
+       s = _cpu_exception_suspend();
        /* Save old ASID */
        oasid = _reg_read_4(SH3_PTEH) & SH3_PTEH_ASID_MASK;
 
@@ -136,4 +145,5 @@
        /* Restore old ASID */
        if (asid != oasid)
                _reg_write_4(SH3_PTEH, oasid);
+       _cpu_exception_resume(s);
 }
diff -r 35ed940d0071 -r e29add4bea73 sys/arch/sh3/sh3/mmu_sh4.c
--- a/sys/arch/sh3/sh3/mmu_sh4.c        Thu Dec 30 09:32:13 2004 +0000
+++ b/sys/arch/sh3/sh3/mmu_sh4.c        Thu Dec 30 09:48:30 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mmu_sh4.c,v 1.7 2003/07/15 03:35:57 lukem Exp $        */
+/*     $NetBSD: mmu_sh4.c,v 1.8 2004/12/30 09:48:30 tsutsui Exp $      */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mmu_sh4.c,v 1.7 2003/07/15 03:35:57 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mmu_sh4.c,v 1.8 2004/12/30 09:48:30 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -85,7 +85,10 @@
 sh4_tlb_invalidate_addr(int asid, vaddr_t va)
 {
        u_int32_t pteh;
+       int s;
+
        va &= SH4_PTEH_VPN_MASK;
+       s = _cpu_exception_suspend();
 
        /* Save current ASID */
        pteh = _reg_read_4(SH4_PTEH);
@@ -98,14 +101,17 @@
        RUN_P1;
        /* Restore ASID */
        _reg_write_4(SH4_PTEH, pteh);
+
+       _cpu_exception_resume(s);
 }
 
 void
 sh4_tlb_invalidate_asid(int asid)
 {
        u_int32_t a;
-       int e;
+       int e, s;
 
+       s = _cpu_exception_suspend();
        /* Invalidate entry attribute to ASID */
        RUN_P2;
        for (e = 0; e < SH4_UTLB_ENTRY; e++) {
@@ -116,14 +122,16 @@
 
        __sh4_itlb_invalidate_all();
        RUN_P1;
+       _cpu_exception_resume(s);
 }
 
 void
 sh4_tlb_invalidate_all()
 {
        u_int32_t a;
-       int e, eend;
+       int e, eend, s;
 
+       s = _cpu_exception_suspend();
        /* If non-wired entry limit is zero, clear all entry. */
        a = _reg_read_4(SH4_MMUCR) & SH4_MMUCR_URB_MASK;
        eend = a ? (a >> SH4_MMUCR_URB_SHIFT) : SH4_UTLB_ENTRY;
@@ -141,6 +149,7 @@
        _reg_write_4(SH4_ITLB_DA1 | (2 << SH4_ITLB_E_SHIFT), 0);
        _reg_write_4(SH4_ITLB_DA1 | (3 << SH4_ITLB_E_SHIFT), 0);
        RUN_P1;
+       _cpu_exception_resume(s);
 }
 
 void
@@ -148,9 +157,11 @@
 {
        u_int32_t oasid;
        u_int32_t ptel;
+       int s;
 
        KDASSERT(asid < 0x100 && (pte & ~PGOFSET) != 0 && va != 0);
 
+       s = _cpu_exception_suspend();
        /* Save old ASID */
        oasid = _reg_read_4(SH4_PTEH) & SH4_PTEH_ASID_MASK;
 
@@ -173,4 +184,5 @@
        /* Restore old ASID */
        if (asid != oasid)
                _reg_write_4(SH4_PTEH, oasid);
+       _cpu_exception_resume(s);
 }



Home | Main Index | Thread Index | Old Index