/*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, 1999 by Ralf Baechle6*/7#include <linux/errno.h>8#include <asm/asm.h>9#include <asm/asm-offsets.h>10#include <asm/regdef.h>1112#define EX(insn,reg,addr,handler) \139: insn reg, addr; \14.section __ex_table,"a"; \15PTR 9b, handler; \16.previous1718/*19* Returns: -EFAULT if exception before terminator, N if the entire20* buffer filled, else strlen.21*/2223/*24* Ugly special case have to check: we might get passed a user space25* pointer which wraps into the kernel space. We don't deal with that. If26* it happens at most some bytes of the exceptions handlers will be copied.27*/2829LEAF(__strncpy_from_user_asm)30LONG_L v0, TI_ADDR_LIMIT($28) # pointer ok?31and v0, a132bnez v0, .Lfault3334FEXPORT(__strncpy_from_user_nocheck_asm)35move v0, zero36move v1, a137.set noreorder381: EX(lbu, t0, (v1), .Lfault)39PTR_ADDIU v1, 140R10KCBARRIER(0(ra))41beqz t0, 2f42sb t0, (a0)43PTR_ADDIU v0, 144.set reorder45PTR_ADDIU a0, 146bne v0, a2, 1b472: PTR_ADDU t0, a1, v048xor t0, a149bltz t0, .Lfault50jr ra # return n51END(__strncpy_from_user_asm)5253.Lfault: li v0, -EFAULT54jr ra5556.section __ex_table,"a"57PTR 1b, .Lfault58.previous596061