10aea86a2SCatalin Marinas/* 20aea86a2SCatalin Marinas * Based on arch/arm/lib/clear_user.S 30aea86a2SCatalin Marinas * 40aea86a2SCatalin Marinas * Copyright (C) 2012 ARM Ltd. 50aea86a2SCatalin Marinas * 60aea86a2SCatalin Marinas * This program is free software; you can redistribute it and/or modify 70aea86a2SCatalin Marinas * it under the terms of the GNU General Public License version 2 as 80aea86a2SCatalin Marinas * published by the Free Software Foundation. 90aea86a2SCatalin Marinas * 100aea86a2SCatalin Marinas * This program is distributed in the hope that it will be useful, 110aea86a2SCatalin Marinas * but WITHOUT ANY WARRANTY; without even the implied warranty of 120aea86a2SCatalin Marinas * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 130aea86a2SCatalin Marinas * GNU General Public License for more details. 140aea86a2SCatalin Marinas * 150aea86a2SCatalin Marinas * You should have received a copy of the GNU General Public License 160aea86a2SCatalin Marinas * along with this program. If not, see <http://www.gnu.org/licenses/>. 170aea86a2SCatalin Marinas */ 180aea86a2SCatalin Marinas#include <linux/linkage.h> 19338d4f49SJames Morse 20bd38967dSCatalin Marinas#include <asm/uaccess.h> 210aea86a2SCatalin Marinas 220aea86a2SCatalin Marinas .text 230aea86a2SCatalin Marinas 240aea86a2SCatalin Marinas/* Prototype: int __clear_user(void *addr, size_t sz) 250aea86a2SCatalin Marinas * Purpose : clear some user memory 260aea86a2SCatalin Marinas * Params : addr - user memory address to clear 270aea86a2SCatalin Marinas * : sz - number of bytes to clear 280aea86a2SCatalin Marinas * Returns : number of bytes NOT cleared 290aea86a2SCatalin Marinas * 300aea86a2SCatalin Marinas * Alignment fixed up by hardware. 310aea86a2SCatalin Marinas */ 320aea86a2SCatalin MarinasENTRY(__clear_user) 33bd38967dSCatalin Marinas uaccess_enable_not_uao x2, x3 340aea86a2SCatalin Marinas mov x2, x1 // save the size for fixup return 350aea86a2SCatalin Marinas subs x1, x1, #8 360aea86a2SCatalin Marinas b.mi 2f 370aea86a2SCatalin Marinas1: 3857f4959bSJames Morseuao_user_alternative 9f, str, sttr, xzr, x0, 8 390aea86a2SCatalin Marinas subs x1, x1, #8 400aea86a2SCatalin Marinas b.pl 1b 410aea86a2SCatalin Marinas2: adds x1, x1, #4 420aea86a2SCatalin Marinas b.mi 3f 4357f4959bSJames Morseuao_user_alternative 9f, str, sttr, wzr, x0, 4 440aea86a2SCatalin Marinas sub x1, x1, #4 450aea86a2SCatalin Marinas3: adds x1, x1, #2 460aea86a2SCatalin Marinas b.mi 4f 4757f4959bSJames Morseuao_user_alternative 9f, strh, sttrh, wzr, x0, 2 480aea86a2SCatalin Marinas sub x1, x1, #2 490aea86a2SCatalin Marinas4: adds x1, x1, #1 500aea86a2SCatalin Marinas b.mi 5f 5157f4959bSJames Morseuao_user_alternative 9f, strb, sttrb, wzr, x0, 0 520aea86a2SCatalin Marinas5: mov x0, #0 53bd38967dSCatalin Marinas uaccess_disable_not_uao x2 540aea86a2SCatalin Marinas ret 550aea86a2SCatalin MarinasENDPROC(__clear_user) 560aea86a2SCatalin Marinas 570aea86a2SCatalin Marinas .section .fixup,"ax" 580aea86a2SCatalin Marinas .align 2 590aea86a2SCatalin Marinas9: mov x0, x2 // return the original size 600aea86a2SCatalin Marinas ret 610aea86a2SCatalin Marinas .previous 62