Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-4]: src/sys/arch/sparc/sparc pull up rev 1.126 from trunk (requ...



details:   https://anonhg.NetBSD.org/src/rev/2b9a436409ff
branches:  netbsd-1-4
changeset: 469669:2b9a436409ff
user:      cgd <cgd%NetBSD.org@localhost>
date:      Fri Nov 05 07:52:15 1999 +0000

description:
pull up rev 1.126 from trunk (requested by chs):
  Fix several panics in copy{in,out,}str().

diffstat:

 sys/arch/sparc/sparc/locore.s |  73 ++++++++++++++----------------------------
 1 files changed, 24 insertions(+), 49 deletions(-)

diffs (141 lines):

diff -r f5b48aedce25 -r 2b9a436409ff sys/arch/sparc/sparc/locore.s
--- a/sys/arch/sparc/sparc/locore.s     Fri Nov 05 07:50:23 1999 +0000
+++ b/sys/arch/sparc/sparc/locore.s     Fri Nov 05 07:52:15 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.s,v 1.114.2.1 1999/04/30 15:33:55 perry Exp $   */
+/*     $NetBSD: locore.s,v 1.114.2.2 1999/11/05 07:52:15 cgd Exp $     */
 
 /*
  * Copyright (c) 1996 Paul Kranenburg
@@ -4324,26 +4324,19 @@
  */
 ENTRY(copyinstr)
        ! %o0 = fromaddr, %o1 = toaddr, %o2 = maxlen, %o3 = &lencopied
-#ifdef DIAGNOSTIC
-       tst     %o2                     ! kernel should never give maxlen <= 0
-       ble     1f
-        EMPTY
-#endif
+       mov     %o1, %o5                ! save = toaddr;
+       tst     %o2                     ! maxlen == 0?
+       beq,a   Lcstoolong              ! yes, return ENAMETOOLONG
+        sethi  %hi(cpcb), %o4
+
        set     KERNBASE, %o4
        cmp     %o0, %o4                ! fromaddr < KERNBASE?
-       blu,a   Lcsdocopy               ! yes, go do it
-       sethi   %hi(cpcb), %o4          ! (first instr of copy)
+       blu     Lcsdocopy               ! yes, go do it
+        sethi  %hi(cpcb), %o4          ! (first instr of copy)
 
        b       Lcsdone                 ! no, return EFAULT
         mov    EFAULT, %o0
 
-1:
-       sethi   %hi(2f), %o0
-       call    _C_LABEL(panic)
-        or     %lo(2f), %o0, %o0
-2:     .asciz  "copyinstr"
-       _ALIGN
-
 /*
  * copyoutstr(fromaddr, toaddr, maxlength, &lencopied)
  *
@@ -4352,33 +4345,25 @@
  */
 ENTRY(copyoutstr)
        ! %o0 = fromaddr, %o1 = toaddr, %o2 = maxlen, %o3 = &lencopied
-#ifdef DIAGNOSTIC
-       tst     %o2
-       ble     1f
-        EMPTY
-#endif
+       mov     %o1, %o5                ! save = toaddr;
+       tst     %o2                     ! maxlen == 0?
+       beq,a   Lcstoolong              ! yes, return ENAMETOOLONG
+        sethi  %hi(cpcb), %o4
+
        set     KERNBASE, %o4
        cmp     %o1, %o4                ! toaddr < KERNBASE?
-       blu,a   Lcsdocopy               ! yes, go do it
+       blu     Lcsdocopy               ! yes, go do it
         sethi  %hi(cpcb), %o4          ! (first instr of copy)
 
        b       Lcsdone                 ! no, return EFAULT
         mov    EFAULT, %o0
 
-1:
-       sethi   %hi(2f), %o0
-       call    _C_LABEL(panic)
-        or     %lo(2f), %o0, %o0
-2:     .asciz  "copyoutstr"
-       _ALIGN
-
 Lcsdocopy:
 !      sethi   %hi(cpcb), %o4          ! (done earlier)
        ld      [%o4 + %lo(cpcb)], %o4  ! catch faults
-       set     Lcsfault, %o5
-       st      %o5, [%o4 + PCB_ONFAULT]
-
-       mov     %o1, %o5                !       save = toaddr;
+       set     Lcsfault, %g1
+       st      %g1, [%o4 + PCB_ONFAULT]
+
 ! XXX should do this in bigger chunks when possible
 0:                                     ! loop:
        ldsb    [%o0], %g1              !       c = *fromaddr;
@@ -4387,10 +4372,10 @@
        be      1f                      !       if (c == NULL)
         inc    %o1                     !               goto ok;
        deccc   %o2                     !       if (--len > 0) {
-       bg      0b                      !               fromaddr++;
+       bgu     0b                      !               fromaddr++;
         inc    %o0                     !               goto loop;
                                        !       }
-                                       !
+Lcstoolong:                            !
        b       Lcsdone                 !       error = ENAMETOOLONG;
         mov    ENAMETOOLONG, %o0       !       goto done;
 1:                                     ! ok:
@@ -4416,12 +4401,11 @@
  * it does not seem that way to the C compiler.)
  */
 ENTRY(copystr)
-#ifdef DIAGNOSTIC
-       tst     %o2                     !       if (maxlength <= 0)
-       ble     4f                      !               panic(...);
-        EMPTY
-#endif
        mov     %o1, %o5                !       to0 = to;
+       tst     %o2                     ! if (maxlength == 0)
+       beq,a   2f                      !
+        mov    ENAMETOOLONG, %o0       !       ret = ENAMETOOLONG; goto done;
+
 0:                                     ! loop:
        ldsb    [%o0], %o4              !       c = *from;
        tst     %o4
@@ -4429,7 +4413,7 @@
        be      1f                      !       if (c == 0)
         inc    %o1                     !               goto ok;
        deccc   %o2                     !       if (--len > 0) {
-       bg,a    0b                      !               from++;
+       bgu,a   0b                      !               from++;
         inc    %o0                     !               goto loop;
        b       2f                      !       }
         mov    ENAMETOOLONG, %o0       !       ret = ENAMETOOLONG; goto done;
@@ -4443,15 +4427,6 @@
 3:
        retl
         nop
-#ifdef DIAGNOSTIC
-4:
-       sethi   %hi(5f), %o0
-       call    _C_LABEL(panic)
-        or     %lo(5f), %o0, %o0
-5:
-       .asciz  "copystr"
-       _ALIGN
-#endif
 
 /*
  * Copyin(src, dst, len)



Home | Main Index | Thread Index | Old Index