1*4882a593Smuzhiyun/* SPDX-License-Identifier: GPL-2.0-only */ 2*4882a593Smuzhiyun/* 3*4882a593Smuzhiyun * Based on arch/arm/lib/clear_user.S 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Copyright (C) 2012 ARM Ltd. 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun#include <linux/linkage.h> 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun#include <asm/asm-uaccess.h> 10*4882a593Smuzhiyun#include <asm/assembler.h> 11*4882a593Smuzhiyun 12*4882a593Smuzhiyun .text 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun/* Prototype: int __arch_clear_user(void *addr, size_t sz) 15*4882a593Smuzhiyun * Purpose : clear some user memory 16*4882a593Smuzhiyun * Params : addr - user memory address to clear 17*4882a593Smuzhiyun * : sz - number of bytes to clear 18*4882a593Smuzhiyun * Returns : number of bytes NOT cleared 19*4882a593Smuzhiyun * 20*4882a593Smuzhiyun * Alignment fixed up by hardware. 21*4882a593Smuzhiyun */ 22*4882a593SmuzhiyunSYM_FUNC_START(__arch_clear_user) 23*4882a593Smuzhiyun mov x2, x1 // save the size for fixup return 24*4882a593Smuzhiyun subs x1, x1, #8 25*4882a593Smuzhiyun b.mi 2f 26*4882a593Smuzhiyun1: 27*4882a593Smuzhiyunuao_user_alternative 9f, str, sttr, xzr, x0, 8 28*4882a593Smuzhiyun subs x1, x1, #8 29*4882a593Smuzhiyun b.pl 1b 30*4882a593Smuzhiyun2: adds x1, x1, #4 31*4882a593Smuzhiyun b.mi 3f 32*4882a593Smuzhiyunuao_user_alternative 9f, str, sttr, wzr, x0, 4 33*4882a593Smuzhiyun sub x1, x1, #4 34*4882a593Smuzhiyun3: adds x1, x1, #2 35*4882a593Smuzhiyun b.mi 4f 36*4882a593Smuzhiyunuao_user_alternative 9f, strh, sttrh, wzr, x0, 2 37*4882a593Smuzhiyun sub x1, x1, #2 38*4882a593Smuzhiyun4: adds x1, x1, #1 39*4882a593Smuzhiyun b.mi 5f 40*4882a593Smuzhiyunuao_user_alternative 9f, strb, sttrb, wzr, x0, 0 41*4882a593Smuzhiyun5: mov x0, #0 42*4882a593Smuzhiyun ret 43*4882a593SmuzhiyunSYM_FUNC_END(__arch_clear_user) 44*4882a593SmuzhiyunEXPORT_SYMBOL(__arch_clear_user) 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun .section .fixup,"ax" 47*4882a593Smuzhiyun .align 2 48*4882a593Smuzhiyun9: mov x0, x2 // return the original size 49*4882a593Smuzhiyun ret 50*4882a593Smuzhiyun .previous 51