1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Based on arch/arm/lib/clear_user.S
5 * Copyright (C) 2012 ARM Ltd.
7 #include <linux/linkage.h>
9 #include <asm/asm-uaccess.h>
10 #include <asm/assembler.h>
14 /* Prototype: int __arch_clear_user(void *addr, size_t sz)
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
20 * Alignment fixed up by hardware.
22 ENTRY(__arch_clear_user)
23 uaccess_enable_not_uao x2, x3, x4
24 mov x2, x1 // save the size for fixup return
28 uao_user_alternative 9f, str, sttr, xzr, x0, 8
33 uao_user_alternative 9f, str, sttr, wzr, x0, 4
37 uao_user_alternative 9f, strh, sttrh, wzr, x0, 2
41 uao_user_alternative 9f, strb, sttrb, wzr, x0, 0
43 uaccess_disable_not_uao x2, x3
45 ENDPROC(__arch_clear_user)
46 EXPORT_SYMBOL(__arch_clear_user)
50 9: mov x0, x2 // return the original size