^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * linux/arch/arm/lib/clear_user.S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 1995, 1996,1997,1998 Russell King
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/linkage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <asm/assembler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <asm/unwind.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) .text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /* Prototype: unsigned long arm_clear_user(void *addr, size_t sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Purpose : clear some user memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Params : addr - user memory address to clear
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * : sz - number of bytes to clear
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * Returns : number of bytes NOT cleared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) ENTRY(__clear_user_std)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) WEAK(arm_clear_user)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) UNWIND(.fnstart)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) UNWIND(.save {r1, lr})
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) stmfd sp!, {r1, lr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) mov r2, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) cmp r1, #4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) blt 2f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) ands ip, r0, #3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) beq 1f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) cmp ip, #2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) strusr r2, r0, 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) strusr r2, r0, 1, le
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) strusr r2, r0, 1, lt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) rsb ip, ip, #4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) sub r1, r1, ip @ 7 6 5 4 3 2 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 1: subs r1, r1, #8 @ -1 -2 -3 -4 -5 -6 -7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) strusr r2, r0, 4, pl, rept=2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) bpl 1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) adds r1, r1, #4 @ 3 2 1 0 -1 -2 -3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) strusr r2, r0, 4, pl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 2: tst r1, #2 @ 1x 1x 0x 0x 1x 1x 0x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) strusr r2, r0, 1, ne, rept=2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) tst r1, #1 @ x1 x0 x1 x0 x1 x0 x1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) it ne @ explicit IT needed for the label
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) USER( strbtne r2, [r0])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) mov r0, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) ldmfd sp!, {r1, pc}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) UNWIND(.fnend)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) ENDPROC(arm_clear_user)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) ENDPROC(__clear_user_std)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) .pushsection .text.fixup,"ax"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) .align 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 9001: ldmfd sp!, {r0, pc}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) .popsection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)