| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: locore.s,v 1.136 2020/09/19 01:32:16 thorpej Exp $ */ | | 1 | /* $NetBSD: locore.s,v 1.137 2021/05/23 01:00:53 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,27 +57,27 @@ | | | @@ -57,27 +57,27 @@ |
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.136 2020/09/19 01:32:16 thorpej Exp $"); | | 70 | __KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.137 2021/05/23 01:00:53 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 | /* don't reorder instructions; paranoia. */ | | 76 | /* don't reorder instructions; paranoia. */ |
77 | .set noreorder | | 77 | .set noreorder |
78 | .text | | 78 | .text |
79 | | | 79 | |
80 | .macro bfalse reg, dst | | 80 | .macro bfalse reg, dst |
81 | beq \reg, \dst | | 81 | beq \reg, \dst |
82 | .endm | | 82 | .endm |
83 | | | 83 | |
| @@ -977,26 +977,31 @@ NESTED(copyoutstr, 4, 16, ra, IM_RA|IM_S | | | @@ -977,26 +977,31 @@ NESTED(copyoutstr, 4, 16, ra, IM_RA|IM_S |
977 | lda sp, 16(sp) /* kill stack frame. */ | | 977 | lda sp, 16(sp) /* kill stack frame. */ |
978 | RET /* v0 left over from copystr */ | | 978 | RET /* v0 left over from copystr */ |
979 | END(copyoutstr) | | 979 | END(copyoutstr) |
980 | | | 980 | |
981 | /* | | 981 | /* |
982 | * kcopy(const void *src, void *dst, size_t len); | | 982 | * kcopy(const void *src, void *dst, size_t len); |
983 | * | | 983 | * |
984 | * Copy len bytes from src to dst, aborting if we encounter a fatal | | 984 | * Copy len bytes from src to dst, aborting if we encounter a fatal |
985 | * page fault. | | 985 | * page fault. |
986 | * | | 986 | * |
987 | * kcopy() _must_ save and restore the old fault handler since it is | | 987 | * kcopy() _must_ save and restore the old fault handler since it is |
988 | * called by uiomove(), which may be in the path of servicing a non-fatal | | 988 | * called by uiomove(), which may be in the path of servicing a non-fatal |
989 | * page fault. | | 989 | * page fault. |
| | | 990 | * |
| | | 991 | * N.B. This implementation is a wrapper around memcpy(), which is |
| | | 992 | * implemented in src/common/lib/libc/arch/alpha/string/bcopy.S. |
| | | 993 | * This is safe ONLY because we know that, as implemented, it is |
| | | 994 | * a LEAF function (and thus does not use any callee-saved registers). |
990 | */ | | 995 | */ |
991 | NESTED(kcopy, 3, 32, ra, IM_RA|IM_S0|IM_S1, 0) | | 996 | NESTED(kcopy, 3, 32, ra, IM_RA|IM_S0|IM_S1, 0) |
992 | LDGP(pv) | | 997 | LDGP(pv) |
993 | lda sp, -32(sp) /* set up stack frame */ | | 998 | lda sp, -32(sp) /* set up stack frame */ |
994 | stq ra, (32-8)(sp) /* save ra */ | | 999 | stq ra, (32-8)(sp) /* save ra */ |
995 | stq s0, (32-16)(sp) /* save s0 */ | | 1000 | stq s0, (32-16)(sp) /* save s0 */ |
996 | stq s1, (32-24)(sp) /* save s1 */ | | 1001 | stq s1, (32-24)(sp) /* save s1 */ |
997 | /* Swap a0, a1, for call to memcpy(). */ | | 1002 | /* Swap a0, a1, for call to memcpy(). */ |
998 | mov a1, v0 | | 1003 | mov a1, v0 |
999 | mov a0, a1 | | 1004 | mov a0, a1 |
1000 | mov v0, a0 | | 1005 | mov v0, a0 |
1001 | /* Note: GET_CURLWP clobbers v0, t0, t8...t11. */ | | 1006 | /* Note: GET_CURLWP clobbers v0, t0, t8...t11. */ |
1002 | GET_CURLWP | | 1007 | GET_CURLWP |
| @@ -1006,30 +1011,27 @@ NESTED(kcopy, 3, 32, ra, IM_RA|IM_S0|IM_ | | | @@ -1006,30 +1011,27 @@ NESTED(kcopy, 3, 32, ra, IM_RA|IM_S0|IM_ |
1006 | stq v0, PCB_ONFAULT(s1) | | 1011 | stq v0, PCB_ONFAULT(s1) |
1007 | CALL(memcpy) /* do the copy. */ | | 1012 | CALL(memcpy) /* do the copy. */ |
1008 | stq s0, PCB_ONFAULT(s1) /* restore the old handler. */ | | 1013 | stq s0, PCB_ONFAULT(s1) /* restore the old handler. */ |
1009 | ldq ra, (32-8)(sp) /* restore ra. */ | | 1014 | ldq ra, (32-8)(sp) /* restore ra. */ |
1010 | ldq s0, (32-16)(sp) /* restore s0. */ | | 1015 | ldq s0, (32-16)(sp) /* restore s0. */ |
1011 | ldq s1, (32-24)(sp) /* restore s1. */ | | 1016 | ldq s1, (32-24)(sp) /* restore s1. */ |
1012 | lda sp, 32(sp) /* kill stack frame. */ | | 1017 | lda sp, 32(sp) /* kill stack frame. */ |
1013 | mov zero, v0 /* return 0. */ | | 1018 | mov zero, v0 /* return 0. */ |
1014 | RET | | 1019 | RET |
1015 | END(kcopy) | | 1020 | END(kcopy) |
1016 | | | 1021 | |
1017 | LEAF(kcopyerr, 0) | | 1022 | LEAF(kcopyerr, 0) |
1018 | LDGP(pv) | | 1023 | LDGP(pv) |
1019 | .set noat | | 1024 | stq s0, PCB_ONFAULT(s1) /* s1 == pcb (from above) */ |
1020 | ldq at_reg, L_PCB(s1) /* restore the old handler. */ | | | |
1021 | stq s0, PCB_ONFAULT(at_reg) | | | |
1022 | .set at | | | |
1023 | ldq ra, (32-8)(sp) /* restore ra. */ | | 1025 | ldq ra, (32-8)(sp) /* restore ra. */ |
1024 | ldq s0, (32-16)(sp) /* restore s0. */ | | 1026 | ldq s0, (32-16)(sp) /* restore s0. */ |
1025 | ldq s1, (32-24)(sp) /* restore s1. */ | | 1027 | ldq s1, (32-24)(sp) /* restore s1. */ |
1026 | lda sp, 32(sp) /* kill stack frame. */ | | 1028 | lda sp, 32(sp) /* kill stack frame. */ |
1027 | RET | | 1029 | RET |
1028 | END(kcopyerr) | | 1030 | END(kcopyerr) |
1029 | | | 1031 | |
1030 | NESTED(copyin, 3, 16, ra, IM_RA|IM_S0, 0) | | 1032 | NESTED(copyin, 3, 16, ra, IM_RA|IM_S0, 0) |
1031 | LDGP(pv) | | 1033 | LDGP(pv) |
1032 | lda sp, -16(sp) /* set up stack frame */ | | 1034 | lda sp, -16(sp) /* set up stack frame */ |
1033 | stq ra, (16-8)(sp) /* save ra */ | | 1035 | stq ra, (16-8)(sp) /* save ra */ |
1034 | stq s0, (16-16)(sp) /* save s0 */ | | 1036 | stq s0, (16-16)(sp) /* save s0 */ |
1035 | ldiq t0, VM_MAX_ADDRESS /* make sure that src addr */ | | 1037 | ldiq t0, VM_MAX_ADDRESS /* make sure that src addr */ |