Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/powerpc Add a provision for a per-cpu battable. Ea...



details:   https://anonhg.NetBSD.org/src/rev/b732be4e609a
branches:  trunk
changeset: 981001:b732be4e609a
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Feb 24 16:42:38 2021 +0000

description:
Add a provision for a per-cpu battable.  Each CPU starts with the global
one, but this allows CPUs to temporarily switch to an alternate battable
if needed.

diffstat:

 sys/arch/powerpc/include/cpu.h       |   6 +++++-
 sys/arch/powerpc/oea/cpu_subr.c      |  12 ++++++++----
 sys/arch/powerpc/oea/genassym.cf     |   3 ++-
 sys/arch/powerpc/powerpc/trap_subr.S |  26 +++++++++++++++++++-------
 4 files changed, 34 insertions(+), 13 deletions(-)

diffs (151 lines):

diff -r 19c4abce963b -r b732be4e609a sys/arch/powerpc/include/cpu.h
--- a/sys/arch/powerpc/include/cpu.h    Wed Feb 24 09:10:12 2021 +0000
+++ b/sys/arch/powerpc/include/cpu.h    Wed Feb 24 16:42:38 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.116 2021/02/03 10:37:05 rin Exp $    */
+/*     $NetBSD: cpu.h,v 1.117 2021/02/24 16:42:38 thorpej Exp $        */
 
 /*
  * Copyright (C) 1999 Wolfgang Solfrank.
@@ -94,6 +94,10 @@
        struct lwp *ci_onproc;          /* current user LWP / kthread */
        struct pcb *ci_curpcb;
        struct pmap *ci_curpm;
+#if defined(PPC_OEA) || defined(PPC_OEA601) || defined(PPC_OEA64) || \
+    defined(PPC_OEA64_BRIDGE) || defined(MODULAR) || defined(_MODULE)
+       void *ci_battable;              /* BAT table in use by this CPU */
+#endif
        struct lwp *ci_softlwps[SOFTINT_COUNT];
        int ci_cpuid;                   /* from SPR_PIR */
 
diff -r 19c4abce963b -r b732be4e609a sys/arch/powerpc/oea/cpu_subr.c
--- a/sys/arch/powerpc/oea/cpu_subr.c   Wed Feb 24 09:10:12 2021 +0000
+++ b/sys/arch/powerpc/oea/cpu_subr.c   Wed Feb 24 16:42:38 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu_subr.c,v 1.104 2020/07/06 10:31:23 rin Exp $       */
+/*     $NetBSD: cpu_subr.c,v 1.105 2021/02/24 16:42:38 thorpej Exp $   */
 
 /*-
  * Copyright (c) 2001 Matt Thomas.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.104 2020/07/06 10:31:23 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.105 2021/02/24 16:42:38 thorpej Exp $");
 
 #include "sysmon_envsys.h"
 
@@ -235,24 +235,27 @@
        { "",           0,              REVFMT_HEX }
 };
 
+#include <powerpc/oea/bat.h>
+extern struct bat battable[];
+
 #ifdef MULTIPROCESSOR
 struct cpu_info cpu_info[CPU_MAXNUM] = {
     [0] = {
        .ci_curlwp = &lwp0,
+       .ci_battable = battable,
     },
 };
 volatile struct cpu_hatch_data *cpu_hatch_data;
 volatile int cpu_hatch_stack;
 #define HATCH_STACK_SIZE 0x1000
 extern int ticks_per_intr;
-#include <powerpc/oea/bat.h>
 #include <powerpc/pic/picvar.h>
 #include <powerpc/pic/ipivar.h>
-extern struct bat battable[];
 #else
 struct cpu_info cpu_info[1] = {
     [0] = {
        .ci_curlwp = &lwp0,
+       .ci_battable = battable,
     },
 };
 #endif /*MULTIPROCESSOR*/
@@ -1329,6 +1332,7 @@
        ci->ci_curlwp = ci->ci_data.cpu_idlelwp;
        ci->ci_curpcb = lwp_getpcb(ci->ci_curlwp);
        ci->ci_curpm = ci->ci_curpcb->pcb_pm;
+       ci->ci_battable = battable;
 
        cpu_hatch_data = h;
        h->hatch_running = 0;
diff -r 19c4abce963b -r b732be4e609a sys/arch/powerpc/oea/genassym.cf
--- a/sys/arch/powerpc/oea/genassym.cf  Wed Feb 24 09:10:12 2021 +0000
+++ b/sys/arch/powerpc/oea/genassym.cf  Wed Feb 24 16:42:38 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: genassym.cf,v 1.28 2020/07/06 09:34:17 rin Exp $
+#      $NetBSD: genassym.cf,v 1.29 2021/02/24 16:42:38 thorpej Exp $
 
 #
 # Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -66,6 +66,7 @@
 define PM_KERNELSR     offsetof(struct pmap, pm_sr[KERNEL_SR])
 endif
 
+define CI_BATTABLE     offsetof(struct cpu_info, ci_battable)
 define CI_TEMPSAVE     offsetof(struct cpu_info, ci_savearea[CI_SAVETEMP])
 define CI_DDBSAVE      offsetof(struct cpu_info, ci_savearea[CI_SAVEDDB])
 define CI_DISISAVE     offsetof(struct cpu_info, ci_savearea[CI_SAVEMMU])
diff -r 19c4abce963b -r b732be4e609a sys/arch/powerpc/powerpc/trap_subr.S
--- a/sys/arch/powerpc/powerpc/trap_subr.S      Wed Feb 24 09:10:12 2021 +0000
+++ b/sys/arch/powerpc/powerpc/trap_subr.S      Wed Feb 24 16:42:38 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap_subr.S,v 1.84 2020/07/12 21:18:01 rin Exp $       */
+/*     $NetBSD: trap_subr.S,v 1.85 2021/02/24 16:42:38 thorpej Exp $   */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -268,14 +268,20 @@
        rlwinm  %r31,%r31,3+(32-BAT_ADDR_SHIFT),BAT_ADDR_SHIFT-3,28
                                        /* get segment * 8 */
 
+       /* Get address of this CPU's current battable */
+       GET_CPUINFO(%r30)
+       ldreg   %r30,CI_BATTABLE(%r30)
+
+       /* Add offset to the slot we care about. */
+       add     %r31,%r31,%r30
+
        /* get batu */
-       addis   %r31,%r31,_C_LABEL(battable)@ha
-       ldreg   %r30,_C_LABEL(battable)@l(%r31)
+       ldreg   %r30,0(%r31)
        mtcr    %r30
        bf      30,1f                   /* branch if supervisor valid is
                                           false */
        /* get batl */
-       ldreg   %r31,_C_LABEL(battable)+SZREG@l(%r31)
+       ldreg   %r31,SZREG(%r31)
 /* We randomly use the highest two bat registers here */
        mftb    %r28
        mtcr    %r28
@@ -363,15 +369,21 @@
        mfdar   %r31                    /* get fault address */
        rlwinm  %r31,%r31,12,20,28      /* get "segment" battable offset */
 
+       /* Get address of this CPU's current battable */
+       GET_CPUINFO(%r30)
+       ldreg   %r30,CI_BATTABLE(%r30)
+
+       /* Add offset to the slot we care about. */
+       add     %r31,%r31,%r30
+
        /* get batl */
-       addis   %r31,%r31,_C_LABEL(battable)@ha
-       ldreg   %r30,_C_LABEL(battable)+SZREG@l(%r31)
+       ldreg   %r30,SZREG(%r31)
        mtcr    %r30
        bf      25,1f                   /* branch if Valid is false,
                                           presently assumes supervisor only */
 
        /* get batu */
-       ldreg   %r31,_C_LABEL(battable)@l(%r31)
+       ldreg   %r31,0(%r31)
 /* We randomly use the highest two bat registers here */
        mfspr   %r28,SPR_RTCL_R
        andi.   %r28,%r28,128



Home | Main Index | Thread Index | Old Index