Source-Changes-HG archive

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

[src/trunk]: src/sys/arch powerpc: Sprinkle "memory" clobbers on eieio and ne...



details:   https://anonhg.NetBSD.org/src/rev/69d1873f8498
branches:  trunk
changeset: 361598:69d1873f8498
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Feb 16 23:49:26 2022 +0000

description:
powerpc: Sprinkle "memory" clobbers on eieio and nearby asm blocks.

Otherwise the compiler may reorder these around loads and stores,
which mostly defeats the purpose.  `asm volatile' just ensures the
instruction isn't _deleted_; it may still move around.

diffstat:

 sys/arch/amiga/amiga/bus.c                  |   6 ++--
 sys/arch/amigappc/amigappc/p5reg.h          |   6 ++--
 sys/arch/amigappc/include/bus_funcs.h       |   4 +-
 sys/arch/amigappc/include/cpu.h             |   6 ++--
 sys/arch/bebox/stand/boot/io.c              |  18 ++++++------
 sys/arch/bebox/stand/boot/pci.c             |   4 +-
 sys/arch/bebox/stand/boot/vreset.c          |   4 +-
 sys/arch/evbppc/pmppc/dev/if_cs_mainbus.c   |  10 +++---
 sys/arch/ibmnws/ibmnws/machdep.c            |   8 ++--
 sys/arch/macppc/dev/if_mc.c                 |   8 ++--
 sys/arch/macppc/dev/mediabay.c              |   8 ++--
 sys/arch/macppc/dev/valkyriefb.c            |  14 +++++-----
 sys/arch/macppc/dev/zs.c                    |   6 ++--
 sys/arch/powerpc/include/pio.h              |   6 ++--
 sys/arch/powerpc/oea/pmap.c                 |  30 ++++++++++++---------
 sys/arch/powerpc/pic/intr.c                 |   8 ++--
 sys/arch/powerpc/powerpc/bus_dma.c          |  20 +++++++-------
 sys/arch/prep/stand/boot/io.c               |  18 ++++++------
 sys/arch/prep/stand/boot/pci.c              |   6 ++--
 sys/arch/prep/stand/boot/vreset.c           |   4 +-
 sys/arch/rs6000/stand/boot/boot.c           |   5 +--
 sys/arch/sandpoint/stand/altboot/brdsetup.c |  39 ++++++++++++++++++----------
 22 files changed, 126 insertions(+), 112 deletions(-)

diffs (truncated from 806 to 300 lines):

diff -r 6aaaecde891a -r 69d1873f8498 sys/arch/amiga/amiga/bus.c
--- a/sys/arch/amiga/amiga/bus.c        Wed Feb 16 23:31:13 2022 +0000
+++ b/sys/arch/amiga/amiga/bus.c        Wed Feb 16 23:49:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus.c,v 1.2 2015/11/12 12:01:53 phx Exp $ */
+/*     $NetBSD: bus.c,v 1.3 2022/02/16 23:49:26 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -39,8 +39,8 @@
                        bus_size_t offset, bus_size_t length, int flags)
 {
 /* Only amigappc needs barrier. */
-#if defined(__powerpc__) 
-       asm volatile("eieio");  
+#if defined(__powerpc__)
+       asm volatile("eieio" ::: "memory");
 #endif
 }
 
diff -r 6aaaecde891a -r 69d1873f8498 sys/arch/amigappc/amigappc/p5reg.h
--- a/sys/arch/amigappc/amigappc/p5reg.h        Wed Feb 16 23:31:13 2022 +0000
+++ b/sys/arch/amigappc/amigappc/p5reg.h        Wed Feb 16 23:49:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: p5reg.h,v 1.2 2010/02/02 19:15:33 phx Exp $ */
+/*     $NetBSD: p5reg.h,v 1.3 2022/02/16 23:49:26 riastradh Exp $ */
 
 /*
  * Copyright (C) 2000 Adam Ciarcinski.
@@ -100,13 +100,13 @@
 #define P5read(reg, val)                                               \
        do {                                                            \
                (val) = *(volatile unsigned char *)(P5BASE + (reg));    \
-               __asm volatile("eieio");                                        \
+               __asm volatile("eieio" ::: "memory");                   \
        } while (0);
 
 #define P5write(reg, val)                                              \
        do {                                                            \
                *(volatile unsigned char *)(P5BASE + (reg)) = (val);    \
-               __asm volatile("eieio");                                        \
+               __asm volatile("eieio" ::: "memory");                   \
        } while (0);
 
 #endif /* _P5REG_H_ */
diff -r 6aaaecde891a -r 69d1873f8498 sys/arch/amigappc/include/bus_funcs.h
--- a/sys/arch/amigappc/include/bus_funcs.h     Wed Feb 16 23:31:13 2022 +0000
+++ b/sys/arch/amigappc/include/bus_funcs.h     Wed Feb 16 23:49:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_funcs.h,v 1.1 2011/07/18 17:51:17 dyoung Exp $     */
+/*     $NetBSD: bus_funcs.h,v 1.2 2022/02/16 23:49:26 riastradh Exp $  */
 
 /*
  * Copyright (c) 1996 Leo Weppelman.  All rights reserved.
@@ -141,6 +141,6 @@
         ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
 
 /* Instruction for enforcing reorder protection. */
-#define amiga_bus_reorder_protect() __asm volatile ("eieio")
+#define amiga_bus_reorder_protect() __asm volatile("eieio" ::: "memory")
 
 #endif /* _AMIGAPPC_BUS_FUNCS_H_ */
diff -r 6aaaecde891a -r 69d1873f8498 sys/arch/amigappc/include/cpu.h
--- a/sys/arch/amigappc/include/cpu.h   Wed Feb 16 23:31:13 2022 +0000
+++ b/sys/arch/amigappc/include/cpu.h   Wed Feb 16 23:49:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.20 2011/06/20 06:35:39 matt Exp $    */
+/*     $NetBSD: cpu.h,v 1.21 2022/02/16 23:49:26 riastradh Exp $       */
 
 /*
  * Copyright (C) 1995-1997 Wolfgang Solfrank.
@@ -70,12 +70,12 @@
 /*
  * Reorder protection when accessing device registers.
  */
-#define amiga_membarrier() __asm volatile ("eieio")
+#define amiga_membarrier() __asm volatile("eieio" ::: "memory")
 
 /*
  * Finish all bus operations and flush pipelines.
  */
-#define amiga_cpu_sync() __asm volatile ("sync; isync")
+#define amiga_cpu_sync() __asm volatile("sync; isync" ::: "memory")
 
 #endif /* _KERNEL && !_MODULE */
 
diff -r 6aaaecde891a -r 69d1873f8498 sys/arch/bebox/stand/boot/io.c
--- a/sys/arch/bebox/stand/boot/io.c    Wed Feb 16 23:31:13 2022 +0000
+++ b/sys/arch/bebox/stand/boot/io.c    Wed Feb 16 23:49:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: io.c,v 1.7 2010/10/14 05:52:01 kiyohara Exp $  */
+/*     $NetBSD: io.c,v 1.8 2022/02/16 23:49:26 riastradh Exp $ */
 
 /*-
  * Copyright (C) 1995-1997 Gary Thomas (gdt%linuxppc.org@localhost)
@@ -124,10 +124,10 @@
 {
        uint32_t bnd;
 
-       asm volatile("eieio");
+       asm volatile("eieio" ::: "memory");
        for (bnd = adr + siz; adr < bnd; adr += dcache_line_size)
-               asm volatile ("dcbf 0,%0" :: "r"(adr));
-       asm volatile ("sync");
+               asm volatile("dcbf 0,%0" :: "r"(adr) : "memory");
+       asm volatile("sync" ::: "memory");
 }
 
 void
@@ -138,10 +138,10 @@
        off = adr & (dcache_line_size - 1);
        adr -= off;
        siz += off;
-       asm volatile ("eieio");
+       asm volatile("eieio" ::: "memory");
        if (off != 0) {
                /* wbinv() leading unaligned dcache line */
-               asm volatile ("dcbf 0,%0" :: "r"(adr));
+               asm volatile("dcbf 0,%0" :: "r"(adr) : "memory");
                if (siz < dcache_line_size)
                        goto done;
                adr += dcache_line_size;
@@ -151,15 +151,15 @@
        off = bnd & (dcache_line_size - 1);
        if (off != 0) {
                /* wbinv() trailing unaligned dcache line */
-               asm volatile ("dcbf 0,%0" :: "r"(bnd)); /* it's OK */
+               asm volatile("dcbf 0,%0" :: "r"(bnd) : "memory"); /* it's OK */
                if (siz < dcache_line_size)
                        goto done;
                siz -= off;
        }
        for (bnd = adr + siz; adr < bnd; adr += dcache_line_size) {
                /* inv() intermediate dcache lines if ever */
-               asm volatile ("dcbi 0,%0" :: "r"(adr));
+               asm volatile("dcbi 0,%0" :: "r"(adr) : "memory");
        }
   done:
-       asm volatile ("sync");
+       asm volatile("sync" ::: "memory");
 }
diff -r 6aaaecde891a -r 69d1873f8498 sys/arch/bebox/stand/boot/pci.c
--- a/sys/arch/bebox/stand/boot/pci.c   Wed Feb 16 23:31:13 2022 +0000
+++ b/sys/arch/bebox/stand/boot/pci.c   Wed Feb 16 23:49:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci.c,v 1.5 2010/10/14 06:12:54 kiyohara Exp $ */
+/*     $NetBSD: pci.c,v 1.6 2022/02/16 23:49:26 riastradh Exp $        */
 
 /*
  * Copyright (C) 1995-1997 Gary Thomas (gdt%linuxppc.org@localhost)
@@ -92,7 +92,7 @@
 
        ppci = (u_char *)&PCI_slots[slot].config_addr[CMD];
        *ppci = enable;
-       __asm volatile("eieio");
+       __asm volatile("eieio" ::: "memory");
 }
 
 void
diff -r 6aaaecde891a -r 69d1873f8498 sys/arch/bebox/stand/boot/vreset.c
--- a/sys/arch/bebox/stand/boot/vreset.c        Wed Feb 16 23:31:13 2022 +0000
+++ b/sys/arch/bebox/stand/boot/vreset.c        Wed Feb 16 23:49:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vreset.c,v 1.14 2014/12/12 15:57:30 phx Exp $  */
+/*     $NetBSD: vreset.c,v 1.15 2022/02/16 23:49:26 riastradh Exp $    */
 
 /*
  * Copyright (C) 1995-1997 Gary Thomas (gdt%linuxppc.org@localhost)
@@ -624,7 +624,7 @@
 
        for (i = 0;  i < sizeof(font);  i += 16) {
                for (j = 0;  j < 16;  j++) {
-                       __asm volatile("eieio");
+                       __asm volatile("eieio" ::: "memory");
                        font_page[(2*i)+j] = font[i+j];
                }
        }
diff -r 6aaaecde891a -r 69d1873f8498 sys/arch/evbppc/pmppc/dev/if_cs_mainbus.c
--- a/sys/arch/evbppc/pmppc/dev/if_cs_mainbus.c Wed Feb 16 23:31:13 2022 +0000
+++ b/sys/arch/evbppc/pmppc/dev/if_cs_mainbus.c Wed Feb 16 23:49:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cs_mainbus.c,v 1.8 2015/04/13 21:18:42 riastradh Exp $      */
+/*     $NetBSD: if_cs_mainbus.c,v 1.9 2022/02/16 23:49:26 riastradh Exp $      */
 
 /*
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cs_mainbus.c,v 1.8 2015/04/13 21:18:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cs_mainbus.c,v 1.9 2022/02/16 23:49:26 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -99,7 +99,7 @@
                 : "=m"(save), "=m"(*dp)
                 : "m"(u.d)
                );
-       __asm volatile ("eieio; sync");
+       __asm volatile("eieio; sync" ::: "memory");
        __asm volatile("mtmsr %0" :: "r"(msr));
        return (u.i);
 }
@@ -130,7 +130,7 @@
                 : "=m"(save), "=m"(*dp)
                 : "m"(u.d)
                );
-       __asm volatile ("eieio; sync");
+       __asm volatile("eieio; sync" ::: "memory");
        __asm volatile("mtmsr %0" :: "r"(msr));
        splx(s);
 }
@@ -208,7 +208,7 @@
                v = bswap16(v);
                u.i = (u_int64_t)v << 48;
                __asm volatile("lfd 0,%1\nstfd 0,%0" : "=m"(*dp) : "m"(u.d) );
-               __asm volatile ("eieio; sync");
+               __asm volatile("eieio; sync" ::: "memory");
        }
        __asm volatile("lfd 0,%0" :: "m"(save));
        __asm volatile("mtmsr %0" :: "r"(msr));
diff -r 6aaaecde891a -r 69d1873f8498 sys/arch/ibmnws/ibmnws/machdep.c
--- a/sys/arch/ibmnws/ibmnws/machdep.c  Wed Feb 16 23:31:13 2022 +0000
+++ b/sys/arch/ibmnws/ibmnws/machdep.c  Wed Feb 16 23:49:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.18 2021/02/27 01:31:24 thorpej Exp $     */
+/*     $NetBSD: machdep.c,v 1.19 2022/02/16 23:49:26 riastradh Exp $   */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.18 2021/02/27 01:31:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.19 2022/02/16 23:49:26 riastradh Exp $");
 
 #include "opt_compat_netbsd.h"
 
@@ -249,13 +249,13 @@
            reg &= ~1UL;
            *(volatile u_char *)(PREP_BUS_SPACE_IO + 0x92) = reg;
 
-           __asm volatile("sync; eieio\n");
+           __asm volatile("sync; eieio" ::: "memory");
 
            reg = *(volatile u_char *)(PREP_BUS_SPACE_IO + 0x92);
            reg |= 1;
            *(volatile u_char *)(PREP_BUS_SPACE_IO + 0x92) = reg;
 
-           __asm volatile("sync; eieio\n");
+           __asm volatile("sync; eieio" ::: "memory");
        }
 
        for (;;)
diff -r 6aaaecde891a -r 69d1873f8498 sys/arch/macppc/dev/if_mc.c
--- a/sys/arch/macppc/dev/if_mc.c       Wed Feb 16 23:31:13 2022 +0000
+++ b/sys/arch/macppc/dev/if_mc.c       Wed Feb 16 23:49:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_mc.c,v 1.27 2021/03/05 07:15:53 rin Exp $   */
+/*     $NetBSD: if_mc.c,v 1.28 2022/02/16 23:49:26 riastradh Exp $     */
 
 /*-
  * Copyright (c) 1997 David Huang <khym%bga.com@localhost>
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.27 2021/03/05 07:15:53 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.28 2022/02/16 23:49:26 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -267,7 +267,7 @@
                statoff = offset + datalen;
 
                DBDMA_BUILD_CMD(cmd, DBDMA_CMD_STOP, 0, 0, 0, 0);
-               __asm volatile("eieio");
+               __asm volatile("eieio" ::: "memory");
 
                /* flushcache(sc->sc_rxbuf + offset, datalen + 4); */
 
@@ -282,7 +282,7 @@
 next:
                DBDMA_BUILD_CMD(cmd, DBDMA_CMD_IN_LAST, 0, DBDMA_INT_ALWAYS,
                        DBDMA_WAIT_NEVER, DBDMA_BRANCH_NEVER);
-               __asm volatile("eieio");
+               __asm volatile("eieio" ::: "memory");
                cmd->d_status = 0;
                cmd->d_resid = 0;
                sc->sc_tail = i + 1;
diff -r 6aaaecde891a -r 69d1873f8498 sys/arch/macppc/dev/mediabay.c
--- a/sys/arch/macppc/dev/mediabay.c    Wed Feb 16 23:31:13 2022 +0000
+++ b/sys/arch/macppc/dev/mediabay.c    Wed Feb 16 23:49:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mediabay.c,v 1.27 2022/01/22 11:49:16 thorpej Exp $    */
+/*     $NetBSD: mediabay.c,v 1.28 2022/02/16 23:49:26 riastradh Exp $  */
 
 /*-



Home | Main Index | Thread Index | Old Index