blob: 6928781e6beebcf3aab564ef0a52461e3ad43e92 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * linux/arch/arm/lib/csumpartialcopyuser.S
4 *
5 * Copyright (C) 1995-1998 Russell King
6 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * 27/03/03 Ian Molton Clean up CONFIG_CPU
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 */
9#include <linux/linkage.h>
10#include <asm/assembler.h>
11#include <asm/errno.h>
Sam Ravnborge6ae7442005-09-09 21:08:59 +020012#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
14 .text
15
Russell Kinga5e090a2015-08-19 20:40:41 +010016#ifdef CONFIG_CPU_SW_DOMAIN_PAN
17 .macro save_regs
18 mrc p15, 0, ip, c3, c0, 0
19 stmfd sp!, {r1, r2, r4 - r8, ip, lr}
20 uaccess_enable ip
21 .endm
22
23 .macro load_regs
24 ldmfd sp!, {r1, r2, r4 - r8, ip, lr}
25 mcr p15, 0, ip, c3, c0, 0
26 ret lr
27 .endm
28#else
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 .macro save_regs
Catalin Marinas22acc4e2008-08-29 18:31:27 +010030 stmfd sp!, {r1, r2, r4 - r8, lr}
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 .endm
32
Catalin Marinas90303b12006-01-12 16:53:51 +000033 .macro load_regs
Catalin Marinas22acc4e2008-08-29 18:31:27 +010034 ldmfd sp!, {r1, r2, r4 - r8, pc}
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 .endm
Russell Kinga5e090a2015-08-19 20:40:41 +010036#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
38 .macro load1b, reg1
Catalin Marinas8b592782009-07-24 12:32:57 +010039 ldrusr \reg1, r0, 1
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 .endm
41
42 .macro load2b, reg1, reg2
Catalin Marinas8b592782009-07-24 12:32:57 +010043 ldrusr \reg1, r0, 1
44 ldrusr \reg2, r0, 1
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 .endm
46
47 .macro load1l, reg1
Catalin Marinas8b592782009-07-24 12:32:57 +010048 ldrusr \reg1, r0, 4
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 .endm
50
51 .macro load2l, reg1, reg2
Catalin Marinas8b592782009-07-24 12:32:57 +010052 ldrusr \reg1, r0, 4
53 ldrusr \reg2, r0, 4
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 .endm
55
56 .macro load4l, reg1, reg2, reg3, reg4
Catalin Marinas8b592782009-07-24 12:32:57 +010057 ldrusr \reg1, r0, 4
58 ldrusr \reg2, r0, 4
59 ldrusr \reg3, r0, 4
60 ldrusr \reg4, r0, 4
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 .endm
62
63/*
64 * unsigned int
Al Viro1d60be32020-07-12 22:56:34 -040065 * csum_partial_copy_from_user(const char *src, char *dst, int len)
66 * r0 = src, r1 = dst, r2 = len
67 * Returns : r0 = checksum or 0
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 */
69
70#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
Catalin Marinas93ed3972008-08-28 11:22:32 +010071#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73#include "csumpartialcopygeneric.S"
74
75/*
Al Viro1d60be32020-07-12 22:56:34 -040076 * We report fault by returning 0 csum - impossible in normal case, since
77 * we start with 0xffffffff for initial sum.
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 */
Ard Biesheuvelc4a84ae2015-03-24 10:41:09 +010079 .pushsection .text.fixup,"ax"
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 .align 4
Al Viro1d60be32020-07-12 22:56:34 -0400819001: mov r0, #0
Catalin Marinas90303b12006-01-12 16:53:51 +000082 load_regs
Russell King42604152010-04-19 10:15:03 +010083 .popsection