Thomas Gleixner | caab277 | 2019-06-03 07:44:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Based on arch/arm/lib/clear_user.S |
| 4 | * |
| 5 | * Copyright (C) 2012 ARM Ltd. |
Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 6 | */ |
| 7 | #include <linux/linkage.h> |
James Morse | 338d4f4 | 2015-07-22 19:05:54 +0100 | [diff] [blame] | 8 | |
Al Viro | b4b8664 | 2016-12-26 04:10:19 -0500 | [diff] [blame] | 9 | #include <asm/asm-uaccess.h> |
Mark Rutland | 56c08ec | 2018-12-07 18:08:20 +0000 | [diff] [blame] | 10 | #include <asm/assembler.h> |
Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 11 | |
| 12 | .text |
| 13 | |
Will Deacon | f71c2ff | 2018-02-05 15:34:23 +0000 | [diff] [blame] | 14 | /* Prototype: int __arch_clear_user(void *addr, size_t sz) |
Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 15 | * Purpose : clear some user memory |
| 16 | * Params : addr - user memory address to clear |
| 17 | * : sz - number of bytes to clear |
| 18 | * Returns : number of bytes NOT cleared |
| 19 | * |
| 20 | * Alignment fixed up by hardware. |
| 21 | */ |
Will Deacon | f71c2ff | 2018-02-05 15:34:23 +0000 | [diff] [blame] | 22 | ENTRY(__arch_clear_user) |
Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 23 | mov x2, x1 // save the size for fixup return |
| 24 | subs x1, x1, #8 |
| 25 | b.mi 2f |
| 26 | 1: |
James Morse | 57f4959 | 2016-02-05 14:58:48 +0000 | [diff] [blame] | 27 | uao_user_alternative 9f, str, sttr, xzr, x0, 8 |
Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 28 | subs x1, x1, #8 |
| 29 | b.pl 1b |
| 30 | 2: adds x1, x1, #4 |
| 31 | b.mi 3f |
James Morse | 57f4959 | 2016-02-05 14:58:48 +0000 | [diff] [blame] | 32 | uao_user_alternative 9f, str, sttr, wzr, x0, 4 |
Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 33 | sub x1, x1, #4 |
| 34 | 3: adds x1, x1, #2 |
| 35 | b.mi 4f |
James Morse | 57f4959 | 2016-02-05 14:58:48 +0000 | [diff] [blame] | 36 | uao_user_alternative 9f, strh, sttrh, wzr, x0, 2 |
Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 37 | sub x1, x1, #2 |
| 38 | 4: adds x1, x1, #1 |
| 39 | b.mi 5f |
James Morse | 57f4959 | 2016-02-05 14:58:48 +0000 | [diff] [blame] | 40 | uao_user_alternative 9f, strb, sttrb, wzr, x0, 0 |
Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 41 | 5: mov x0, #0 |
Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 42 | ret |
Will Deacon | f71c2ff | 2018-02-05 15:34:23 +0000 | [diff] [blame] | 43 | ENDPROC(__arch_clear_user) |
Mark Rutland | 56c08ec | 2018-12-07 18:08:20 +0000 | [diff] [blame] | 44 | EXPORT_SYMBOL(__arch_clear_user) |
Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 45 | |
| 46 | .section .fixup,"ax" |
| 47 | .align 2 |
| 48 | 9: mov x0, x2 // return the original size |
Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 49 | ret |
| 50 | .previous |