Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 2 | /* |
| 3 | * linux/arch/arm/lib/clear_user.S |
| 4 | * |
| 5 | * Copyright (C) 1995, 1996,1997,1998 Russell King |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 6 | */ |
| 7 | #include <linux/linkage.h> |
| 8 | #include <asm/assembler.h> |
Stephen Boyd | 6f56a68 | 2015-09-15 00:11:30 +0100 | [diff] [blame] | 9 | #include <asm/unwind.h> |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 10 | |
| 11 | .text |
| 12 | |
Russell King | 3fba7e2 | 2015-08-19 11:02:28 +0100 | [diff] [blame] | 13 | /* Prototype: unsigned long arm_clear_user(void *addr, size_t sz) |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 14 | * 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 Pitre | a1f9884 | 2009-03-08 22:34:45 -0400 | [diff] [blame] | 19 | ENTRY(__clear_user_std) |
Russell King | 3fba7e2 | 2015-08-19 11:02:28 +0100 | [diff] [blame] | 20 | WEAK(arm_clear_user) |
Stephen Boyd | 6f56a68 | 2015-09-15 00:11:30 +0100 | [diff] [blame] | 21 | UNWIND(.fnstart) |
| 22 | UNWIND(.save {r1, lr}) |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 23 | 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 Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 30 | strusr r2, r0, 1 |
| 31 | strusr r2, r0, 1, le |
| 32 | strusr r2, r0, 1, lt |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 33 | rsb ip, ip, #4 |
| 34 | sub r1, r1, ip @ 7 6 5 4 3 2 1 |
| 35 | 1: subs r1, r1, #8 @ -1 -2 -3 -4 -5 -6 -7 |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 36 | strusr r2, r0, 4, pl, rept=2 |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 37 | bpl 1b |
| 38 | adds r1, r1, #4 @ 3 2 1 0 -1 -2 -3 |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 39 | strusr r2, r0, 4, pl |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 40 | 2: tst r1, #2 @ 1x 1x 0x 0x 1x 1x 0x |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 41 | strusr r2, r0, 1, ne, rept=2 |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 42 | tst r1, #1 @ x1 x0 x1 x0 x1 x0 x1 |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 43 | it ne @ explicit IT needed for the label |
Stefan Agner | e44fc38 | 2019-02-18 00:57:38 +0100 | [diff] [blame] | 44 | USER( strbtne r2, [r0]) |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 45 | mov r0, #0 |
Russell King | 1b93a71 | 2006-06-25 11:23:45 +0100 | [diff] [blame] | 46 | ldmfd sp!, {r1, pc} |
Stephen Boyd | 6f56a68 | 2015-09-15 00:11:30 +0100 | [diff] [blame] | 47 | UNWIND(.fnend) |
Russell King | 3fba7e2 | 2015-08-19 11:02:28 +0100 | [diff] [blame] | 48 | ENDPROC(arm_clear_user) |
Catalin Marinas | e814d82 | 2010-05-07 10:52:32 +0100 | [diff] [blame] | 49 | ENDPROC(__clear_user_std) |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 50 | |
Ard Biesheuvel | c4a84ae | 2015-03-24 10:41:09 +0100 | [diff] [blame] | 51 | .pushsection .text.fixup,"ax" |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 52 | .align 0 |
Russell King | 1b93a71 | 2006-06-25 11:23:45 +0100 | [diff] [blame] | 53 | 9001: ldmfd sp!, {r0, pc} |
Russell King | 4260415 | 2010-04-19 10:15:03 +0100 | [diff] [blame] | 54 | .popsection |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 55 | |