blob: aeafc03e961a822c82772a060350fd7728de1de4 [file] [log] [blame]
Thomas Gleixnercaab2772019-06-03 07:44:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Catalin Marinas0aea86a2012-03-05 11:49:32 +00002/*
3 * Based on arch/arm/lib/clear_user.S
4 *
5 * Copyright (C) 2012 ARM Ltd.
Catalin Marinas0aea86a2012-03-05 11:49:32 +00006 */
7#include <linux/linkage.h>
James Morse338d4f42015-07-22 19:05:54 +01008
Al Virob4b86642016-12-26 04:10:19 -05009#include <asm/asm-uaccess.h>
Mark Rutland56c08ec2018-12-07 18:08:20 +000010#include <asm/assembler.h>
Catalin Marinas0aea86a2012-03-05 11:49:32 +000011
12 .text
13
Will Deaconf71c2ff2018-02-05 15:34:23 +000014/* Prototype: int __arch_clear_user(void *addr, size_t sz)
Catalin Marinas0aea86a2012-03-05 11:49:32 +000015 * 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
19 *
20 * Alignment fixed up by hardware.
21 */
Will Deaconf71c2ff2018-02-05 15:34:23 +000022ENTRY(__arch_clear_user)
Catalin Marinas0aea86a2012-03-05 11:49:32 +000023 mov x2, x1 // save the size for fixup return
24 subs x1, x1, #8
25 b.mi 2f
261:
James Morse57f49592016-02-05 14:58:48 +000027uao_user_alternative 9f, str, sttr, xzr, x0, 8
Catalin Marinas0aea86a2012-03-05 11:49:32 +000028 subs x1, x1, #8
29 b.pl 1b
302: adds x1, x1, #4
31 b.mi 3f
James Morse57f49592016-02-05 14:58:48 +000032uao_user_alternative 9f, str, sttr, wzr, x0, 4
Catalin Marinas0aea86a2012-03-05 11:49:32 +000033 sub x1, x1, #4
343: adds x1, x1, #2
35 b.mi 4f
James Morse57f49592016-02-05 14:58:48 +000036uao_user_alternative 9f, strh, sttrh, wzr, x0, 2
Catalin Marinas0aea86a2012-03-05 11:49:32 +000037 sub x1, x1, #2
384: adds x1, x1, #1
39 b.mi 5f
James Morse57f49592016-02-05 14:58:48 +000040uao_user_alternative 9f, strb, sttrb, wzr, x0, 0
Catalin Marinas0aea86a2012-03-05 11:49:32 +0000415: mov x0, #0
Catalin Marinas0aea86a2012-03-05 11:49:32 +000042 ret
Will Deaconf71c2ff2018-02-05 15:34:23 +000043ENDPROC(__arch_clear_user)
Mark Rutland56c08ec2018-12-07 18:08:20 +000044EXPORT_SYMBOL(__arch_clear_user)
Catalin Marinas0aea86a2012-03-05 11:49:32 +000045
46 .section .fixup,"ax"
47 .align 2
489: mov x0, x2 // return the original size
Catalin Marinas0aea86a2012-03-05 11:49:32 +000049 ret
50 .previous