Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * linux/arch/unicore32/lib/strncpy_from_user.S
4 *
5 * Code specific to PKUnity SoC and UniCore ISA
6 *
7 * Copyright (C) 2001-2010 GUAN Xue-tao
8 */
9#include <linux/linkage.h>
10#include <asm/assembler.h>
11#include <asm/errno.h>
12
13 .text
14 .align 5
15
16/*
17 * Copy a string from user space to kernel space.
18 * r0 = dst, r1 = src, r2 = byte length
19 * returns the number of characters copied (strlen of copied string),
20 * -EFAULT on exception, or "len" if we fill the whole buffer
21 */
22ENTRY(__strncpy_from_user)
23 mov ip, r1
241: sub.a r2, r2, #1
25 ldrusr r3, r1, 1, ns
26 bfs 2f
27 stb.w r3, [r0]+, #1
28 cxor.a r3, #0
29 bne 1b
30 sub r1, r1, #1 @ take NUL character out of count
312: sub r0, r1, ip
32 mov pc, lr
33ENDPROC(__strncpy_from_user)
34
35 .pushsection .fixup,"ax"
36 .align 0
379001: mov r3, #0
38 stb r3, [r0+], #0 @ null terminate
39 mov r0, #-EFAULT
40 mov pc, lr
41 .popsection
42