aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2016-09-04 14:26:36 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2016-09-27 21:15:21 -0400
commit76580237d13fbfcd55acbc8fdd6726be7080a275 (patch)
treea9fb9054672631ac64819eab73778614fcac1ffb
parent4ad41c1e2616a64c9e789d7069b1cb3402d2af3a (diff)
xtensa: split uaccess.h into C and asm sides
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--arch/xtensa/include/asm/asm-uaccess.h160
-rw-r--r--arch/xtensa/include/asm/uaccess.h142
-rw-r--r--arch/xtensa/kernel/coprocessor.S2
-rw-r--r--arch/xtensa/kernel/entry.S2
4 files changed, 162 insertions, 144 deletions
diff --git a/arch/xtensa/include/asm/asm-uaccess.h b/arch/xtensa/include/asm/asm-uaccess.h
new file mode 100644
index 000000000000..a7a110039786
--- /dev/null
+++ b/arch/xtensa/include/asm/asm-uaccess.h
@@ -0,0 +1,160 @@
1/*
2 * include/asm-xtensa/uaccess.h
3 *
4 * User space memory access functions
5 *
6 * These routines provide basic accessing functions to the user memory
7 * space for the kernel. This header file provides functions such as:
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 *
13 * Copyright (C) 2001 - 2005 Tensilica Inc.
14 */
15
16#ifndef _XTENSA_ASM_UACCESS_H
17#define _XTENSA_ASM_UACCESS_H
18
19#include <linux/errno.h>
20#include <asm/types.h>
21
22#define VERIFY_READ 0
23#define VERIFY_WRITE 1
24
25#include <asm/current.h>
26#include <asm/asm-offsets.h>
27#include <asm/processor.h>
28
29/*
30 * These assembly macros mirror the C macros in asm/uaccess.h. They
31 * should always have identical functionality. See
32 * arch/xtensa/kernel/sys.S for usage.
33 */
34
35#define KERNEL_DS 0
36#define USER_DS 1
37
38#define get_ds (KERNEL_DS)
39
40/*
41 * get_fs reads current->thread.current_ds into a register.
42 * On Entry:
43 * <ad> anything
44 * <sp> stack
45 * On Exit:
46 * <ad> contains current->thread.current_ds
47 */
48 .macro get_fs ad, sp
49 GET_CURRENT(\ad,\sp)
50#if THREAD_CURRENT_DS > 1020
51 addi \ad, \ad, TASK_THREAD
52 l32i \ad, \ad, THREAD_CURRENT_DS - TASK_THREAD
53#else
54 l32i \ad, \ad, THREAD_CURRENT_DS
55#endif
56 .endm
57
58/*
59 * set_fs sets current->thread.current_ds to some value.
60 * On Entry:
61 * <at> anything (temp register)
62 * <av> value to write
63 * <sp> stack
64 * On Exit:
65 * <at> destroyed (actually, current)
66 * <av> preserved, value to write
67 */
68 .macro set_fs at, av, sp
69 GET_CURRENT(\at,\sp)
70 s32i \av, \at, THREAD_CURRENT_DS
71 .endm
72
73/*
74 * kernel_ok determines whether we should bypass addr/size checking.
75 * See the equivalent C-macro version below for clarity.
76 * On success, kernel_ok branches to a label indicated by parameter
77 * <success>. This implies that the macro falls through to the next
78 * insruction on an error.
79 *
80 * Note that while this macro can be used independently, we designed
81 * in for optimal use in the access_ok macro below (i.e., we fall
82 * through on error).
83 *
84 * On Entry:
85 * <at> anything (temp register)
86 * <success> label to branch to on success; implies
87 * fall-through macro on error
88 * <sp> stack pointer
89 * On Exit:
90 * <at> destroyed (actually, current->thread.current_ds)
91 */
92
93#if ((KERNEL_DS != 0) || (USER_DS == 0))
94# error Assembly macro kernel_ok fails
95#endif
96 .macro kernel_ok at, sp, success
97 get_fs \at, \sp
98 beqz \at, \success
99 .endm
100
101/*
102 * user_ok determines whether the access to user-space memory is allowed.
103 * See the equivalent C-macro version below for clarity.
104 *
105 * On error, user_ok branches to a label indicated by parameter
106 * <error>. This implies that the macro falls through to the next
107 * instruction on success.
108 *
109 * Note that while this macro can be used independently, we designed
110 * in for optimal use in the access_ok macro below (i.e., we fall
111 * through on success).
112 *
113 * On Entry:
114 * <aa> register containing memory address
115 * <as> register containing memory size
116 * <at> temp register
117 * <error> label to branch to on error; implies fall-through
118 * macro on success
119 * On Exit:
120 * <aa> preserved
121 * <as> preserved
122 * <at> destroyed (actually, (TASK_SIZE + 1 - size))
123 */
124 .macro user_ok aa, as, at, error
125 movi \at, __XTENSA_UL_CONST(TASK_SIZE)
126 bgeu \as, \at, \error
127 sub \at, \at, \as
128 bgeu \aa, \at, \error
129 .endm
130
131/*
132 * access_ok determines whether a memory access is allowed. See the
133 * equivalent C-macro version below for clarity.
134 *
135 * On error, access_ok branches to a label indicated by parameter
136 * <error>. This implies that the macro falls through to the next
137 * instruction on success.
138 *
139 * Note that we assume success is the common case, and we optimize the
140 * branch fall-through case on success.
141 *
142 * On Entry:
143 * <aa> register containing memory address
144 * <as> register containing memory size
145 * <at> temp register
146 * <sp>
147 * <error> label to branch to on error; implies fall-through
148 * macro on success
149 * On Exit:
150 * <aa> preserved
151 * <as> preserved
152 * <at> destroyed
153 */
154 .macro access_ok aa, as, at, sp, error
155 kernel_ok \at, \sp, .Laccess_ok_\@
156 user_ok \aa, \as, \at, \error
157.Laccess_ok_\@:
158 .endm
159
160#endif /* _XTENSA_ASM_UACCESS_H */
diff --git a/arch/xtensa/include/asm/uaccess.h b/arch/xtensa/include/asm/uaccess.h
index de72ba558d8d..848a3d736bcb 100644
--- a/arch/xtensa/include/asm/uaccess.h
+++ b/arch/xtensa/include/asm/uaccess.h
@@ -17,153 +17,12 @@
17#define _XTENSA_UACCESS_H 17#define _XTENSA_UACCESS_H
18 18
19#include <linux/errno.h> 19#include <linux/errno.h>
20#ifndef __ASSEMBLY__
21#include <linux/prefetch.h> 20#include <linux/prefetch.h>
22#endif
23#include <asm/types.h> 21#include <asm/types.h>
24 22
25#define VERIFY_READ 0 23#define VERIFY_READ 0
26#define VERIFY_WRITE 1 24#define VERIFY_WRITE 1
27 25
28#ifdef __ASSEMBLY__
29
30#include <asm/current.h>
31#include <asm/asm-offsets.h>
32#include <asm/processor.h>
33
34/*
35 * These assembly macros mirror the C macros that follow below. They
36 * should always have identical functionality. See
37 * arch/xtensa/kernel/sys.S for usage.
38 */
39
40#define KERNEL_DS 0
41#define USER_DS 1
42
43#define get_ds (KERNEL_DS)
44
45/*
46 * get_fs reads current->thread.current_ds into a register.
47 * On Entry:
48 * <ad> anything
49 * <sp> stack
50 * On Exit:
51 * <ad> contains current->thread.current_ds
52 */
53 .macro get_fs ad, sp
54 GET_CURRENT(\ad,\sp)
55#if THREAD_CURRENT_DS > 1020
56 addi \ad, \ad, TASK_THREAD
57 l32i \ad, \ad, THREAD_CURRENT_DS - TASK_THREAD
58#else
59 l32i \ad, \ad, THREAD_CURRENT_DS
60#endif
61 .endm
62
63/*
64 * set_fs sets current->thread.current_ds to some value.
65 * On Entry:
66 * <at> anything (temp register)
67 * <av> value to write
68 * <sp> stack
69 * On Exit:
70 * <at> destroyed (actually, current)
71 * <av> preserved, value to write
72 */
73 .macro set_fs at, av, sp
74 GET_CURRENT(\at,\sp)
75 s32i \av, \at, THREAD_CURRENT_DS
76 .endm
77
78/*
79 * kernel_ok determines whether we should bypass addr/size checking.
80 * See the equivalent C-macro version below for clarity.
81 * On success, kernel_ok branches to a label indicated by parameter
82 * <success>. This implies that the macro falls through to the next
83 * insruction on an error.
84 *
85 * Note that while this macro can be used independently, we designed
86 * in for optimal use in the access_ok macro below (i.e., we fall
87 * through on error).
88 *
89 * On Entry:
90 * <at> anything (temp register)
91 * <success> label to branch to on success; implies
92 * fall-through macro on error
93 * <sp> stack pointer
94 * On Exit:
95 * <at> destroyed (actually, current->thread.current_ds)
96 */
97
98#if ((KERNEL_DS != 0) || (USER_DS == 0))
99# error Assembly macro kernel_ok fails
100#endif
101 .macro kernel_ok at, sp, success
102 get_fs \at, \sp
103 beqz \at, \success
104 .endm
105
106/*
107 * user_ok determines whether the access to user-space memory is allowed.
108 * See the equivalent C-macro version below for clarity.
109 *
110 * On error, user_ok branches to a label indicated by parameter
111 * <error>. This implies that the macro falls through to the next
112 * instruction on success.
113 *
114 * Note that while this macro can be used independently, we designed
115 * in for optimal use in the access_ok macro below (i.e., we fall
116 * through on success).
117 *
118 * On Entry:
119 * <aa> register containing memory address
120 * <as> register containing memory size
121 * <at> temp register
122 * <error> label to branch to on error; implies fall-through
123 * macro on success
124 * On Exit:
125 * <aa> preserved
126 * <as> preserved
127 * <at> destroyed (actually, (TASK_SIZE + 1 - size))
128 */
129 .macro user_ok aa, as, at, error
130 movi \at, __XTENSA_UL_CONST(TASK_SIZE)
131 bgeu \as, \at, \error
132 sub \at, \at, \as
133 bgeu \aa, \at, \error
134 .endm
135
136/*
137 * access_ok determines whether a memory access is allowed. See the
138 * equivalent C-macro version below for clarity.
139 *
140 * On error, access_ok branches to a label indicated by parameter
141 * <error>. This implies that the macro falls through to the next
142 * instruction on success.
143 *
144 * Note that we assume success is the common case, and we optimize the
145 * branch fall-through case on success.
146 *
147 * On Entry:
148 * <aa> register containing memory address
149 * <as> register containing memory size
150 * <at> temp register
151 * <sp>
152 * <error> label to branch to on error; implies fall-through
153 * macro on success
154 * On Exit:
155 * <aa> preserved
156 * <as> preserved
157 * <at> destroyed
158 */
159 .macro access_ok aa, as, at, sp, error
160 kernel_ok \at, \sp, .Laccess_ok_\@
161 user_ok \aa, \as, \at, \error
162.Laccess_ok_\@:
163 .endm
164
165#else /* __ASSEMBLY__ not defined */
166
167#include <linux/sched.h> 26#include <linux/sched.h>
168 27
169/* 28/*
@@ -495,5 +354,4 @@ struct exception_table_entry
495 unsigned long insn, fixup; 354 unsigned long insn, fixup;
496}; 355};
497 356
498#endif /* __ASSEMBLY__ */
499#endif /* _XTENSA_UACCESS_H */ 357#endif /* _XTENSA_UACCESS_H */
diff --git a/arch/xtensa/kernel/coprocessor.S b/arch/xtensa/kernel/coprocessor.S
index a482df5df2b2..6911e384f608 100644
--- a/arch/xtensa/kernel/coprocessor.S
+++ b/arch/xtensa/kernel/coprocessor.S
@@ -17,7 +17,7 @@
17#include <asm/processor.h> 17#include <asm/processor.h>
18#include <asm/coprocessor.h> 18#include <asm/coprocessor.h>
19#include <asm/thread_info.h> 19#include <asm/thread_info.h>
20#include <asm/uaccess.h> 20#include <asm/asm-uaccess.h>
21#include <asm/unistd.h> 21#include <asm/unistd.h>
22#include <asm/ptrace.h> 22#include <asm/ptrace.h>
23#include <asm/current.h> 23#include <asm/current.h>
diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S
index fe8f7e7efb9d..a504384b9339 100644
--- a/arch/xtensa/kernel/entry.S
+++ b/arch/xtensa/kernel/entry.S
@@ -17,7 +17,7 @@
17#include <asm/processor.h> 17#include <asm/processor.h>
18#include <asm/coprocessor.h> 18#include <asm/coprocessor.h>
19#include <asm/thread_info.h> 19#include <asm/thread_info.h>
20#include <asm/uaccess.h> 20#include <asm/asm-uaccess.h>
21#include <asm/unistd.h> 21#include <asm/unistd.h>
22#include <asm/ptrace.h> 22#include <asm/ptrace.h>
23#include <asm/current.h> 23#include <asm/current.h>