blob: 8f2c4dbfc5f21009d6336c16f514140a226fe3eb [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Nicolas Pitrea0c6fdb2005-11-01 19:52:22 +00002/*
3 * linux/arch/arm/lib/clear_user.S
4 *
5 * Copyright (C) 1995, 1996,1997,1998 Russell King
Nicolas Pitrea0c6fdb2005-11-01 19:52:22 +00006 */
7#include <linux/linkage.h>
8#include <asm/assembler.h>
Stephen Boyd6f56a682015-09-15 00:11:30 +01009#include <asm/unwind.h>
Nicolas Pitrea0c6fdb2005-11-01 19:52:22 +000010
11 .text
12
Russell King3fba7e22015-08-19 11:02:28 +010013/* Prototype: unsigned long arm_clear_user(void *addr, size_t sz)
Nicolas Pitrea0c6fdb2005-11-01 19:52:22 +000014 * Purpose : clear some user memory
15 * Params : addr - user memory address to clear
16 * : sz - number of bytes to clear
17 * Returns : number of bytes NOT cleared
18 */
Nicolas Pitrea1f98842009-03-08 22:34:45 -040019ENTRY(__clear_user_std)
Russell King3fba7e22015-08-19 11:02:28 +010020WEAK(arm_clear_user)
Stephen Boyd6f56a682015-09-15 00:11:30 +010021UNWIND(.fnstart)
22UNWIND(.save {r1, lr})
Nicolas Pitrea0c6fdb2005-11-01 19:52:22 +000023 stmfd sp!, {r1, lr}
24 mov r2, #0
25 cmp r1, #4
26 blt 2f
27 ands ip, r0, #3
28 beq 1f
29 cmp ip, #2
Catalin Marinas8b592782009-07-24 12:32:57 +010030 strusr r2, r0, 1
31 strusr r2, r0, 1, le
32 strusr r2, r0, 1, lt
Nicolas Pitrea0c6fdb2005-11-01 19:52:22 +000033 rsb ip, ip, #4
34 sub r1, r1, ip @ 7 6 5 4 3 2 1
351: subs r1, r1, #8 @ -1 -2 -3 -4 -5 -6 -7
Catalin Marinas8b592782009-07-24 12:32:57 +010036 strusr r2, r0, 4, pl, rept=2
Nicolas Pitrea0c6fdb2005-11-01 19:52:22 +000037 bpl 1b
38 adds r1, r1, #4 @ 3 2 1 0 -1 -2 -3
Catalin Marinas8b592782009-07-24 12:32:57 +010039 strusr r2, r0, 4, pl
Nicolas Pitrea0c6fdb2005-11-01 19:52:22 +0000402: tst r1, #2 @ 1x 1x 0x 0x 1x 1x 0x
Catalin Marinas8b592782009-07-24 12:32:57 +010041 strusr r2, r0, 1, ne, rept=2
Nicolas Pitrea0c6fdb2005-11-01 19:52:22 +000042 tst r1, #1 @ x1 x0 x1 x0 x1 x0 x1
Catalin Marinas8b592782009-07-24 12:32:57 +010043 it ne @ explicit IT needed for the label
Stefan Agnere44fc382019-02-18 00:57:38 +010044USER( strbtne r2, [r0])
Nicolas Pitrea0c6fdb2005-11-01 19:52:22 +000045 mov r0, #0
Russell King1b93a712006-06-25 11:23:45 +010046 ldmfd sp!, {r1, pc}
Stephen Boyd6f56a682015-09-15 00:11:30 +010047UNWIND(.fnend)
Russell King3fba7e22015-08-19 11:02:28 +010048ENDPROC(arm_clear_user)
Catalin Marinase814d822010-05-07 10:52:32 +010049ENDPROC(__clear_user_std)
Nicolas Pitrea0c6fdb2005-11-01 19:52:22 +000050
Ard Biesheuvelc4a84ae2015-03-24 10:41:09 +010051 .pushsection .text.fixup,"ax"
Nicolas Pitrea0c6fdb2005-11-01 19:52:22 +000052 .align 0
Russell King1b93a712006-06-25 11:23:45 +0100539001: ldmfd sp!, {r0, pc}
Russell King42604152010-04-19 10:15:03 +010054 .popsection
Nicolas Pitrea0c6fdb2005-11-01 19:52:22 +000055