/*1* This file is subject to the terms and conditions of the GNU General Public2* License. See the file "COPYING" in the main directory of this archive3* for more details.4*5* Copyright (c) 1996, 1998, 1999, 2004 by Ralf Baechle6* Copyright (c) 1999 Silicon Graphics, Inc.7*/8#include <linux/export.h>9#include <asm/asm.h>10#include <asm/asm-offsets.h>11#include <asm/regdef.h>1213#define EX(insn,reg,addr,handler) \149: insn reg, addr; \15.section __ex_table,"a"; \16PTR_WD 9b, handler; \17.previous1819/*20* Return the size of a string including the ending NUL character up to a21* maximum of a1 or 0 in case of error.22*23* Note: for performance reasons we deliberately accept that a user may24* make strlen_user and strnlen_user access the first few KSEG025* bytes. There's nothing secret there. On 64-bit accessing beyond26* the maximum is a tad hairier ...27*/28LEAF(__strnlen_user_asm)29move v0, a030PTR_ADDU a1, a0 # stop pointer311:32#ifdef CONFIG_CPU_DADDI_WORKAROUNDS33.set noat34li AT, 135#endif36beq v0, a1, 1f # limit reached?37#ifdef CONFIG_EVA38.set push39.set eva40EX(lbe, t0, (v0), .Lfault)41.set pop42#else43EX(lb, t0, (v0), .Lfault)44#endif45.set noreorder46bnez t0, 1b471:48#ifndef CONFIG_CPU_DADDI_WORKAROUNDS49PTR_ADDIU v0, 150#else51PTR_ADDU v0, AT52.set at53#endif54.set reorder55PTR_SUBU v0, a056jr ra57END(__strnlen_user_asm)5859.Lfault:60move v0, zero61jr ra6263EXPORT_SYMBOL(__strnlen_user_asm)646566