xref: /linux/arch/arm/lib/csumpartialcopyuser.S (revision f14aa5ea415b8add245e976bfab96a12986c6843)
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 *  linux/arch/arm/lib/csumpartialcopyuser.S
4 *
5 *  Copyright (C) 1995-1998 Russell King
6 *
7 * 27/03/03 Ian Molton Clean up CONFIG_CPU
8 */
9#include <linux/linkage.h>
10#include <asm/assembler.h>
11#include <asm/errno.h>
12#include <asm/asm-offsets.h>
13
14		.text
15
16#if defined(CONFIG_CPU_SW_DOMAIN_PAN)
17
18		.macro	save_regs
19		mrc	p15, 0, ip, c3, c0, 0
20		stmfd	sp!, {r1, r2, r4 - r8, ip, lr}
21		uaccess_enable ip
22		.endm
23
24		.macro	load_regs
25		ldmfd	sp!, {r1, r2, r4 - r8, ip, lr}
26		mcr	p15, 0, ip, c3, c0, 0
27		ret	lr
28		.endm
29
30#elif defined(CONFIG_CPU_TTBR0_PAN)
31
32		.macro	save_regs
33		mrc	p15, 0, ip, c2, c0, 2		@ read TTBCR
34		stmfd	sp!, {r1, r2, r4 - r8, ip, lr}
35		uaccess_enable ip
36		.endm
37
38		.macro	load_regs
39		ldmfd	sp!, {r1, r2, r4 - r8, ip, lr}
40		mcr	p15, 0, ip, c2, c0, 2		@ restore TTBCR
41		ret	lr
42		.endm
43
44#else
45
46		.macro	save_regs
47		stmfd	sp!, {r1, r2, r4 - r8, lr}
48		.endm
49
50		.macro	load_regs
51		ldmfd	sp!, {r1, r2, r4 - r8, pc}
52		.endm
53
54#endif
55
56		.macro	load1b,	reg1
57		ldrusr	\reg1, r0, 1
58		.endm
59
60		.macro	load2b, reg1, reg2
61		ldrusr	\reg1, r0, 1
62		ldrusr	\reg2, r0, 1
63		.endm
64
65		.macro	load1l, reg1
66		ldrusr	\reg1, r0, 4
67		.endm
68
69		.macro	load2l, reg1, reg2
70		ldrusr	\reg1, r0, 4
71		ldrusr	\reg2, r0, 4
72		.endm
73
74		.macro	load4l, reg1, reg2, reg3, reg4
75		ldrusr	\reg1, r0, 4
76		ldrusr	\reg2, r0, 4
77		ldrusr	\reg3, r0, 4
78		ldrusr	\reg4, r0, 4
79		.endm
80
81/*
82 * unsigned int
83 * csum_partial_copy_from_user(const char *src, char *dst, int len)
84 *  r0 = src, r1 = dst, r2 = len
85 *  Returns : r0 = checksum or 0
86 */
87
88#define FN_ENTRY	ENTRY(csum_partial_copy_from_user)
89#define FN_EXIT		ENDPROC(csum_partial_copy_from_user)
90
91#include "csumpartialcopygeneric.S"
92
93/*
94 * We report fault by returning 0 csum - impossible in normal case, since
95 * we start with 0xffffffff for initial sum.
96 */
97		.pushsection .text.fixup,"ax"
98		.align	4
999001:		mov	r0, #0
100		load_regs
101		.popsection
102