1/* 2 * Based on arch/arm/lib/clear_user.S 3 * 4 * Copyright (C) 2012 ARM Ltd. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 as 8 * published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18#include <linux/linkage.h> 19#include <asm/assembler.h> 20 21 .text 22 23/* Prototype: int __clear_user(void *addr, size_t sz) 24 * Purpose : clear some user memory 25 * Params : addr - user memory address to clear 26 * : sz - number of bytes to clear 27 * Returns : number of bytes NOT cleared 28 * 29 * Alignment fixed up by hardware. 30 */ 31ENTRY(__clear_user) 32 mov x2, x1 // save the size for fixup return 33 subs x1, x1, #8 34 b.mi 2f 351: 36USER(9f, str xzr, [x0], #8 ) 37 subs x1, x1, #8 38 b.pl 1b 392: adds x1, x1, #4 40 b.mi 3f 41USER(9f, str wzr, [x0], #4 ) 42 sub x1, x1, #4 433: adds x1, x1, #2 44 b.mi 4f 45USER(9f, strh wzr, [x0], #2 ) 46 sub x1, x1, #2 474: adds x1, x1, #1 48 b.mi 5f 49 strb wzr, [x0] 505: mov x0, #0 51 ret 52ENDPROC(__clear_user) 53 54 .section .fixup,"ax" 55 .align 2 569: mov x0, x2 // return the original size 57 ret 58 .previous 59