Module Name:    src
Committed By:   skrll
Date:           Wed Jan  8 20:59:20 UTC 2020

Modified Files:
        src/sys/arch/aarch64/aarch64: cpuswitch.S
        src/sys/arch/alpha/alpha: locore.s
        src/sys/arch/amd64/amd64: locore.S
        src/sys/arch/arm/arm32: cpuswitch.S
        src/sys/arch/hppa/hppa: locore.S
        src/sys/arch/m68k/m68k: switch_subr.s
        src/sys/arch/mips/mips: locore.S
        src/sys/arch/powerpc/powerpc: locore_subr.S
        src/sys/arch/riscv/riscv: locore.S
        src/sys/arch/sh3/sh3: locore_subr.S
        src/sys/arch/sparc/sparc: locore.s
        src/sys/arch/sparc64/sparc64: locore.s

Log Message:
oldlwp is always non-NULL in cpu_switchto so remove the test for NULL.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/aarch64/aarch64/cpuswitch.S
cvs rdiff -u -r1.123 -r1.124 src/sys/arch/alpha/alpha/locore.s
cvs rdiff -u -r1.196 -r1.197 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.96 -r1.97 src/sys/arch/arm/arm32/cpuswitch.S
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/hppa/hppa/locore.S
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/m68k/m68k/switch_subr.s
cvs rdiff -u -r1.221 -r1.222 src/sys/arch/mips/mips/locore.S
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/powerpc/powerpc/locore_subr.S
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/riscv/riscv/locore.S
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/sh3/sh3/locore_subr.S
cvs rdiff -u -r1.275 -r1.276 src/sys/arch/sparc/sparc/locore.s
cvs rdiff -u -r1.422 -r1.423 src/sys/arch/sparc64/sparc64/locore.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/aarch64/aarch64/cpuswitch.S
diff -u src/sys/arch/aarch64/aarch64/cpuswitch.S:1.14 src/sys/arch/aarch64/aarch64/cpuswitch.S:1.15
--- src/sys/arch/aarch64/aarch64/cpuswitch.S:1.14	Wed Jan  8 17:38:41 2020
+++ src/sys/arch/aarch64/aarch64/cpuswitch.S	Wed Jan  8 20:59:18 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpuswitch.S,v 1.14 2020/01/08 17:38:41 ad Exp $ */
+/* $NetBSD: cpuswitch.S,v 1.15 2020/01/08 20:59:18 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -37,18 +37,16 @@
 #include "opt_ddb.h"
 #include "opt_kasan.h"
 
-RCSID("$NetBSD: cpuswitch.S,v 1.14 2020/01/08 17:38:41 ad Exp $")
+RCSID("$NetBSD: cpuswitch.S,v 1.15 2020/01/08 20:59:18 skrll Exp $")
 
 /*
  * At IPL_SCHED:
- *	x0 = oldlwp (maybe be NULL)
+ *	x0 = oldlwp
  *	x1 = newlwp
  *	x2 = returning
  * returns x0-x2 unchanged
  */
 ENTRY_NP(cpu_switchto)
-	cbz	x0, .Lrestore_lwp
-
 	/*
 	 * Store the callee saved register on the stack.
 	 */
@@ -72,7 +70,6 @@ ENTRY_NP(cpu_switchto)
 
 	/* We are done with the old lwp */
 
-.Lrestore_lwp:
 	DISABLE_INTERRUPT
 	ldr	x6, [x1, #L_PCB]	/* x6 = lwp_getpcb(newlwp) */
 	ldr	x4, [x6, #PCB_TF]	/* get trapframe ptr (aka SP) */

Index: src/sys/arch/alpha/alpha/locore.s
diff -u src/sys/arch/alpha/alpha/locore.s:1.123 src/sys/arch/alpha/alpha/locore.s:1.124
--- src/sys/arch/alpha/alpha/locore.s:1.123	Sat Apr  6 03:06:24 2019
+++ src/sys/arch/alpha/alpha/locore.s	Wed Jan  8 20:59:18 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.123 2019/04/06 03:06:24 thorpej Exp $ */
+/* $NetBSD: locore.s,v 1.124 2020/01/08 20:59:18 skrll Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2019 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include <machine/asm.h>
 
-__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.123 2019/04/06 03:06:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.124 2020/01/08 20:59:18 skrll Exp $");
 
 #include "assym.h"
 
@@ -663,8 +663,6 @@ LEAF(savectx, 1)
 LEAF(cpu_switchto, 0)
 	LDGP(pv)
 
-	beq	a0, 1f
-
 	/*
 	 * do an inline savectx(), to save old context
 	 */
@@ -679,7 +677,6 @@ LEAF(cpu_switchto, 0)
 	stq	s6, PCB_CONTEXT+(6 * 8)(a2)
 	stq	ra, PCB_CONTEXT+(7 * 8)(a2)	/* store ra */
 
-1:
 	mov	a0, s4				/* save old curlwp */
 	mov	a1, s2				/* save new lwp */
 	ldq	a0, L_MD_PCBPADDR(s2)		/* save new pcbpaddr */

Index: src/sys/arch/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.196 src/sys/arch/amd64/amd64/locore.S:1.197
--- src/sys/arch/amd64/amd64/locore.S:1.196	Wed Jan  8 17:38:41 2020
+++ src/sys/arch/amd64/amd64/locore.S	Wed Jan  8 20:59:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.196 2020/01/08 17:38:41 ad Exp $	*/
+/*	$NetBSD: locore.S,v 1.197 2020/01/08 20:59:18 skrll Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1819,8 +1819,8 @@ END(dumpsys)
  * struct lwp *cpu_switchto(struct lwp *oldlwp, struct lwp *newlwp,
  *     bool returning)
  *
- *	1. if (oldlwp != NULL), save its context.
- *	2. then, restore context of newlwp.
+ *	1. save context of oldlwp.
+ *	2. restore context of newlwp.
  *
  * Note that the stack frame layout is known to "struct switchframe" in
  * <machine/frame.h> and to the code in cpu_lwp_fork() which initializes

Index: src/sys/arch/arm/arm32/cpuswitch.S
diff -u src/sys/arch/arm/arm32/cpuswitch.S:1.96 src/sys/arch/arm/arm32/cpuswitch.S:1.97
--- src/sys/arch/arm/arm32/cpuswitch.S:1.96	Wed Jan  8 17:38:41 2020
+++ src/sys/arch/arm/arm32/cpuswitch.S	Wed Jan  8 20:59:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpuswitch.S,v 1.96 2020/01/08 17:38:41 ad Exp $	*/
+/*	$NetBSD: cpuswitch.S,v 1.97 2020/01/08 20:59:18 skrll Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -87,7 +87,7 @@
 #include <arm/asm.h>
 #include <arm/locore.h>
 
-	RCSID("$NetBSD: cpuswitch.S,v 1.96 2020/01/08 17:38:41 ad Exp $")
+	RCSID("$NetBSD: cpuswitch.S,v 1.97 2020/01/08 20:59:18 skrll Exp $")
 
 /* LINTSTUB: include <sys/param.h> */
 
@@ -128,7 +128,7 @@
  * Switch to the specified next LWP
  * Arguments:
  *
- *	r0	'struct lwp *' of the current LWP (or NULL if exiting)
+ *	r0	'struct lwp *' of the current LWP
  *	r1	'struct lwp *' of the LWP to switch to
  *	r2	returning
  */
@@ -151,20 +151,6 @@ ENTRY(cpu_switchto)
 	/* rem: r6 = new lwp */
 	/* rem: interrupts are enabled */
 
-	/*
-	 * If the old lwp on entry to cpu_switchto was zero then the
-	 * process that called it was exiting. This means that we do
-	 * not need to save the current context. Instead we can jump
-	 * straight to restoring the context for the new process.
-	 */
-	teq	r4, #0
-	beq	.Ldo_switch
-
-	/* rem: r4 = old lwp */
-	/* rem: r5 = curcpu() */
-	/* rem: r6 = new lwp */
-	/* rem: interrupts are enabled */
-
 	/* Save old context */
 
 	/* Get the user structure for the old lwp. */
@@ -192,14 +178,8 @@ ENTRY(cpu_switchto)
 	 * them for the new process.
 	 */
 
-	/* rem: r4 = old lwp */
-	/* rem: r5 = curcpu() */
-	/* rem: r6 = new lwp */
-	/* rem: interrupts are enabled */
-
 	/* Restore saved context */
 
-.Ldo_switch:
 	/* rem: r4 = old lwp */
 	/* rem: r5 = curcpu() */
 	/* rem: r6 = new lwp */

Index: src/sys/arch/hppa/hppa/locore.S
diff -u src/sys/arch/hppa/hppa/locore.S:1.3 src/sys/arch/hppa/hppa/locore.S:1.4
--- src/sys/arch/hppa/hppa/locore.S:1.3	Tue Apr 16 20:33:36 2019
+++ src/sys/arch/hppa/hppa/locore.S	Wed Jan  8 20:59:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.3 2019/04/16 20:33:36 skrll Exp $	*/
+/*	$NetBSD: locore.S,v 1.4 2020/01/08 20:59:18 skrll Exp $	*/
 /*	$OpenBSD: locore.S,v 1.158 2008/07/28 19:08:46 miod Exp $	*/
 
 /*
@@ -836,9 +836,6 @@ switch_diag:
 kstack_ok:
 #endif
 
-	/* If old LWP exited, don't bother saving anything. */
-	comb,=,n %r0, %arg0, switch_exited
-
 	/*
 	 * save old LWP context
 	 *
@@ -876,7 +873,6 @@ kstack_ok:
 	 * arg0: old LWP (oldl)
 	 * arg1: new LWP (newl)
 	 */
-switch_exited:
 	ldw	L_MD(%arg1), %t1
 	ldw	L_PCB(%arg1), %t3
 	ldw	PCB_KSP(%t3), %sp		/* restore stack of newl */

Index: src/sys/arch/m68k/m68k/switch_subr.s
diff -u src/sys/arch/m68k/m68k/switch_subr.s:1.33 src/sys/arch/m68k/m68k/switch_subr.s:1.34
--- src/sys/arch/m68k/m68k/switch_subr.s:1.33	Tue Oct  2 18:37:31 2018
+++ src/sys/arch/m68k/m68k/switch_subr.s	Wed Jan  8 20:59:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: switch_subr.s,v 1.33 2018/10/02 18:37:31 mrg Exp $	*/
+/*	$NetBSD: switch_subr.s,v 1.34 2020/01/08 20:59:18 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation.
@@ -89,14 +89,6 @@ GLOBAL(_Idle)				/* For sun2/sun3's cloc
  */
 ENTRY(cpu_switchto)
 	movl	4(%sp),%a1		| fetch `current' lwp
-#ifdef M68010
-	movl	%a1,%d0
-	tstl	%d0
-#else
-	tstl	%a1			| Old LWP exited?
-#endif
-	jeq	.Lcpu_switch_noctxsave	| Yup. Don't bother saving context
-
 	/*
 	 * Save state of previous process in its pcb.
 	 */
@@ -140,7 +132,6 @@ ENTRY(cpu_switchto)
 #endif	/* FPCOPROC */
 #endif	/* !_M68K_CUSTOM_FPU_CTX */
 
-.Lcpu_switch_noctxsave:
 	movl	8(%sp),%a0		| get newlwp
 	movl	%a0,_C_LABEL(curlwp)
 	movl	L_PCB(%a0),%a1		| get its pcb

Index: src/sys/arch/mips/mips/locore.S
diff -u src/sys/arch/mips/mips/locore.S:1.221 src/sys/arch/mips/mips/locore.S:1.222
--- src/sys/arch/mips/mips/locore.S:1.221	Wed Jan  8 17:38:42 2020
+++ src/sys/arch/mips/mips/locore.S	Wed Jan  8 20:59:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.221 2020/01/08 17:38:42 ad Exp $	*/
+/*	$NetBSD: locore.S,v 1.222 2020/01/08 20:59:19 skrll Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -63,7 +63,7 @@
 #include <mips/trap.h>
 #include <mips/locore.h>
 
-RCSID("$NetBSD: locore.S,v 1.221 2020/01/08 17:38:42 ad Exp $")
+RCSID("$NetBSD: locore.S,v 1.222 2020/01/08 20:59:19 skrll Exp $")
 
 #include "assym.h"
 
@@ -244,10 +244,8 @@ NESTED(cpu_switchto, CALLFRAME_SIZ, ra)
 #endif
 #endif /* PARANOIA */
 	/*
-	 * Save old context, unless the LWP is exiting.
+	 * Save old context
 	 */
-	beq	a0, zero, 1f
-	 nop
 	PTR_L	a2, L_PCB(a0)			# a2 = pcb of old lwp
 	mfc0	t0, MIPS_COP_0_STATUS
 	REG_PROLOGUE
@@ -268,7 +266,7 @@ NESTED(cpu_switchto, CALLFRAME_SIZ, ra)
 	REG_S	gp, PCB_CONTEXT+SF_REG_GP(a2)
 #endif
 	REG_EPILOGUE
-1:
+
 #if defined(PARANOID_SPL)
 	/*
 	 * Verify interrupt configuration matches IPL_SCHED

Index: src/sys/arch/powerpc/powerpc/locore_subr.S
diff -u src/sys/arch/powerpc/powerpc/locore_subr.S:1.58 src/sys/arch/powerpc/powerpc/locore_subr.S:1.59
--- src/sys/arch/powerpc/powerpc/locore_subr.S:1.58	Wed Jan  8 17:38:42 2020
+++ src/sys/arch/powerpc/powerpc/locore_subr.S	Wed Jan  8 20:59:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore_subr.S,v 1.58 2020/01/08 17:38:42 ad Exp $	*/
+/*	$NetBSD: locore_subr.S,v 1.59 2020/01/08 20:59:19 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -156,7 +156,7 @@ GLOBAL(powersave)
  * struct lwp *
  * cpu_switchto(struct lwp *current, struct lwp *new)
  * switch to the indicated new LWP.
- * 	r3 - current LWP (maybe NULL, if so don't save state)
+ * 	r3 - current LWP
  * 	r4 - LWP to switch to
  *	scheduler lock held
  *	SPL is IPL_SCHED.
@@ -179,12 +179,6 @@ ENTRY(cpu_switchto)
 	tweqi	%r0,0	
 #endif
 
-	/* 
-	 * If the oldlwp was null, don't bother saving the switch state.
-	 */
-	cmpwi	%r30,0
-	beq	switchto_restore
-
 #if defined (PPC_OEA) || defined (PPC_OEA64_BRIDGE)
 	mfsr	%r10,USER_SR		/* save USER_SR for copyin/copyout */
 #else
@@ -202,7 +196,6 @@ ENTRY(cpu_switchto)
 	streg	%r9,PCB_USPRG0(%r4)	/* save in PCB, not switchframe. */
 #endif
 
-switchto_restore:
 /* Lock the scheduler. */
 #if defined(PPC_IBM4XX) || defined(PPC_BOOKE)
 	wrteei	0			/* disable interrupts while

Index: src/sys/arch/riscv/riscv/locore.S
diff -u src/sys/arch/riscv/riscv/locore.S:1.10 src/sys/arch/riscv/riscv/locore.S:1.11
--- src/sys/arch/riscv/riscv/locore.S:1.10	Wed Jan  8 17:38:42 2020
+++ src/sys/arch/riscv/riscv/locore.S	Wed Jan  8 20:59:19 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.10 2020/01/08 17:38:42 ad Exp $ */
+/* $NetBSD: locore.S,v 1.11 2020/01/08 20:59:19 skrll Exp $ */
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -167,8 +167,6 @@ END(start)
 ENTRY_NP(cpu_switchto)
 	addi	sp, sp, -TF_LEN		// allocate trapframe
 
-	beqz	a0, .Lswitchto_newlwp	// can skip saving oldl state?
-
 	REG_S	ra, TF_RA(sp)		// save return address
 	REG_S	s0, TF_S0(sp)		// save callee saved address
 	REG_S	s1, TF_S1(sp)		// save callee saved address
@@ -186,7 +184,7 @@ ENTRY_NP(cpu_switchto)
 	REG_S	t4, TF_SR(sp)		// save it
 	
 	REG_S	sp, L_MD_KTF(a0)	// record trapframe pointer
-.Lswitchto_newlwp:
+
 	csrrci	t0, sstatus, SR_EI	// # disable interrupts
 
 	move	tp, a1			// # put the new lwp in thread pointer

Index: src/sys/arch/sh3/sh3/locore_subr.S
diff -u src/sys/arch/sh3/sh3/locore_subr.S:1.57 src/sys/arch/sh3/sh3/locore_subr.S:1.58
--- src/sys/arch/sh3/sh3/locore_subr.S:1.57	Sat Apr  6 03:06:27 2019
+++ src/sys/arch/sh3/sh3/locore_subr.S	Wed Jan  8 20:59:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore_subr.S,v 1.57 2019/04/06 03:06:27 thorpej Exp $	*/
+/*	$NetBSD: locore_subr.S,v 1.58 2020/01/08 20:59:19 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
 #include <sh3/mmu_sh3.h>
 #include <sh3/mmu_sh4.h>
 
-__KERNEL_RCSID(0, "$NetBSD: locore_subr.S,v 1.57 2019/04/06 03:06:27 thorpej Exp $")
+__KERNEL_RCSID(0, "$NetBSD: locore_subr.S,v 1.58 2020/01/08 20:59:19 skrll Exp $")
 
 
 /*
@@ -86,13 +86,10 @@ __KERNEL_RCSID(0, "$NetBSD: locore_subr.
  *	Return olwp (in the nlwp context).
  */
 ENTRY(cpu_switchto)
-	tst	r4, r4			! olwp can be NULL
-	bt	.L_saved
-
 	!! save old lwp's context to switchframe
 	mov.l	@(L_MD_PCB, r4), r1	! olwp->l_md.md_pcb
 	SAVEPCB(r1)
-.L_saved:
+
 	!! free to use callee-save registers now
 
 	mov.l	.L_curlwp, r2

Index: src/sys/arch/sparc/sparc/locore.s
diff -u src/sys/arch/sparc/sparc/locore.s:1.275 src/sys/arch/sparc/sparc/locore.s:1.276
--- src/sys/arch/sparc/sparc/locore.s:1.275	Mon Dec 30 22:13:47 2019
+++ src/sys/arch/sparc/sparc/locore.s	Wed Jan  8 20:59:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.275 2019/12/30 22:13:47 ad Exp $	*/
+/*	$NetBSD: locore.s,v 1.276 2020/01/08 20:59:19 skrll Exp $	*/
 
 /*
  * Copyright (c) 1996 Paul Kranenburg
@@ -4863,9 +4863,7 @@ ENTRY(cpu_switchto)
 
 	sethi	%hi(cpcb), %l6
 
-	tst	%i0				! if (oldlwp == NULL)
-	bz	Lnosaveoldlwp
-	 rd	%psr, %l1			! psr = %psr;
+	rd	%psr, %l1			! psr = %psr;
 
 	ld	[%l6 + %lo(cpcb)], %o0
 
@@ -4881,7 +4879,6 @@ ENTRY(cpu_switchto)
 Lwb1:	SAVE; SAVE; SAVE; SAVE; SAVE; SAVE;	/* 6 of each: */
 	restore; restore; restore; restore; restore; restore
 
-Lnosaveoldlwp:
 	andn	%l1, PSR_PIL, %l1		! oldpsr &= ~PSR_PIL;
 
 	/*

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.422 src/sys/arch/sparc64/sparc64/locore.s:1.423
--- src/sys/arch/sparc64/sparc64/locore.s:1.422	Wed Jan  8 17:38:42 2020
+++ src/sys/arch/sparc64/sparc64/locore.s	Wed Jan  8 20:59:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.422 2020/01/08 17:38:42 ad Exp $	*/
+/*	$NetBSD: locore.s,v 1.423 2020/01/08 20:59:20 skrll Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -6536,8 +6536,7 @@ ENTRY(cpu_switchto)
 	wrpr	%g0, PSTATE_KERN, %pstate	! make sure we're on normal globals
 						! with traps turned off
 
-	brz,pn	%i0, 1f
-	 sethi	%hi(CPCB), %l6
+	sethi	%hi(CPCB), %l6
 
 	rdpr	%pstate, %o1			! oldpstate = %pstate;
 	LDPTR	[%i0 + L_PCB], %l5
@@ -6549,7 +6548,6 @@ ENTRY(cpu_switchto)
 	rdpr	%cwp, %o2		! Useless
 	stb	%o2, [%l5 + PCB_CWP]
 
-1:
 	sethi	%hi(CURLWP), %l7
 
 	LDPTR   [%i1 + L_PCB], %l1	! newpcb = l->l_pcb;

Reply via email to