18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Based on arch/arm/lib/clear_user.S 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2012 ARM Ltd. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#include <linux/linkage.h> 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <asm/asm-uaccess.h> 108c2ecf20Sopenharmony_ci#include <asm/assembler.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci .text 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* Prototype: int __arch_clear_user(void *addr, size_t sz) 158c2ecf20Sopenharmony_ci * Purpose : clear some user memory 168c2ecf20Sopenharmony_ci * Params : addr - user memory address to clear 178c2ecf20Sopenharmony_ci * : sz - number of bytes to clear 188c2ecf20Sopenharmony_ci * Returns : number of bytes NOT cleared 198c2ecf20Sopenharmony_ci * 208c2ecf20Sopenharmony_ci * Alignment fixed up by hardware. 218c2ecf20Sopenharmony_ci */ 228c2ecf20Sopenharmony_ciSYM_FUNC_START(__arch_clear_user) 238c2ecf20Sopenharmony_ci mov x2, x1 // save the size for fixup return 248c2ecf20Sopenharmony_ci subs x1, x1, #8 258c2ecf20Sopenharmony_ci b.mi 2f 268c2ecf20Sopenharmony_ci1: 278c2ecf20Sopenharmony_ciuao_user_alternative 9f, str, sttr, xzr, x0, 8 288c2ecf20Sopenharmony_ci subs x1, x1, #8 298c2ecf20Sopenharmony_ci b.pl 1b 308c2ecf20Sopenharmony_ci2: adds x1, x1, #4 318c2ecf20Sopenharmony_ci b.mi 3f 328c2ecf20Sopenharmony_ciuao_user_alternative 9f, str, sttr, wzr, x0, 4 338c2ecf20Sopenharmony_ci sub x1, x1, #4 348c2ecf20Sopenharmony_ci3: adds x1, x1, #2 358c2ecf20Sopenharmony_ci b.mi 4f 368c2ecf20Sopenharmony_ciuao_user_alternative 9f, strh, sttrh, wzr, x0, 2 378c2ecf20Sopenharmony_ci sub x1, x1, #2 388c2ecf20Sopenharmony_ci4: adds x1, x1, #1 398c2ecf20Sopenharmony_ci b.mi 5f 408c2ecf20Sopenharmony_ciuao_user_alternative 9f, strb, sttrb, wzr, x0, 0 418c2ecf20Sopenharmony_ci5: mov x0, #0 428c2ecf20Sopenharmony_ci ret 438c2ecf20Sopenharmony_ciSYM_FUNC_END(__arch_clear_user) 448c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__arch_clear_user) 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci .section .fixup,"ax" 478c2ecf20Sopenharmony_ci .align 2 488c2ecf20Sopenharmony_ci9: mov x0, x2 // return the original size 498c2ecf20Sopenharmony_ci ret 508c2ecf20Sopenharmony_ci .previous 51