Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * arch/alpha/lib/clear_user.S
0004  * Contributed by Richard Henderson <rth@tamu.edu>
0005  *
0006  * Zero user space, handling exceptions as we go.
0007  *
0008  * We have to make sure that $0 is always up-to-date and contains the
0009  * right "bytes left to zero" value (and that it is updated only _after_
0010  * a successful copy).  There is also some rather minor exception setup
0011  * stuff.
0012  */
0013 #include <asm/export.h>
0014 
0015 /* Allow an exception for an insn; exit if we get one.  */
0016 #define EX(x,y...)          \
0017     99: x,##y;          \
0018     .section __ex_table,"a";    \
0019     .long 99b - .;          \
0020     lda $31, $exception-99b($31);   \
0021     .previous
0022 
0023     .set noat
0024     .set noreorder
0025     .align 4
0026 
0027     .globl __clear_user
0028     .ent __clear_user
0029     .frame  $30, 0, $26
0030     .prologue 0
0031 
0032 $loop:
0033     and $1, 3, $4   # e0    :
0034     beq $4, 1f      # .. e1 :
0035 
0036 0:  EX( stq_u $31, 0($16) ) # e0    : zero one word
0037     subq    $0, 8, $0   # .. e1 :
0038     subq    $4, 1, $4   # e0    :
0039     addq    $16, 8, $16 # .. e1 :
0040     bne $4, 0b      # e1    :
0041     unop            #       :
0042 
0043 1:  bic $1, 3, $1   # e0    :
0044     beq $1, $tail   # .. e1 :
0045 
0046 2:  EX( stq_u $31, 0($16) ) # e0    : zero four words
0047     subq    $0, 8, $0   # .. e1 :
0048     EX( stq_u $31, 8($16) ) # e0    :
0049     subq    $0, 8, $0   # .. e1 :
0050     EX( stq_u $31, 16($16) )    # e0    :
0051     subq    $0, 8, $0   # .. e1 :
0052     EX( stq_u $31, 24($16) )    # e0    :
0053     subq    $0, 8, $0   # .. e1 :
0054     subq    $1, 4, $1   # e0    :
0055     addq    $16, 32, $16    # .. e1 :
0056     bne $1, 2b      # e1    :
0057 
0058 $tail:
0059     bne $2, 1f      # e1    : is there a tail to do?
0060     ret $31, ($26), 1   # .. e1 :
0061 
0062 1:  EX( ldq_u $5, 0($16) )  # e0    :
0063     clr $0      # .. e1 :
0064     nop         # e1    :
0065     mskqh   $5, $0, $5  # e0    :
0066     EX( stq_u $5, 0($16) )  # e0    :
0067     ret $31, ($26), 1   # .. e1 :
0068 
0069 __clear_user:
0070     and $17, $17, $0
0071     and $16, 7, $4  # e0    : find dest misalignment
0072     beq $0, $zerolength # .. e1 :
0073     addq    $0, $4, $1  # e0    : bias counter
0074     and $1, 7, $2   # e1    : number of bytes in tail
0075     srl $1, 3, $1   # e0    :
0076     beq $4, $loop   # .. e1 :
0077 
0078     EX( ldq_u $5, 0($16) )  # e0    : load dst word to mask back in
0079     beq $1, $oneword    # .. e1 : sub-word store?
0080 
0081     mskql   $5, $16, $5 # e0    : take care of misaligned head
0082     addq    $16, 8, $16 # .. e1 :
0083     EX( stq_u $5, -8($16) ) # e0    :
0084     addq    $0, $4, $0  # .. e1 : bytes left -= 8 - misalignment
0085     subq    $1, 1, $1   # e0    :
0086     subq    $0, 8, $0   # .. e1 :
0087     br  $loop       # e1    :
0088     unop            #       :
0089 
0090 $oneword:
0091     mskql   $5, $16, $4 # e0    :
0092     mskqh   $5, $2, $5  # e0    :
0093     or  $5, $4, $5  # e1    :
0094     EX( stq_u $5, 0($16) )  # e0    :
0095     clr $0      # .. e1 :
0096 
0097 $zerolength:
0098 $exception:
0099     ret $31, ($26), 1   # .. e1 :
0100 
0101     .end __clear_user
0102     EXPORT_SYMBOL(__clear_user)