Module Name: src Committed By: thorpej Date: Wed Feb 24 16:42:38 UTC 2021
Modified Files: src/sys/arch/powerpc/include: cpu.h src/sys/arch/powerpc/oea: cpu_subr.c genassym.cf src/sys/arch/powerpc/powerpc: trap_subr.S Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/sys/arch/powerpc/include/cpu.h cvs rdiff -u -r1.104 -r1.105 src/sys/arch/powerpc/oea/cpu_subr.c cvs rdiff -u -r1.28 -r1.29 src/sys/arch/powerpc/oea/genassym.cf cvs rdiff -u -r1.84 -r1.85 src/sys/arch/powerpc/powerpc/trap_subr.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/powerpc/include/cpu.h diff -u src/sys/arch/powerpc/include/cpu.h:1.116 src/sys/arch/powerpc/include/cpu.h:1.117 --- src/sys/arch/powerpc/include/cpu.h:1.116 Wed Feb 3 10:37:05 2021 +++ src/sys/arch/powerpc/include/cpu.h Wed Feb 24 16:42:38 2021 @@ -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 cpu_info { 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 */ Index: src/sys/arch/powerpc/oea/cpu_subr.c diff -u src/sys/arch/powerpc/oea/cpu_subr.c:1.104 src/sys/arch/powerpc/oea/cpu_subr.c:1.105 --- src/sys/arch/powerpc/oea/cpu_subr.c:1.104 Mon Jul 6 10:31:23 2020 +++ src/sys/arch/powerpc/oea/cpu_subr.c Wed Feb 24 16:42:38 2021 @@ -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 @@ static const struct cputab models[] = { { "", 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 @@ cpu_spinup(device_t self, struct cpu_inf 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; Index: src/sys/arch/powerpc/oea/genassym.cf diff -u src/sys/arch/powerpc/oea/genassym.cf:1.28 src/sys/arch/powerpc/oea/genassym.cf:1.29 --- src/sys/arch/powerpc/oea/genassym.cf:1.28 Mon Jul 6 09:34:17 2020 +++ src/sys/arch/powerpc/oea/genassym.cf Wed Feb 24 16:42:38 2021 @@ -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_USRSR offsetof(struct pmap, pm 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]) Index: src/sys/arch/powerpc/powerpc/trap_subr.S diff -u src/sys/arch/powerpc/powerpc/trap_subr.S:1.84 src/sys/arch/powerpc/powerpc/trap_subr.S:1.85 --- src/sys/arch/powerpc/powerpc/trap_subr.S:1.84 Sun Jul 12 21:18:01 2020 +++ src/sys/arch/powerpc/powerpc/trap_subr.S Wed Feb 24 16:42:38 2021 @@ -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 @@ _C_LABEL(dsitrap): 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 @@ _C_LABEL(dsi601trap): 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