process_64.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. /*
  2. * Copyright (C) 1995 Linus Torvalds
  3. *
  4. * Pentium III FXSR, SSE support
  5. * Gareth Hughes <gareth@valinux.com>, May 2000
  6. *
  7. * X86-64 port
  8. * Andi Kleen.
  9. *
  10. * CPU hotplug support - ashok.raj@intel.com
  11. */
  12. /*
  13. * This file handles the architecture-dependent parts of process handling..
  14. */
  15. #include <linux/stackprotector.h>
  16. #include <linux/cpu.h>
  17. #include <linux/errno.h>
  18. #include <linux/sched.h>
  19. #include <linux/fs.h>
  20. #include <linux/kernel.h>
  21. #include <linux/mm.h>
  22. #include <linux/elfcore.h>
  23. #include <linux/smp.h>
  24. #include <linux/slab.h>
  25. #include <linux/user.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/utsname.h>
  28. #include <linux/delay.h>
  29. #include <linux/module.h>
  30. #include <linux/ptrace.h>
  31. #include <linux/notifier.h>
  32. #include <linux/kprobes.h>
  33. #include <linux/kdebug.h>
  34. #include <linux/tick.h>
  35. #include <linux/prctl.h>
  36. #include <linux/uaccess.h>
  37. #include <linux/io.h>
  38. #include <linux/ftrace.h>
  39. #include <linux/dmi.h>
  40. #include <asm/pgtable.h>
  41. #include <asm/system.h>
  42. #include <asm/processor.h>
  43. #include <asm/i387.h>
  44. #include <asm/mmu_context.h>
  45. #include <asm/prctl.h>
  46. #include <asm/desc.h>
  47. #include <asm/proto.h>
  48. #include <asm/ia32.h>
  49. #include <asm/idle.h>
  50. #include <asm/syscalls.h>
  51. #include <asm/ds.h>
  52. asmlinkage extern void ret_from_fork(void);
  53. DEFINE_PER_CPU(struct task_struct *, current_task) = &init_task;
  54. EXPORT_PER_CPU_SYMBOL(current_task);
  55. DEFINE_PER_CPU(unsigned long, old_rsp);
  56. static DEFINE_PER_CPU(unsigned char, is_idle);
  57. unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED;
  58. static ATOMIC_NOTIFIER_HEAD(idle_notifier);
  59. void idle_notifier_register(struct notifier_block *n)
  60. {
  61. atomic_notifier_chain_register(&idle_notifier, n);
  62. }
  63. EXPORT_SYMBOL_GPL(idle_notifier_register);
  64. void idle_notifier_unregister(struct notifier_block *n)
  65. {
  66. atomic_notifier_chain_unregister(&idle_notifier, n);
  67. }
  68. EXPORT_SYMBOL_GPL(idle_notifier_unregister);
  69. void enter_idle(void)
  70. {
  71. percpu_write(is_idle, 1);
  72. atomic_notifier_call_chain(&idle_notifier, IDLE_START, NULL);
  73. }
  74. static void __exit_idle(void)
  75. {
  76. if (x86_test_and_clear_bit_percpu(0, is_idle) == 0)
  77. return;
  78. atomic_notifier_call_chain(&idle_notifier, IDLE_END, NULL);
  79. }
  80. /* Called from interrupts to signify idle end */
  81. void exit_idle(void)
  82. {
  83. /* idle loop has pid 0 */
  84. if (current->pid)
  85. return;
  86. __exit_idle();
  87. }
  88. #ifndef CONFIG_SMP
  89. static inline void play_dead(void)
  90. {
  91. BUG();
  92. }
  93. #endif
  94. /*
  95. * The idle thread. There's no useful work to be
  96. * done, so just try to conserve power and have a
  97. * low exit latency (ie sit in a loop waiting for
  98. * somebody to say that they'd like to reschedule)
  99. */
  100. void cpu_idle(void)
  101. {
  102. current_thread_info()->status |= TS_POLLING;
  103. /*
  104. * If we're the non-boot CPU, nothing set the stack canary up
  105. * for us. CPU0 already has it initialized but no harm in
  106. * doing it again. This is a good place for updating it, as
  107. * we wont ever return from this function (so the invalid
  108. * canaries already on the stack wont ever trigger).
  109. */
  110. boot_init_stack_canary();
  111. /* endless idle loop with no priority at all */
  112. while (1) {
  113. tick_nohz_stop_sched_tick(1);
  114. while (!need_resched()) {
  115. rmb();
  116. if (cpu_is_offline(smp_processor_id()))
  117. play_dead();
  118. /*
  119. * Idle routines should keep interrupts disabled
  120. * from here on, until they go to idle.
  121. * Otherwise, idle callbacks can misfire.
  122. */
  123. local_irq_disable();
  124. enter_idle();
  125. /* Don't trace irqs off for idle */
  126. stop_critical_timings();
  127. pm_idle();
  128. start_critical_timings();
  129. /* In many cases the interrupt that ended idle
  130. has already called exit_idle. But some idle
  131. loops can be woken up without interrupt. */
  132. __exit_idle();
  133. }
  134. tick_nohz_restart_sched_tick();
  135. preempt_enable_no_resched();
  136. schedule();
  137. preempt_disable();
  138. }
  139. }
  140. /* Prints also some state that isn't saved in the pt_regs */
  141. void __show_regs(struct pt_regs *regs, int all)
  142. {
  143. unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L, fs, gs, shadowgs;
  144. unsigned long d0, d1, d2, d3, d6, d7;
  145. unsigned int fsindex, gsindex;
  146. unsigned int ds, cs, es;
  147. const char *board;
  148. printk("\n");
  149. print_modules();
  150. board = dmi_get_system_info(DMI_PRODUCT_NAME);
  151. if (!board)
  152. board = "";
  153. printk(KERN_INFO "Pid: %d, comm: %.20s %s %s %.*s %s\n",
  154. current->pid, current->comm, print_tainted(),
  155. init_utsname()->release,
  156. (int)strcspn(init_utsname()->version, " "),
  157. init_utsname()->version, board);
  158. printk(KERN_INFO "RIP: %04lx:[<%016lx>] ", regs->cs & 0xffff, regs->ip);
  159. printk_address(regs->ip, 1);
  160. printk(KERN_INFO "RSP: %04lx:%016lx EFLAGS: %08lx\n", regs->ss,
  161. regs->sp, regs->flags);
  162. printk(KERN_INFO "RAX: %016lx RBX: %016lx RCX: %016lx\n",
  163. regs->ax, regs->bx, regs->cx);
  164. printk(KERN_INFO "RDX: %016lx RSI: %016lx RDI: %016lx\n",
  165. regs->dx, regs->si, regs->di);
  166. printk(KERN_INFO "RBP: %016lx R08: %016lx R09: %016lx\n",
  167. regs->bp, regs->r8, regs->r9);
  168. printk(KERN_INFO "R10: %016lx R11: %016lx R12: %016lx\n",
  169. regs->r10, regs->r11, regs->r12);
  170. printk(KERN_INFO "R13: %016lx R14: %016lx R15: %016lx\n",
  171. regs->r13, regs->r14, regs->r15);
  172. asm("movl %%ds,%0" : "=r" (ds));
  173. asm("movl %%cs,%0" : "=r" (cs));
  174. asm("movl %%es,%0" : "=r" (es));
  175. asm("movl %%fs,%0" : "=r" (fsindex));
  176. asm("movl %%gs,%0" : "=r" (gsindex));
  177. rdmsrl(MSR_FS_BASE, fs);
  178. rdmsrl(MSR_GS_BASE, gs);
  179. rdmsrl(MSR_KERNEL_GS_BASE, shadowgs);
  180. if (!all)
  181. return;
  182. cr0 = read_cr0();
  183. cr2 = read_cr2();
  184. cr3 = read_cr3();
  185. cr4 = read_cr4();
  186. printk(KERN_INFO "FS: %016lx(%04x) GS:%016lx(%04x) knlGS:%016lx\n",
  187. fs, fsindex, gs, gsindex, shadowgs);
  188. printk(KERN_INFO "CS: %04x DS: %04x ES: %04x CR0: %016lx\n", cs, ds,
  189. es, cr0);
  190. printk(KERN_INFO "CR2: %016lx CR3: %016lx CR4: %016lx\n", cr2, cr3,
  191. cr4);
  192. get_debugreg(d0, 0);
  193. get_debugreg(d1, 1);
  194. get_debugreg(d2, 2);
  195. printk(KERN_INFO "DR0: %016lx DR1: %016lx DR2: %016lx\n", d0, d1, d2);
  196. get_debugreg(d3, 3);
  197. get_debugreg(d6, 6);
  198. get_debugreg(d7, 7);
  199. printk(KERN_INFO "DR3: %016lx DR6: %016lx DR7: %016lx\n", d3, d6, d7);
  200. }
  201. void show_regs(struct pt_regs *regs)
  202. {
  203. printk(KERN_INFO "CPU %d:", smp_processor_id());
  204. __show_regs(regs, 1);
  205. show_trace(NULL, regs, (void *)(regs + 1), regs->bp);
  206. }
  207. void release_thread(struct task_struct *dead_task)
  208. {
  209. if (dead_task->mm) {
  210. if (dead_task->mm->context.size) {
  211. printk("WARNING: dead process %8s still has LDT? <%p/%d>\n",
  212. dead_task->comm,
  213. dead_task->mm->context.ldt,
  214. dead_task->mm->context.size);
  215. BUG();
  216. }
  217. }
  218. }
  219. static inline void set_32bit_tls(struct task_struct *t, int tls, u32 addr)
  220. {
  221. struct user_desc ud = {
  222. .base_addr = addr,
  223. .limit = 0xfffff,
  224. .seg_32bit = 1,
  225. .limit_in_pages = 1,
  226. .useable = 1,
  227. };
  228. struct desc_struct *desc = t->thread.tls_array;
  229. desc += tls;
  230. fill_ldt(desc, &ud);
  231. }
  232. static inline u32 read_32bit_tls(struct task_struct *t, int tls)
  233. {
  234. return get_desc_base(&t->thread.tls_array[tls]);
  235. }
  236. /*
  237. * This gets called before we allocate a new thread and copy
  238. * the current task into it.
  239. */
  240. void prepare_to_copy(struct task_struct *tsk)
  241. {
  242. unlazy_fpu(tsk);
  243. }
  244. int copy_thread(unsigned long clone_flags, unsigned long sp,
  245. unsigned long unused,
  246. struct task_struct *p, struct pt_regs *regs)
  247. {
  248. int err;
  249. struct pt_regs *childregs;
  250. struct task_struct *me = current;
  251. childregs = ((struct pt_regs *)
  252. (THREAD_SIZE + task_stack_page(p))) - 1;
  253. *childregs = *regs;
  254. childregs->ax = 0;
  255. childregs->sp = sp;
  256. if (sp == ~0UL)
  257. childregs->sp = (unsigned long)childregs;
  258. p->thread.sp = (unsigned long) childregs;
  259. p->thread.sp0 = (unsigned long) (childregs+1);
  260. p->thread.usersp = me->thread.usersp;
  261. set_tsk_thread_flag(p, TIF_FORK);
  262. p->thread.fs = me->thread.fs;
  263. p->thread.gs = me->thread.gs;
  264. savesegment(gs, p->thread.gsindex);
  265. savesegment(fs, p->thread.fsindex);
  266. savesegment(es, p->thread.es);
  267. savesegment(ds, p->thread.ds);
  268. if (unlikely(test_tsk_thread_flag(me, TIF_IO_BITMAP))) {
  269. p->thread.io_bitmap_ptr = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL);
  270. if (!p->thread.io_bitmap_ptr) {
  271. p->thread.io_bitmap_max = 0;
  272. return -ENOMEM;
  273. }
  274. memcpy(p->thread.io_bitmap_ptr, me->thread.io_bitmap_ptr,
  275. IO_BITMAP_BYTES);
  276. set_tsk_thread_flag(p, TIF_IO_BITMAP);
  277. }
  278. /*
  279. * Set a new TLS for the child thread?
  280. */
  281. if (clone_flags & CLONE_SETTLS) {
  282. #ifdef CONFIG_IA32_EMULATION
  283. if (test_thread_flag(TIF_IA32))
  284. err = do_set_thread_area(p, -1,
  285. (struct user_desc __user *)childregs->si, 0);
  286. else
  287. #endif
  288. err = do_arch_prctl(p, ARCH_SET_FS, childregs->r8);
  289. if (err)
  290. goto out;
  291. }
  292. clear_tsk_thread_flag(p, TIF_DS_AREA_MSR);
  293. p->thread.ds_ctx = NULL;
  294. clear_tsk_thread_flag(p, TIF_DEBUGCTLMSR);
  295. p->thread.debugctlmsr = 0;
  296. err = 0;
  297. out:
  298. if (err && p->thread.io_bitmap_ptr) {
  299. kfree(p->thread.io_bitmap_ptr);
  300. p->thread.io_bitmap_max = 0;
  301. }
  302. return err;
  303. }
  304. void
  305. start_thread(struct pt_regs *regs, unsigned long new_ip, unsigned long new_sp)
  306. {
  307. loadsegment(fs, 0);
  308. loadsegment(es, 0);
  309. loadsegment(ds, 0);
  310. load_gs_index(0);
  311. regs->ip = new_ip;
  312. regs->sp = new_sp;
  313. percpu_write(old_rsp, new_sp);
  314. regs->cs = __USER_CS;
  315. regs->ss = __USER_DS;
  316. regs->flags = 0x200;
  317. set_fs(USER_DS);
  318. /*
  319. * Free the old FP and other extended state
  320. */
  321. free_thread_xstate(current);
  322. }
  323. EXPORT_SYMBOL_GPL(start_thread);
  324. /*
  325. * switch_to(x,y) should switch tasks from x to y.
  326. *
  327. * This could still be optimized:
  328. * - fold all the options into a flag word and test it with a single test.
  329. * - could test fs/gs bitsliced
  330. *
  331. * Kprobes not supported here. Set the probe on schedule instead.
  332. * Function graph tracer not supported too.
  333. */
  334. __notrace_funcgraph struct task_struct *
  335. __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
  336. {
  337. struct thread_struct *prev = &prev_p->thread;
  338. struct thread_struct *next = &next_p->thread;
  339. int cpu = smp_processor_id();
  340. struct tss_struct *tss = &per_cpu(init_tss, cpu);
  341. unsigned fsindex, gsindex;
  342. /* we're going to use this soon, after a few expensive things */
  343. if (next_p->fpu_counter > 5)
  344. prefetch(next->xstate);
  345. /*
  346. * Reload esp0, LDT and the page table pointer:
  347. */
  348. load_sp0(tss, next);
  349. /*
  350. * Switch DS and ES.
  351. * This won't pick up thread selector changes, but I guess that is ok.
  352. */
  353. savesegment(es, prev->es);
  354. if (unlikely(next->es | prev->es))
  355. loadsegment(es, next->es);
  356. savesegment(ds, prev->ds);
  357. if (unlikely(next->ds | prev->ds))
  358. loadsegment(ds, next->ds);
  359. /* We must save %fs and %gs before load_TLS() because
  360. * %fs and %gs may be cleared by load_TLS().
  361. *
  362. * (e.g. xen_load_tls())
  363. */
  364. savesegment(fs, fsindex);
  365. savesegment(gs, gsindex);
  366. load_TLS(next, cpu);
  367. /*
  368. * Leave lazy mode, flushing any hypercalls made here.
  369. * This must be done before restoring TLS segments so
  370. * the GDT and LDT are properly updated, and must be
  371. * done before math_state_restore, so the TS bit is up
  372. * to date.
  373. */
  374. arch_end_context_switch(next_p);
  375. /*
  376. * Switch FS and GS.
  377. *
  378. * Segment register != 0 always requires a reload. Also
  379. * reload when it has changed. When prev process used 64bit
  380. * base always reload to avoid an information leak.
  381. */
  382. if (unlikely(fsindex | next->fsindex | prev->fs)) {
  383. loadsegment(fs, next->fsindex);
  384. /*
  385. * Check if the user used a selector != 0; if yes
  386. * clear 64bit base, since overloaded base is always
  387. * mapped to the Null selector
  388. */
  389. if (fsindex)
  390. prev->fs = 0;
  391. }
  392. /* when next process has a 64bit base use it */
  393. if (next->fs)
  394. wrmsrl(MSR_FS_BASE, next->fs);
  395. prev->fsindex = fsindex;
  396. if (unlikely(gsindex | next->gsindex | prev->gs)) {
  397. load_gs_index(next->gsindex);
  398. if (gsindex)
  399. prev->gs = 0;
  400. }
  401. if (next->gs)
  402. wrmsrl(MSR_KERNEL_GS_BASE, next->gs);
  403. prev->gsindex = gsindex;
  404. /* Must be after DS reload */
  405. unlazy_fpu(prev_p);
  406. /*
  407. * Switch the PDA and FPU contexts.
  408. */
  409. prev->usersp = percpu_read(old_rsp);
  410. percpu_write(old_rsp, next->usersp);
  411. percpu_write(current_task, next_p);
  412. percpu_write(kernel_stack,
  413. (unsigned long)task_stack_page(next_p) +
  414. THREAD_SIZE - KERNEL_STACK_OFFSET);
  415. /*
  416. * Now maybe reload the debug registers and handle I/O bitmaps
  417. */
  418. if (unlikely(task_thread_info(next_p)->flags & _TIF_WORK_CTXSW_NEXT ||
  419. task_thread_info(prev_p)->flags & _TIF_WORK_CTXSW_PREV))
  420. __switch_to_xtra(prev_p, next_p, tss);
  421. /* If the task has used fpu the last 5 timeslices, just do a full
  422. * restore of the math state immediately to avoid the trap; the
  423. * chances of needing FPU soon are obviously high now
  424. *
  425. * tsk_used_math() checks prevent calling math_state_restore(),
  426. * which can sleep in the case of !tsk_used_math()
  427. */
  428. if (tsk_used_math(next_p) && next_p->fpu_counter > 5)
  429. math_state_restore();
  430. return prev_p;
  431. }
  432. /*
  433. * sys_execve() executes a new program.
  434. */
  435. asmlinkage
  436. long sys_execve(char __user *name, char __user * __user *argv,
  437. char __user * __user *envp, struct pt_regs *regs)
  438. {
  439. long error;
  440. char *filename;
  441. filename = getname(name);
  442. error = PTR_ERR(filename);
  443. if (IS_ERR(filename))
  444. return error;
  445. error = do_execve(filename, argv, envp, regs);
  446. putname(filename);
  447. return error;
  448. }
  449. void set_personality_64bit(void)
  450. {
  451. /* inherit personality from parent */
  452. /* Make sure to be in 64bit mode */
  453. clear_thread_flag(TIF_IA32);
  454. /* TBD: overwrites user setup. Should have two bits.
  455. But 64bit processes have always behaved this way,
  456. so it's not too bad. The main problem is just that
  457. 32bit childs are affected again. */
  458. current->personality &= ~READ_IMPLIES_EXEC;
  459. }
  460. asmlinkage long
  461. sys_clone(unsigned long clone_flags, unsigned long newsp,
  462. void __user *parent_tid, void __user *child_tid, struct pt_regs *regs)
  463. {
  464. if (!newsp)
  465. newsp = regs->sp;
  466. return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
  467. }
  468. unsigned long get_wchan(struct task_struct *p)
  469. {
  470. unsigned long stack;
  471. u64 fp, ip;
  472. int count = 0;
  473. if (!p || p == current || p->state == TASK_RUNNING)
  474. return 0;
  475. stack = (unsigned long)task_stack_page(p);
  476. if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
  477. return 0;
  478. fp = *(u64 *)(p->thread.sp);
  479. do {
  480. if (fp < (unsigned long)stack ||
  481. fp >= (unsigned long)stack+THREAD_SIZE)
  482. return 0;
  483. ip = *(u64 *)(fp+8);
  484. if (!in_sched_functions(ip))
  485. return ip;
  486. fp = *(u64 *)fp;
  487. } while (count++ < 16);
  488. return 0;
  489. }
  490. long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
  491. {
  492. int ret = 0;
  493. int doit = task == current;
  494. int cpu;
  495. switch (code) {
  496. case ARCH_SET_GS:
  497. if (addr >= TASK_SIZE_OF(task))
  498. return -EPERM;
  499. cpu = get_cpu();
  500. /* handle small bases via the GDT because that's faster to
  501. switch. */
  502. if (addr <= 0xffffffff) {
  503. set_32bit_tls(task, GS_TLS, addr);
  504. if (doit) {
  505. load_TLS(&task->thread, cpu);
  506. load_gs_index(GS_TLS_SEL);
  507. }
  508. task->thread.gsindex = GS_TLS_SEL;
  509. task->thread.gs = 0;
  510. } else {
  511. task->thread.gsindex = 0;
  512. task->thread.gs = addr;
  513. if (doit) {
  514. load_gs_index(0);
  515. ret = checking_wrmsrl(MSR_KERNEL_GS_BASE, addr);
  516. }
  517. }
  518. put_cpu();
  519. break;
  520. case ARCH_SET_FS:
  521. /* Not strictly needed for fs, but do it for symmetry
  522. with gs */
  523. if (addr >= TASK_SIZE_OF(task))
  524. return -EPERM;
  525. cpu = get_cpu();
  526. /* handle small bases via the GDT because that's faster to
  527. switch. */
  528. if (addr <= 0xffffffff) {
  529. set_32bit_tls(task, FS_TLS, addr);
  530. if (doit) {
  531. load_TLS(&task->thread, cpu);
  532. loadsegment(fs, FS_TLS_SEL);
  533. }
  534. task->thread.fsindex = FS_TLS_SEL;
  535. task->thread.fs = 0;
  536. } else {
  537. task->thread.fsindex = 0;
  538. task->thread.fs = addr;
  539. if (doit) {
  540. /* set the selector to 0 to not confuse
  541. __switch_to */
  542. loadsegment(fs, 0);
  543. ret = checking_wrmsrl(MSR_FS_BASE, addr);
  544. }
  545. }
  546. put_cpu();
  547. break;
  548. case ARCH_GET_FS: {
  549. unsigned long base;
  550. if (task->thread.fsindex == FS_TLS_SEL)
  551. base = read_32bit_tls(task, FS_TLS);
  552. else if (doit)
  553. rdmsrl(MSR_FS_BASE, base);
  554. else
  555. base = task->thread.fs;
  556. ret = put_user(base, (unsigned long __user *)addr);
  557. break;
  558. }
  559. case ARCH_GET_GS: {
  560. unsigned long base;
  561. unsigned gsindex;
  562. if (task->thread.gsindex == GS_TLS_SEL)
  563. base = read_32bit_tls(task, GS_TLS);
  564. else if (doit) {
  565. savesegment(gs, gsindex);
  566. if (gsindex)
  567. rdmsrl(MSR_KERNEL_GS_BASE, base);
  568. else
  569. base = task->thread.gs;
  570. } else
  571. base = task->thread.gs;
  572. ret = put_user(base, (unsigned long __user *)addr);
  573. break;
  574. }
  575. default:
  576. ret = -EINVAL;
  577. break;
  578. }
  579. return ret;
  580. }
  581. long sys_arch_prctl(int code, unsigned long addr)
  582. {
  583. return do_arch_prctl(current, code, addr);
  584. }