Thu Sep 3 04:18:30 2020 UTC ()
The only remaining consumer of curpcb was the PROM mapping code, for if
PROM console routines are being used (only on KN8AE).  We have access to
the sam information via curlwp, so use that, and eliminate the need to set
cpu_info::ci_curpcb when context switching, which saves an extra all into
PALcode.


(thorpej)
diff -r1.22 -r1.23 src/sys/arch/alpha/alpha/genassym.cf
diff -r1.126 -r1.127 src/sys/arch/alpha/alpha/locore.s
diff -r1.54 -r1.55 src/sys/arch/alpha/alpha/prom.c
diff -r1.39 -r1.40 src/sys/arch/alpha/include/asm.h

cvs diff -r1.22 -r1.23 src/sys/arch/alpha/alpha/genassym.cf (expand / switch to unified diff)

--- src/sys/arch/alpha/alpha/genassym.cf 2020/02/20 08:27:38 1.22
+++ src/sys/arch/alpha/alpha/genassym.cf 2020/09/03 04:18:30 1.23
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: genassym.cf,v 1.22 2020/02/20 08:27:38 skrll Exp $ 1# $NetBSD: genassym.cf,v 1.23 2020/09/03 04:18:30 thorpej Exp $
2 2
3# 3#
4# Copyright (c) 1982, 1990, 1993 4# Copyright (c) 1982, 1990, 1993
5# The Regents of the University of California. All rights reserved. 5# The Regents of the University of California. All rights reserved.
6# 6#
7# Redistribution and use in source and binary forms, with or without 7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions 8# modification, are permitted provided that the following conditions
9# are met: 9# are met:
10# 1. Redistributions of source code must retain the above copyright 10# 1. Redistributions of source code must retain the above copyright
11# notice, this list of conditions and the following disclaimer. 11# notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright 12# 2. Redistributions in binary form must reproduce the above copyright
13# notice, this list of conditions and the following disclaimer in the 13# notice, this list of conditions and the following disclaimer in the
14# documentation and/or other materials provided with the distribution. 14# documentation and/or other materials provided with the distribution.
@@ -177,16 +177,15 @@ define ALPHA_KENTRY_MM ALPHA_KENTRY_MM @@ -177,16 +177,15 @@ define ALPHA_KENTRY_MM ALPHA_KENTRY_MM
177define ALPHA_KENTRY_IF ALPHA_KENTRY_IF 177define ALPHA_KENTRY_IF ALPHA_KENTRY_IF
178define ALPHA_KENTRY_UNA ALPHA_KENTRY_UNA 178define ALPHA_KENTRY_UNA ALPHA_KENTRY_UNA
179 179
180# errno values 180# errno values
181define ENAMETOOLONG ENAMETOOLONG 181define ENAMETOOLONG ENAMETOOLONG
182define EFAULT EFAULT 182define EFAULT EFAULT
183 183
184# Syscalls called from sigreturn. 184# Syscalls called from sigreturn.
185define SYS_compat_16___sigreturn14 SYS_compat_16___sigreturn14 185define SYS_compat_16___sigreturn14 SYS_compat_16___sigreturn14
186define SYS_exit SYS_exit 186define SYS_exit SYS_exit
187 187
188# CPU info 188# CPU info
189define CPU_INFO_CURLWP offsetof(struct cpu_info, ci_curlwp) 189define CPU_INFO_CURLWP offsetof(struct cpu_info, ci_curlwp)
190define CPU_INFO_CURPCB offsetof(struct cpu_info, ci_curpcb) 
191define CPU_INFO_IDLE_LWP offsetof(struct cpu_info, ci_data.cpu_idlelwp) 190define CPU_INFO_IDLE_LWP offsetof(struct cpu_info, ci_data.cpu_idlelwp)
192define CPU_INFO_SIZEOF sizeof(struct cpu_info) 191define CPU_INFO_SIZEOF sizeof(struct cpu_info)

cvs diff -r1.126 -r1.127 src/sys/arch/alpha/alpha/locore.s (expand / switch to unified diff)

--- src/sys/arch/alpha/alpha/locore.s 2020/09/03 02:09:09 1.126
+++ src/sys/arch/alpha/alpha/locore.s 2020/09/03 04:18:30 1.127
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: locore.s,v 1.126 2020/09/03 02:09:09 thorpej Exp $ */ 1/* $NetBSD: locore.s,v 1.127 2020/09/03 04:18:30 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999, 2000, 2019 The NetBSD Foundation, Inc. 4 * Copyright (c) 1999, 2000, 2019 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -57,41 +57,37 @@ @@ -57,41 +57,37 @@
57 * rights to redistribute these changes. 57 * rights to redistribute these changes.
58 */ 58 */
59 59
60.stabs __FILE__,100,0,0,kernel_text 60.stabs __FILE__,100,0,0,kernel_text
61 61
62#include "opt_ddb.h" 62#include "opt_ddb.h"
63#include "opt_kgdb.h" 63#include "opt_kgdb.h"
64#include "opt_multiprocessor.h" 64#include "opt_multiprocessor.h"
65#include "opt_lockdebug.h" 65#include "opt_lockdebug.h"
66#include "opt_compat_netbsd.h" 66#include "opt_compat_netbsd.h"
67 67
68#include <machine/asm.h> 68#include <machine/asm.h>
69 69
70__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.126 2020/09/03 02:09:09 thorpej Exp $"); 70__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.127 2020/09/03 04:18:30 thorpej Exp $");
71 71
72#include "assym.h" 72#include "assym.h"
73 73
74.stabs __FILE__,132,0,0,kernel_text 74.stabs __FILE__,132,0,0,kernel_text
75 75
76/* 76/*
77 * Perform actions necessary to switch to a new context. The 77 * Perform actions necessary to switch to a new context. The
78 * hwpcb should be in a0. Clobbers v0, t0, t8..t11, a0. 78 * hwpcb should be in a0. Clobbers v0, t0, t8..t11, a0.
79 */ 79 */
80#define SWITCH_CONTEXT \ 80#define SWITCH_CONTEXT \
81 /* Make a note of the context we're running on. */ \ 
82 GET_CURPCB ; \ 
83 stq a0, 0(v0) ; \ 
84 \ 
85 /* Swap in the new context. */ \ 81 /* Swap in the new context. */ \
86 call_pal PAL_OSF1_swpctx 82 call_pal PAL_OSF1_swpctx
87 83
88 84
89 /* don't reorder instructions; paranoia. */ 85 /* don't reorder instructions; paranoia. */
90 .set noreorder 86 .set noreorder
91 .text 87 .text
92 88
93 .macro bfalse reg, dst 89 .macro bfalse reg, dst
94 beq \reg, \dst 90 beq \reg, \dst
95 .endm 91 .endm
96 92
97 .macro btrue reg, dst 93 .macro btrue reg, dst

cvs diff -r1.54 -r1.55 src/sys/arch/alpha/alpha/prom.c (expand / switch to unified diff)

--- src/sys/arch/alpha/alpha/prom.c 2020/09/03 02:09:09 1.54
+++ src/sys/arch/alpha/alpha/prom.c 2020/09/03 04:18:30 1.55
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: prom.c,v 1.54 2020/09/03 02:09:09 thorpej Exp $ */ 1/* $NetBSD: prom.c,v 1.55 2020/09/03 04:18:30 thorpej Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1992, 1994, 1995, 1996 Carnegie Mellon University 4 * Copyright (c) 1992, 1994, 1995, 1996 Carnegie Mellon University
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Permission to use, copy, modify and distribute this software and its 7 * Permission to use, copy, modify and distribute this software and its
8 * documentation is hereby granted, provided that both the copyright 8 * documentation is hereby granted, provided that both the copyright
9 * notice and this permission notice appear in all copies of the 9 * notice and this permission notice appear in all copies of the
10 * software, derivative works or modified versions, and any portions 10 * software, derivative works or modified versions, and any portions
11 * thereof, and that both notices appear in supporting documentation. 11 * thereof, and that both notices appear in supporting documentation.
12 * 12 *
13 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 13 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
14 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 14 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * Carnegie Mellon requests users of this software to return to 17 * Carnegie Mellon requests users of this software to return to
18 * 18 *
19 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 19 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
20 * School of Computer Science 20 * School of Computer Science
21 * Carnegie Mellon University 21 * Carnegie Mellon University
22 * Pittsburgh PA 15213-3890 22 * Pittsburgh PA 15213-3890
23 * 23 *
24 * any improvements or extensions that they make and grant Carnegie Mellon 24 * any improvements or extensions that they make and grant Carnegie Mellon
25 * the rights to redistribute these changes. 25 * the rights to redistribute these changes.
26 */ 26 */
27 27
28#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 28#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
29 29
30__KERNEL_RCSID(0, "$NetBSD: prom.c,v 1.54 2020/09/03 02:09:09 thorpej Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: prom.c,v 1.55 2020/09/03 04:18:30 thorpej Exp $");
31 31
32#include "opt_multiprocessor.h" 32#include "opt_multiprocessor.h"
33 33
34#include <sys/param.h> 34#include <sys/param.h>
35#include <sys/systm.h> 35#include <sys/systm.h>
36#include <sys/proc.h> 36#include <sys/proc.h>
37#include <sys/cpu.h> 37#include <sys/cpu.h>
38 38
39#include <uvm/uvm_extern.h> 39#include <uvm/uvm_extern.h>
40 40
41#include <machine/rpb.h> 41#include <machine/rpb.h>
42#include <machine/alpha.h> 42#include <machine/alpha.h>
43#define ENABLEPROM 43#define ENABLEPROM
@@ -67,27 +67,28 @@ static kmutex_t prom_lock; @@ -67,27 +67,28 @@ static kmutex_t prom_lock;
67 67
68#ifdef _PROM_MAY_USE_PROM_CONSOLE 68#ifdef _PROM_MAY_USE_PROM_CONSOLE
69 69
70pt_entry_t prom_pte, saved_pte[1]; /* XXX */ 70pt_entry_t prom_pte, saved_pte[1]; /* XXX */
71 71
72static pt_entry_t * 72static pt_entry_t *
73prom_lev1map(void) 73prom_lev1map(void)
74{ 74{
75 struct alpha_pcb *apcb; 75 struct alpha_pcb *apcb;
76 76
77 /* 77 /*
78 * Find the level 1 map that we're currently running on. 78 * Find the level 1 map that we're currently running on.
79 */ 79 */
80 apcb = (struct alpha_pcb *)ALPHA_PHYS_TO_K0SEG(curpcb); 80 apcb = (struct alpha_pcb *))
 81 ALPHA_PHYS_TO_K0SEG((paddr_t)curlwp->l_md.md_pcbpaddr);
81 82
82 return ((pt_entry_t *)ALPHA_PHYS_TO_K0SEG(apcb->apcb_ptbr << PGSHIFT)); 83 return ((pt_entry_t *)ALPHA_PHYS_TO_K0SEG(apcb->apcb_ptbr << PGSHIFT));
83} 84}
84#endif /* _PROM_MAY_USE_PROM_CONSOLE */ 85#endif /* _PROM_MAY_USE_PROM_CONSOLE */
85 86
86bool 87bool
87prom_uses_prom_console(void) 88prom_uses_prom_console(void)
88{ 89{
89#ifdef _PROM_MAY_USE_PROM_CONSOLE 90#ifdef _PROM_MAY_USE_PROM_CONSOLE
90 return (cputype == ST_DEC_21000); 91 return (cputype == ST_DEC_21000);
91#else 92#else
92 return false; 93 return false;
93#endif 94#endif
@@ -176,50 +177,50 @@ static void prom_cache_sync(void); @@ -176,50 +177,50 @@ static void prom_cache_sync(void);
176 177
177void 178void
178prom_enter(void) 179prom_enter(void)
179{ 180{
180 181
181 mutex_enter(&prom_lock); 182 mutex_enter(&prom_lock);
182 183
183#ifdef _PROM_MAY_USE_PROM_CONSOLE 184#ifdef _PROM_MAY_USE_PROM_CONSOLE
184 /* 185 /*
185 * If we have not yet switched out of the PROM's context 186 * If we have not yet switched out of the PROM's context
186 * (i.e. the first one after alpha_init()), then the PROM 187 * (i.e. the first one after alpha_init()), then the PROM
187 * is still mapped, regardless of the `prom_mapped' setting. 188 * is still mapped, regardless of the `prom_mapped' setting.
188 */ 189 */
189 if (prom_mapped == 0 && curpcb != 0) { 190 if (! prom_mapped) {
190 if (!prom_uses_prom_console()) 191 if (!prom_uses_prom_console())
191 panic("prom_enter"); 192 panic("prom_enter");
192 { 193 {
193 pt_entry_t *lev1map; 194 pt_entry_t *lev1map;
194 195
195 lev1map = prom_lev1map(); /* XXX */ 196 lev1map = prom_lev1map(); /* XXX */
196 saved_pte[0] = lev1map[0]; /* XXX */ 197 saved_pte[0] = lev1map[0]; /* XXX */
197 lev1map[0] = prom_pte; /* XXX */ 198 lev1map[0] = prom_pte; /* XXX */
198 } 199 }
199 prom_cache_sync(); /* XXX */ 200 prom_cache_sync(); /* XXX */
200 } 201 }
201#endif 202#endif
202} 203}
203 204
204void 205void
205prom_leave(void) 206prom_leave(void)
206{ 207{
207 208
208#ifdef _PROM_MAY_USE_PROM_CONSOLE 209#ifdef _PROM_MAY_USE_PROM_CONSOLE
209 /* 210 /*
210 * See comment above. 211 * See comment above.
211 */ 212 */
212 if (prom_mapped == 0 && curpcb != 0) { 213 if (! prom_mapped) {
213 if (!prom_uses_prom_console()) 214 if (!prom_uses_prom_console())
214 panic("prom_leave"); 215 panic("prom_leave");
215 { 216 {
216 pt_entry_t *lev1map; 217 pt_entry_t *lev1map;
217 218
218 lev1map = prom_lev1map(); /* XXX */ 219 lev1map = prom_lev1map(); /* XXX */
219 lev1map[0] = saved_pte[0]; /* XXX */ 220 lev1map[0] = saved_pte[0]; /* XXX */
220 } 221 }
221 prom_cache_sync(); /* XXX */ 222 prom_cache_sync(); /* XXX */
222 } 223 }
223#endif 224#endif
224 mutex_exit(&prom_lock); 225 mutex_exit(&prom_lock);
225} 226}

cvs diff -r1.39 -r1.40 src/sys/arch/alpha/include/asm.h (expand / switch to unified diff)

--- src/sys/arch/alpha/include/asm.h 2020/08/29 22:50:27 1.39
+++ src/sys/arch/alpha/include/asm.h 2020/09/03 04:18:30 1.40
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: asm.h,v 1.39 2020/08/29 22:50:27 thorpej Exp $ */ 1/* $NetBSD: asm.h,v 1.40 2020/09/03 04:18:30 thorpej Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1991,1990,1989,1994,1995,1996 Carnegie Mellon University 4 * Copyright (c) 1991,1990,1989,1994,1995,1996 Carnegie Mellon University
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Permission to use, copy, modify and distribute this software and its 7 * Permission to use, copy, modify and distribute this software and its
8 * documentation is hereby granted, provided that both the copyright 8 * documentation is hereby granted, provided that both the copyright
9 * notice and this permission notice appear in all copies of the 9 * notice and this permission notice appear in all copies of the
10 * software, derivative works or modified versions, and any portions 10 * software, derivative works or modified versions, and any portions
11 * thereof, and that both notices appear in supporting documentation. 11 * thereof, and that both notices appear in supporting documentation.
12 * 12 *
13 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 13 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
14 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 14 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
@@ -665,33 +665,27 @@ label: ASCIZ msg; \ @@ -665,33 +665,27 @@ label: ASCIZ msg; \
665 * 665 *
666 * All return values are in v0. 666 * All return values are in v0.
667 */ 667 */
668#define GET_CPUINFO call_pal PAL_OSF1_rdval 668#define GET_CPUINFO call_pal PAL_OSF1_rdval
669 669
670#define GET_CURLWP \ 670#define GET_CURLWP \
671 call_pal PAL_OSF1_rdval ; \ 671 call_pal PAL_OSF1_rdval ; \
672 addq v0, CPU_INFO_CURLWP, v0 672 addq v0, CPU_INFO_CURLWP, v0
673 673
674#define GET_FPCURLWP \ 674#define GET_FPCURLWP \
675 call_pal PAL_OSF1_rdval ; \ 675 call_pal PAL_OSF1_rdval ; \
676 addq v0, CPU_INFO_FPCURLWP, v0 676 addq v0, CPU_INFO_FPCURLWP, v0
677 677
678#define GET_CURPCB \ 
679 call_pal PAL_OSF1_rdval ; \ 
680 addq v0, CPU_INFO_CURPCB, v0 
681 
682#else /* if not MULTIPROCESSOR... */ 678#else /* if not MULTIPROCESSOR... */
683 679
684IMPORT(cpu_info_primary, CPU_INFO_SIZEOF) 680IMPORT(cpu_info_primary, CPU_INFO_SIZEOF)
685 681
686#define GET_CPUINFO lda v0, cpu_info_primary 682#define GET_CPUINFO lda v0, cpu_info_primary
687 683
688#define GET_CURLWP lda v0, cpu_info_primary + CPU_INFO_CURLWP 684#define GET_CURLWP lda v0, cpu_info_primary + CPU_INFO_CURLWP
689 685
690#define GET_FPCURLWP lda v0, cpu_info_primary + CPU_INFO_FPCURLWP 686#define GET_FPCURLWP lda v0, cpu_info_primary + CPU_INFO_FPCURLWP
691 
692#define GET_CURPCB lda v0, cpu_info_primary + CPU_INFO_CURPCB 
693#endif /* MULTIPROCESSOR */ 687#endif /* MULTIPROCESSOR */
694#else 688#else
695#define RCSID(_s) __SECTIONSTRING(.ident, _s) 689#define RCSID(_s) __SECTIONSTRING(.ident, _s)
696 690
697#endif /* _KERNEL */ 691#endif /* _KERNEL */