18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * linux/arch/arm/lib/clear_user.S 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 1995, 1996,1997,1998 Russell King 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#include <linux/linkage.h> 88c2ecf20Sopenharmony_ci#include <asm/assembler.h> 98c2ecf20Sopenharmony_ci#include <asm/unwind.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci .text 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* Prototype: unsigned long arm_clear_user(void *addr, size_t sz) 148c2ecf20Sopenharmony_ci * Purpose : clear some user memory 158c2ecf20Sopenharmony_ci * Params : addr - user memory address to clear 168c2ecf20Sopenharmony_ci * : sz - number of bytes to clear 178c2ecf20Sopenharmony_ci * Returns : number of bytes NOT cleared 188c2ecf20Sopenharmony_ci */ 198c2ecf20Sopenharmony_ciENTRY(__clear_user_std) 208c2ecf20Sopenharmony_ciWEAK(arm_clear_user) 218c2ecf20Sopenharmony_ciUNWIND(.fnstart) 228c2ecf20Sopenharmony_ciUNWIND(.save {r1, lr}) 238c2ecf20Sopenharmony_ci stmfd sp!, {r1, lr} 248c2ecf20Sopenharmony_ci mov r2, #0 258c2ecf20Sopenharmony_ci cmp r1, #4 268c2ecf20Sopenharmony_ci blt 2f 278c2ecf20Sopenharmony_ci ands ip, r0, #3 288c2ecf20Sopenharmony_ci beq 1f 298c2ecf20Sopenharmony_ci cmp ip, #2 308c2ecf20Sopenharmony_ci strusr r2, r0, 1 318c2ecf20Sopenharmony_ci strusr r2, r0, 1, le 328c2ecf20Sopenharmony_ci strusr r2, r0, 1, lt 338c2ecf20Sopenharmony_ci rsb ip, ip, #4 348c2ecf20Sopenharmony_ci sub r1, r1, ip @ 7 6 5 4 3 2 1 358c2ecf20Sopenharmony_ci1: subs r1, r1, #8 @ -1 -2 -3 -4 -5 -6 -7 368c2ecf20Sopenharmony_ci strusr r2, r0, 4, pl, rept=2 378c2ecf20Sopenharmony_ci bpl 1b 388c2ecf20Sopenharmony_ci adds r1, r1, #4 @ 3 2 1 0 -1 -2 -3 398c2ecf20Sopenharmony_ci strusr r2, r0, 4, pl 408c2ecf20Sopenharmony_ci2: tst r1, #2 @ 1x 1x 0x 0x 1x 1x 0x 418c2ecf20Sopenharmony_ci strusr r2, r0, 1, ne, rept=2 428c2ecf20Sopenharmony_ci tst r1, #1 @ x1 x0 x1 x0 x1 x0 x1 438c2ecf20Sopenharmony_ci it ne @ explicit IT needed for the label 448c2ecf20Sopenharmony_ciUSER( strbtne r2, [r0]) 458c2ecf20Sopenharmony_ci mov r0, #0 468c2ecf20Sopenharmony_ci ldmfd sp!, {r1, pc} 478c2ecf20Sopenharmony_ciUNWIND(.fnend) 488c2ecf20Sopenharmony_ciENDPROC(arm_clear_user) 498c2ecf20Sopenharmony_ciENDPROC(__clear_user_std) 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci .pushsection .text.fixup,"ax" 528c2ecf20Sopenharmony_ci .align 0 538c2ecf20Sopenharmony_ci9001: ldmfd sp!, {r0, pc} 548c2ecf20Sopenharmony_ci .popsection 558c2ecf20Sopenharmony_ci 56