Module Name:    src
Committed By:   thorpej
Date:           Sun May 23 01:00:53 UTC 2021

Modified Files:
        src/sys/arch/alpha/alpha: locore.s

Log Message:
Fix an error introduced in rev 1.130 where the previous pcb_onfault
handler was not restored properly in the kcopyerr case.  Also add a
comment explaining why it's save for these routines to be wrappers
around memcpy().

Fixes port-alpha/56197.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sys/arch/alpha/alpha/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/alpha/alpha/locore.s
diff -u src/sys/arch/alpha/alpha/locore.s:1.136 src/sys/arch/alpha/alpha/locore.s:1.137
--- src/sys/arch/alpha/alpha/locore.s:1.136	Sat Sep 19 01:32:16 2020
+++ src/sys/arch/alpha/alpha/locore.s	Sun May 23 01:00:53 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.136 2020/09/19 01:32:16 thorpej Exp $ */
+/* $NetBSD: locore.s,v 1.137 2021/05/23 01:00:53 thorpej 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.136 2020/09/19 01:32:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.137 2021/05/23 01:00:53 thorpej Exp $");
 
 #include "assym.h"
 
@@ -987,6 +987,11 @@ NESTED(copyoutstr, 4, 16, ra, IM_RA|IM_S
  * kcopy() _must_ save and restore the old fault handler since it is
  * called by uiomove(), which may be in the path of servicing a non-fatal
  * page fault.
+ *
+ * N.B. This implementation is a wrapper around memcpy(), which is
+ * implemented in src/common/lib/libc/arch/alpha/string/bcopy.S.
+ * This is safe ONLY because we know that, as implemented, it is
+ * a LEAF function (and thus does not use any callee-saved registers).
  */
 NESTED(kcopy, 3, 32, ra, IM_RA|IM_S0|IM_S1, 0)
 	LDGP(pv)
@@ -1016,10 +1021,7 @@ NESTED(kcopy, 3, 32, ra, IM_RA|IM_S0|IM_
 
 LEAF(kcopyerr, 0)
 	LDGP(pv)
-	.set noat
-	ldq	at_reg, L_PCB(s1)		/* restore the old handler.  */
-	stq	s0, PCB_ONFAULT(at_reg)
-	.set at
+	stq	s0, PCB_ONFAULT(s1)		/* s1 == pcb (from above)    */
 	ldq	ra, (32-8)(sp)			/* restore ra.		     */
 	ldq	s0, (32-16)(sp)			/* restore s0.		     */
 	ldq	s1, (32-24)(sp)			/* restore s1.		     */

Reply via email to