diff options
author | Michal Simek <monstr@monstr.eu> | 2010-03-22 10:25:12 -0400 |
---|---|---|
committer | Michal Simek <monstr@monstr.eu> | 2010-04-01 02:38:20 -0400 |
commit | 8b651aa4a7c047b848f3a7bdf0aba9449e6dc3d3 (patch) | |
tree | b063369b4d17748267e738957518b5a6b995c05a /arch | |
parent | c77a9c4bb7b6e26400853c92d74ccc697c5e2f7e (diff) |
microblaze: uaccess: fix put_user and get_user macros
Use FIXUP macros and resort them.
Signed-off-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/microblaze/include/asm/uaccess.h | 100 |
1 files changed, 49 insertions, 51 deletions
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h index 531172e1d1f3..1e8fa4b76115 100644 --- a/arch/microblaze/include/asm/uaccess.h +++ b/arch/microblaze/include/asm/uaccess.h | |||
@@ -197,16 +197,22 @@ extern long strnlen_user(const char *src, long count); | |||
197 | * already performed before the finction (macro) is called. | 197 | * already performed before the finction (macro) is called. |
198 | */ | 198 | */ |
199 | 199 | ||
200 | #define get_user(x, ptr) \ | 200 | #define __get_user_asm(insn, __gu_ptr, __gu_val, __gu_err) \ |
201 | ({ \ | 201 | ({ \ |
202 | access_ok(VERIFY_READ, (ptr), sizeof(*(ptr))) \ | 202 | __asm__ __volatile__ ( \ |
203 | ? __get_user((x), (ptr)) : -EFAULT; \ | 203 | "1:" insn " %1, %2, r0;" \ |
204 | }) | 204 | " addk %0, r0, r0;" \ |
205 | 205 | "2: " \ | |
206 | #define put_user(x, ptr) \ | 206 | __FIXUP_SECTION \ |
207 | ({ \ | 207 | "3: brid 2b; " \ |
208 | access_ok(VERIFY_WRITE, (ptr), sizeof(*(ptr))) \ | 208 | " addik %0, r0, %3;" \ |
209 | ? __put_user((x), (ptr)) : -EFAULT; \ | 209 | ".previous;" \ |
210 | __EX_TABLE_SECTION \ | ||
211 | ".word 1b,3b;" \ | ||
212 | ".previous;" \ | ||
213 | : "=&r"(__gu_err), "=r"(__gu_val) \ | ||
214 | : "r"(__gu_ptr), "i"(-EFAULT) \ | ||
215 | ); \ | ||
210 | }) | 216 | }) |
211 | 217 | ||
212 | #define __get_user(x, ptr) \ | 218 | #define __get_user(x, ptr) \ |
@@ -231,24 +237,49 @@ extern long strnlen_user(const char *src, long count); | |||
231 | __gu_err; \ | 237 | __gu_err; \ |
232 | }) | 238 | }) |
233 | 239 | ||
234 | #define __get_user_asm(insn, __gu_ptr, __gu_val, __gu_err) \ | 240 | #define get_user(x, ptr) \ |
241 | ({ \ | ||
242 | access_ok(VERIFY_READ, (ptr), sizeof(*(ptr))) \ | ||
243 | ? __get_user((x), (ptr)) : -EFAULT; \ | ||
244 | }) | ||
245 | |||
246 | #define __put_user_asm(insn, __gu_ptr, __gu_val, __gu_err) \ | ||
235 | ({ \ | 247 | ({ \ |
236 | __asm__ __volatile__ ( \ | 248 | __asm__ __volatile__ ( \ |
237 | "1:" insn " %1, %2, r0;" \ | 249 | "1:" insn " %1, %2, r0;" \ |
238 | " addk %0, r0, r0;" \ | 250 | " addk %0, r0, r0;" \ |
239 | "2: " \ | 251 | "2: " \ |
240 | __FIXUP_SECTION \ | 252 | __FIXUP_SECTION \ |
241 | "3: brid 2b; " \ | 253 | "3: brid 2b;" \ |
242 | " addik %0, r0, %3;" \ | 254 | " addik %0, r0, %3;" \ |
243 | ".previous;" \ | 255 | ".previous;" \ |
244 | __EX_TABLE_SECTION \ | 256 | __EX_TABLE_SECTION \ |
245 | ".word 1b,3b;" \ | 257 | ".word 1b,3b;" \ |
246 | ".previous;" \ | 258 | ".previous;" \ |
247 | : "=&r"(__gu_err), "=r"(__gu_val) \ | 259 | : "=&r"(__gu_err) \ |
248 | : "r"(__gu_ptr), "i"(-EFAULT) \ | 260 | : "r"(__gu_val), "r"(__gu_ptr), "i"(-EFAULT) \ |
249 | ); \ | 261 | ); \ |
250 | }) | 262 | }) |
251 | 263 | ||
264 | #define __put_user_asm_8(__gu_ptr, __gu_val, __gu_err) \ | ||
265 | ({ \ | ||
266 | __asm__ __volatile__ (" lwi %0, %1, 0;" \ | ||
267 | "1: swi %0, %2, 0;" \ | ||
268 | " lwi %0, %1, 4;" \ | ||
269 | "2: swi %0, %2, 4;" \ | ||
270 | " addk %0, r0, r0;" \ | ||
271 | "3: " \ | ||
272 | __FIXUP_SECTION \ | ||
273 | "4: brid 3b;" \ | ||
274 | " addik %0, r0, %3;" \ | ||
275 | ".previous;" \ | ||
276 | __EX_TABLE_SECTION \ | ||
277 | ".word 1b,4b,2b,4b;" \ | ||
278 | ".previous;" \ | ||
279 | : "=&r"(__gu_err) \ | ||
280 | : "r"(&__gu_val), "r"(__gu_ptr), "i"(-EFAULT) \ | ||
281 | ); \ | ||
282 | }) | ||
252 | 283 | ||
253 | #define __put_user(x, ptr) \ | 284 | #define __put_user(x, ptr) \ |
254 | ({ \ | 285 | ({ \ |
@@ -273,43 +304,10 @@ extern long strnlen_user(const char *src, long count); | |||
273 | __gu_err; \ | 304 | __gu_err; \ |
274 | }) | 305 | }) |
275 | 306 | ||
276 | #define __put_user_asm_8(__gu_ptr, __gu_val, __gu_err) \ | 307 | #define put_user(x, ptr) \ |
277 | ({ \ | 308 | ({ \ |
278 | __asm__ __volatile__ (" lwi %0, %1, 0; \ | 309 | access_ok(VERIFY_WRITE, (ptr), sizeof(*(ptr))) \ |
279 | 1: swi %0, %2, 0; \ | 310 | ? __put_user((x), (ptr)) : -EFAULT; \ |
280 | lwi %0, %1, 4; \ | ||
281 | 2: swi %0, %2, 4; \ | ||
282 | addk %0,r0,r0; \ | ||
283 | 3: \ | ||
284 | .section .fixup,\"ax\"; \ | ||
285 | 4: brid 3b; \ | ||
286 | addik %0, r0, %3; \ | ||
287 | .previous; \ | ||
288 | .section __ex_table,\"a\"; \ | ||
289 | .word 1b,4b,2b,4b; \ | ||
290 | .previous;" \ | ||
291 | : "=&r"(__gu_err) \ | ||
292 | : "r"(&__gu_val), \ | ||
293 | "r"(__gu_ptr), "i"(-EFAULT) \ | ||
294 | ); \ | ||
295 | }) | ||
296 | |||
297 | #define __put_user_asm(insn, __gu_ptr, __gu_val, __gu_err) \ | ||
298 | ({ \ | ||
299 | __asm__ __volatile__ ( \ | ||
300 | "1:" insn " %1, %2, r0; \ | ||
301 | addk %0, r0, r0; \ | ||
302 | 2: \ | ||
303 | .section .fixup,\"ax\"; \ | ||
304 | 3: brid 2b; \ | ||
305 | addik %0, r0, %3; \ | ||
306 | .previous; \ | ||
307 | .section __ex_table,\"a\"; \ | ||
308 | .word 1b,3b; \ | ||
309 | .previous;" \ | ||
310 | : "=r"(__gu_err) \ | ||
311 | : "r"(__gu_val), "r"(__gu_ptr), "i"(-EFAULT) \ | ||
312 | ); \ | ||
313 | }) | 311 | }) |
314 | 312 | ||
315 | /* Return: number of not copied bytes, i.e. 0 if OK or non-zero if fail. */ | 313 | /* Return: number of not copied bytes, i.e. 0 if OK or non-zero if fail. */ |