2019-06-03 12:44:50 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2012-03-05 18:49:32 +07:00
|
|
|
/*
|
|
|
|
* Based on arch/arm/lib/clear_user.S
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 ARM Ltd.
|
|
|
|
*/
|
|
|
|
#include <linux/linkage.h>
|
2015-07-23 01:05:54 +07:00
|
|
|
|
2016-12-26 16:10:19 +07:00
|
|
|
#include <asm/asm-uaccess.h>
|
2018-12-08 01:08:20 +07:00
|
|
|
#include <asm/assembler.h>
|
2012-03-05 18:49:32 +07:00
|
|
|
|
|
|
|
.text
|
|
|
|
|
2018-02-05 22:34:23 +07:00
|
|
|
/* Prototype: int __arch_clear_user(void *addr, size_t sz)
|
2012-03-05 18:49:32 +07:00
|
|
|
* Purpose : clear some user memory
|
|
|
|
* Params : addr - user memory address to clear
|
|
|
|
* : sz - number of bytes to clear
|
|
|
|
* Returns : number of bytes NOT cleared
|
|
|
|
*
|
|
|
|
* Alignment fixed up by hardware.
|
|
|
|
*/
|
2020-01-07 02:58:17 +07:00
|
|
|
SYM_FUNC_START(__arch_clear_user)
|
2012-03-05 18:49:32 +07:00
|
|
|
mov x2, x1 // save the size for fixup return
|
|
|
|
subs x1, x1, #8
|
|
|
|
b.mi 2f
|
|
|
|
1:
|
2016-02-05 21:58:48 +07:00
|
|
|
uao_user_alternative 9f, str, sttr, xzr, x0, 8
|
2012-03-05 18:49:32 +07:00
|
|
|
subs x1, x1, #8
|
|
|
|
b.pl 1b
|
|
|
|
2: adds x1, x1, #4
|
|
|
|
b.mi 3f
|
2016-02-05 21:58:48 +07:00
|
|
|
uao_user_alternative 9f, str, sttr, wzr, x0, 4
|
2012-03-05 18:49:32 +07:00
|
|
|
sub x1, x1, #4
|
|
|
|
3: adds x1, x1, #2
|
|
|
|
b.mi 4f
|
2016-02-05 21:58:48 +07:00
|
|
|
uao_user_alternative 9f, strh, sttrh, wzr, x0, 2
|
2012-03-05 18:49:32 +07:00
|
|
|
sub x1, x1, #2
|
|
|
|
4: adds x1, x1, #1
|
|
|
|
b.mi 5f
|
2016-02-05 21:58:48 +07:00
|
|
|
uao_user_alternative 9f, strb, sttrb, wzr, x0, 0
|
2012-03-05 18:49:32 +07:00
|
|
|
5: mov x0, #0
|
|
|
|
ret
|
2020-01-07 02:58:17 +07:00
|
|
|
SYM_FUNC_END(__arch_clear_user)
|
2018-12-08 01:08:20 +07:00
|
|
|
EXPORT_SYMBOL(__arch_clear_user)
|
2012-03-05 18:49:32 +07:00
|
|
|
|
|
|
|
.section .fixup,"ax"
|
|
|
|
.align 2
|
|
|
|
9: mov x0, x2 // return the original size
|
|
|
|
ret
|
|
|
|
.previous
|