Vineet Gupta | 4adeefe | 2013-01-18 15:12:18 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | * |
| 8 | * Amit Bhor, Kanika Nema: Codito Technologies 2004 |
| 9 | */ |
| 10 | |
| 11 | #include <linux/errno.h> |
| 12 | #include <linux/module.h> |
| 13 | #include <linux/sched.h> |
| 14 | #include <linux/mm.h> |
| 15 | #include <linux/fs.h> |
| 16 | #include <linux/unistd.h> |
| 17 | #include <linux/ptrace.h> |
| 18 | #include <linux/slab.h> |
| 19 | #include <linux/syscalls.h> |
| 20 | #include <linux/elf.h> |
| 21 | #include <linux/tick.h> |
| 22 | |
| 23 | SYSCALL_DEFINE1(arc_settls, void *, user_tls_data_ptr) |
| 24 | { |
| 25 | task_thread_info(current)->thr_ptr = (unsigned int)user_tls_data_ptr; |
| 26 | return 0; |
| 27 | } |
| 28 | |
| 29 | /* |
| 30 | * We return the user space TLS data ptr as sys-call return code |
| 31 | * Ideally it should be copy to user. |
| 32 | * However we can cheat by the fact that some sys-calls do return |
| 33 | * absurdly high values |
| 34 | * Since the tls dat aptr is not going to be in range of 0xFFFF_xxxx |
| 35 | * it won't be considered a sys-call error |
| 36 | * and it will be loads better than copy-to-user, which is a definite |
| 37 | * D-TLB Miss |
| 38 | */ |
| 39 | SYSCALL_DEFINE0(arc_gettls) |
| 40 | { |
| 41 | return task_thread_info(current)->thr_ptr; |
| 42 | } |