process.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1994 - 1999, 2000 by Ralf Baechle and others.
  7. * Copyright (C) 2005, 2006 by Ralf Baechle (ralf@linux-mips.org)
  8. * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  9. * Copyright (C) 2004 Thiemo Seufer
  10. * Copyright (C) 2013 Imagination Technologies Ltd.
  11. */
  12. #include <linux/errno.h>
  13. #include <linux/sched.h>
  14. #include <linux/tick.h>
  15. #include <linux/kernel.h>
  16. #include <linux/mm.h>
  17. #include <linux/stddef.h>
  18. #include <linux/unistd.h>
  19. #include <linux/export.h>
  20. #include <linux/ptrace.h>
  21. #include <linux/mman.h>
  22. #include <linux/personality.h>
  23. #include <linux/sys.h>
  24. #include <linux/init.h>
  25. #include <linux/completion.h>
  26. #include <linux/kallsyms.h>
  27. #include <linux/random.h>
  28. #include <linux/prctl.h>
  29. #include <asm/asm.h>
  30. #include <asm/bootinfo.h>
  31. #include <asm/cpu.h>
  32. #include <asm/dsp.h>
  33. #include <asm/fpu.h>
  34. #include <asm/msa.h>
  35. #include <asm/pgtable.h>
  36. #include <asm/mipsregs.h>
  37. #include <asm/processor.h>
  38. #include <asm/reg.h>
  39. #include <asm/uaccess.h>
  40. #include <asm/io.h>
  41. #include <asm/elf.h>
  42. #include <asm/isadep.h>
  43. #include <asm/inst.h>
  44. #include <asm/stacktrace.h>
  45. #include <asm/irq_regs.h>
  46. #ifdef CONFIG_HOTPLUG_CPU
  47. void arch_cpu_idle_dead(void)
  48. {
  49. /* What the heck is this check doing ? */
  50. if (!cpu_isset(smp_processor_id(), cpu_callin_map))
  51. play_dead();
  52. }
  53. #endif
  54. asmlinkage void ret_from_fork(void);
  55. asmlinkage void ret_from_kernel_thread(void);
  56. void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
  57. {
  58. unsigned long status;
  59. /* New thread loses kernel privileges. */
  60. status = regs->cp0_status & ~(ST0_CU0|ST0_CU1|ST0_FR|KU_MASK);
  61. status |= KU_USER;
  62. regs->cp0_status = status;
  63. clear_used_math();
  64. clear_fpu_owner();
  65. init_dsp();
  66. clear_thread_flag(TIF_USEDMSA);
  67. clear_thread_flag(TIF_MSA_CTX_LIVE);
  68. disable_msa();
  69. regs->cp0_epc = pc;
  70. regs->regs[29] = sp;
  71. }
  72. void exit_thread(void)
  73. {
  74. }
  75. void flush_thread(void)
  76. {
  77. }
  78. int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
  79. {
  80. /*
  81. * Save any process state which is live in hardware registers to the
  82. * parent context prior to duplication. This prevents the new child
  83. * state becoming stale if the parent is preempted before copy_thread()
  84. * gets a chance to save the parent's live hardware registers to the
  85. * child context.
  86. */
  87. preempt_disable();
  88. if (is_msa_enabled())
  89. save_msa(current);
  90. else if (is_fpu_owner())
  91. _save_fp(current);
  92. save_dsp(current);
  93. preempt_enable();
  94. *dst = *src;
  95. return 0;
  96. }
  97. int copy_thread(unsigned long clone_flags, unsigned long usp,
  98. unsigned long arg, struct task_struct *p)
  99. {
  100. struct thread_info *ti = task_thread_info(p);
  101. struct pt_regs *childregs, *regs = current_pt_regs();
  102. unsigned long childksp;
  103. p->set_child_tid = p->clear_child_tid = NULL;
  104. childksp = (unsigned long)task_stack_page(p) + THREAD_SIZE - 32;
  105. /* set up new TSS. */
  106. childregs = (struct pt_regs *) childksp - 1;
  107. /* Put the stack after the struct pt_regs. */
  108. childksp = (unsigned long) childregs;
  109. p->thread.cp0_status = read_c0_status() & ~(ST0_CU2|ST0_CU1);
  110. if (unlikely(p->flags & PF_KTHREAD)) {
  111. unsigned long status = p->thread.cp0_status;
  112. memset(childregs, 0, sizeof(struct pt_regs));
  113. ti->addr_limit = KERNEL_DS;
  114. p->thread.reg16 = usp; /* fn */
  115. p->thread.reg17 = arg;
  116. p->thread.reg29 = childksp;
  117. p->thread.reg31 = (unsigned long) ret_from_kernel_thread;
  118. #if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
  119. status = (status & ~(ST0_KUP | ST0_IEP | ST0_IEC)) |
  120. ((status & (ST0_KUC | ST0_IEC)) << 2);
  121. #else
  122. status |= ST0_EXL;
  123. #endif
  124. childregs->cp0_status = status;
  125. return 0;
  126. }
  127. *childregs = *regs;
  128. childregs->regs[7] = 0; /* Clear error flag */
  129. childregs->regs[2] = 0; /* Child gets zero as return value */
  130. if (usp)
  131. childregs->regs[29] = usp;
  132. ti->addr_limit = USER_DS;
  133. p->thread.reg29 = (unsigned long) childregs;
  134. p->thread.reg31 = (unsigned long) ret_from_fork;
  135. /*
  136. * New tasks lose permission to use the fpu. This accelerates context
  137. * switching for most programs since they don't use the fpu.
  138. */
  139. childregs->cp0_status &= ~(ST0_CU2|ST0_CU1);
  140. clear_tsk_thread_flag(p, TIF_USEDFPU);
  141. clear_tsk_thread_flag(p, TIF_USEDMSA);
  142. clear_tsk_thread_flag(p, TIF_MSA_CTX_LIVE);
  143. #ifdef CONFIG_MIPS_MT_FPAFF
  144. clear_tsk_thread_flag(p, TIF_FPUBOUND);
  145. #endif /* CONFIG_MIPS_MT_FPAFF */
  146. if (clone_flags & CLONE_SETTLS)
  147. ti->tp_value = regs->regs[7];
  148. return 0;
  149. }
  150. #ifdef CONFIG_CC_STACKPROTECTOR
  151. #include <linux/stackprotector.h>
  152. unsigned long __stack_chk_guard __read_mostly;
  153. EXPORT_SYMBOL(__stack_chk_guard);
  154. #endif
  155. struct mips_frame_info {
  156. void *func;
  157. unsigned long func_size;
  158. int frame_size;
  159. int pc_offset;
  160. };
  161. #define J_TARGET(pc,target) \
  162. (((unsigned long)(pc) & 0xf0000000) | ((target) << 2))
  163. static inline int is_ra_save_ins(union mips_instruction *ip)
  164. {
  165. #ifdef CONFIG_CPU_MICROMIPS
  166. union mips_instruction mmi;
  167. /*
  168. * swsp ra,offset
  169. * swm16 reglist,offset(sp)
  170. * swm32 reglist,offset(sp)
  171. * sw32 ra,offset(sp)
  172. * jradiussp - NOT SUPPORTED
  173. *
  174. * microMIPS is way more fun...
  175. */
  176. if (mm_insn_16bit(ip->halfword[0])) {
  177. mmi.word = (ip->halfword[0] << 16);
  178. return (mmi.mm16_r5_format.opcode == mm_swsp16_op &&
  179. mmi.mm16_r5_format.rt == 31) ||
  180. (mmi.mm16_m_format.opcode == mm_pool16c_op &&
  181. mmi.mm16_m_format.func == mm_swm16_op);
  182. }
  183. else {
  184. mmi.halfword[0] = ip->halfword[1];
  185. mmi.halfword[1] = ip->halfword[0];
  186. return (mmi.mm_m_format.opcode == mm_pool32b_op &&
  187. mmi.mm_m_format.rd > 9 &&
  188. mmi.mm_m_format.base == 29 &&
  189. mmi.mm_m_format.func == mm_swm32_func) ||
  190. (mmi.i_format.opcode == mm_sw32_op &&
  191. mmi.i_format.rs == 29 &&
  192. mmi.i_format.rt == 31);
  193. }
  194. #else
  195. /* sw / sd $ra, offset($sp) */
  196. return (ip->i_format.opcode == sw_op || ip->i_format.opcode == sd_op) &&
  197. ip->i_format.rs == 29 &&
  198. ip->i_format.rt == 31;
  199. #endif
  200. }
  201. static inline int is_jump_ins(union mips_instruction *ip)
  202. {
  203. #ifdef CONFIG_CPU_MICROMIPS
  204. /*
  205. * jr16,jrc,jalr16,jalr16
  206. * jal
  207. * jalr/jr,jalr.hb/jr.hb,jalrs,jalrs.hb
  208. * jraddiusp - NOT SUPPORTED
  209. *
  210. * microMIPS is kind of more fun...
  211. */
  212. union mips_instruction mmi;
  213. mmi.word = (ip->halfword[0] << 16);
  214. if ((mmi.mm16_r5_format.opcode == mm_pool16c_op &&
  215. (mmi.mm16_r5_format.rt & mm_jr16_op) == mm_jr16_op) ||
  216. ip->j_format.opcode == mm_jal32_op)
  217. return 1;
  218. if (ip->r_format.opcode != mm_pool32a_op ||
  219. ip->r_format.func != mm_pool32axf_op)
  220. return 0;
  221. return ((ip->u_format.uimmediate >> 6) & mm_jalr_op) == mm_jalr_op;
  222. #else
  223. if (ip->j_format.opcode == j_op)
  224. return 1;
  225. if (ip->j_format.opcode == jal_op)
  226. return 1;
  227. if (ip->r_format.opcode != spec_op)
  228. return 0;
  229. return ip->r_format.func == jalr_op || ip->r_format.func == jr_op;
  230. #endif
  231. }
  232. static inline int is_sp_move_ins(union mips_instruction *ip)
  233. {
  234. #ifdef CONFIG_CPU_MICROMIPS
  235. /*
  236. * addiusp -imm
  237. * addius5 sp,-imm
  238. * addiu32 sp,sp,-imm
  239. * jradiussp - NOT SUPPORTED
  240. *
  241. * microMIPS is not more fun...
  242. */
  243. if (mm_insn_16bit(ip->halfword[0])) {
  244. union mips_instruction mmi;
  245. mmi.word = (ip->halfword[0] << 16);
  246. return (mmi.mm16_r3_format.opcode == mm_pool16d_op &&
  247. mmi.mm16_r3_format.simmediate && mm_addiusp_func) ||
  248. (mmi.mm16_r5_format.opcode == mm_pool16d_op &&
  249. mmi.mm16_r5_format.rt == 29);
  250. }
  251. return ip->mm_i_format.opcode == mm_addiu32_op &&
  252. ip->mm_i_format.rt == 29 && ip->mm_i_format.rs == 29;
  253. #else
  254. /* addiu/daddiu sp,sp,-imm */
  255. if (ip->i_format.rs != 29 || ip->i_format.rt != 29)
  256. return 0;
  257. if (ip->i_format.opcode == addiu_op || ip->i_format.opcode == daddiu_op)
  258. return 1;
  259. #endif
  260. return 0;
  261. }
  262. static int get_frame_info(struct mips_frame_info *info)
  263. {
  264. #ifdef CONFIG_CPU_MICROMIPS
  265. union mips_instruction *ip = (void *) (((char *) info->func) - 1);
  266. #else
  267. union mips_instruction *ip = info->func;
  268. #endif
  269. unsigned max_insns = info->func_size / sizeof(union mips_instruction);
  270. unsigned i;
  271. info->pc_offset = -1;
  272. info->frame_size = 0;
  273. if (!ip)
  274. goto err;
  275. if (max_insns == 0)
  276. max_insns = 128U; /* unknown function size */
  277. max_insns = min(128U, max_insns);
  278. for (i = 0; i < max_insns; i++, ip++) {
  279. if (is_jump_ins(ip))
  280. break;
  281. if (!info->frame_size) {
  282. if (is_sp_move_ins(ip))
  283. {
  284. #ifdef CONFIG_CPU_MICROMIPS
  285. if (mm_insn_16bit(ip->halfword[0]))
  286. {
  287. unsigned short tmp;
  288. if (ip->halfword[0] & mm_addiusp_func)
  289. {
  290. tmp = (((ip->halfword[0] >> 1) & 0x1ff) << 2);
  291. info->frame_size = -(signed short)(tmp | ((tmp & 0x100) ? 0xfe00 : 0));
  292. } else {
  293. tmp = (ip->halfword[0] >> 1);
  294. info->frame_size = -(signed short)(tmp & 0xf);
  295. }
  296. ip = (void *) &ip->halfword[1];
  297. ip--;
  298. } else
  299. #endif
  300. info->frame_size = - ip->i_format.simmediate;
  301. }
  302. continue;
  303. }
  304. if (info->pc_offset == -1 && is_ra_save_ins(ip)) {
  305. info->pc_offset =
  306. ip->i_format.simmediate / sizeof(long);
  307. break;
  308. }
  309. }
  310. if (info->frame_size && info->pc_offset >= 0) /* nested */
  311. return 0;
  312. if (info->pc_offset < 0) /* leaf */
  313. return 1;
  314. /* prologue seems boggus... */
  315. err:
  316. return -1;
  317. }
  318. static struct mips_frame_info schedule_mfi __read_mostly;
  319. #ifdef CONFIG_KALLSYMS
  320. static unsigned long get___schedule_addr(void)
  321. {
  322. return kallsyms_lookup_name("__schedule");
  323. }
  324. #else
  325. static unsigned long get___schedule_addr(void)
  326. {
  327. union mips_instruction *ip = (void *)schedule;
  328. int max_insns = 8;
  329. int i;
  330. for (i = 0; i < max_insns; i++, ip++) {
  331. if (ip->j_format.opcode == j_op)
  332. return J_TARGET(ip, ip->j_format.target);
  333. }
  334. return 0;
  335. }
  336. #endif
  337. static int __init frame_info_init(void)
  338. {
  339. unsigned long size = 0;
  340. #ifdef CONFIG_KALLSYMS
  341. unsigned long ofs;
  342. #endif
  343. unsigned long addr;
  344. addr = get___schedule_addr();
  345. if (!addr)
  346. addr = (unsigned long)schedule;
  347. #ifdef CONFIG_KALLSYMS
  348. kallsyms_lookup_size_offset(addr, &size, &ofs);
  349. #endif
  350. schedule_mfi.func = (void *)addr;
  351. schedule_mfi.func_size = size;
  352. get_frame_info(&schedule_mfi);
  353. /*
  354. * Without schedule() frame info, result given by
  355. * thread_saved_pc() and get_wchan() are not reliable.
  356. */
  357. if (schedule_mfi.pc_offset < 0)
  358. printk("Can't analyze schedule() prologue at %p\n", schedule);
  359. return 0;
  360. }
  361. arch_initcall(frame_info_init);
  362. /*
  363. * Return saved PC of a blocked thread.
  364. */
  365. unsigned long thread_saved_pc(struct task_struct *tsk)
  366. {
  367. struct thread_struct *t = &tsk->thread;
  368. /* New born processes are a special case */
  369. if (t->reg31 == (unsigned long) ret_from_fork)
  370. return t->reg31;
  371. if (schedule_mfi.pc_offset < 0)
  372. return 0;
  373. return ((unsigned long *)t->reg29)[schedule_mfi.pc_offset];
  374. }
  375. #ifdef CONFIG_KALLSYMS
  376. /* generic stack unwinding function */
  377. unsigned long notrace unwind_stack_by_address(unsigned long stack_page,
  378. unsigned long *sp,
  379. unsigned long pc,
  380. unsigned long *ra)
  381. {
  382. struct mips_frame_info info;
  383. unsigned long size, ofs;
  384. int leaf;
  385. extern void ret_from_irq(void);
  386. extern void ret_from_exception(void);
  387. if (!stack_page)
  388. return 0;
  389. /*
  390. * If we reached the bottom of interrupt context,
  391. * return saved pc in pt_regs.
  392. */
  393. if (pc == (unsigned long)ret_from_irq ||
  394. pc == (unsigned long)ret_from_exception) {
  395. struct pt_regs *regs;
  396. if (*sp >= stack_page &&
  397. *sp + sizeof(*regs) <= stack_page + THREAD_SIZE - 32) {
  398. regs = (struct pt_regs *)*sp;
  399. pc = regs->cp0_epc;
  400. if (__kernel_text_address(pc)) {
  401. *sp = regs->regs[29];
  402. *ra = regs->regs[31];
  403. return pc;
  404. }
  405. }
  406. return 0;
  407. }
  408. if (!kallsyms_lookup_size_offset(pc, &size, &ofs))
  409. return 0;
  410. /*
  411. * Return ra if an exception occurred at the first instruction
  412. */
  413. if (unlikely(ofs == 0)) {
  414. pc = *ra;
  415. *ra = 0;
  416. return pc;
  417. }
  418. info.func = (void *)(pc - ofs);
  419. info.func_size = ofs; /* analyze from start to ofs */
  420. leaf = get_frame_info(&info);
  421. if (leaf < 0)
  422. return 0;
  423. if (*sp < stack_page ||
  424. *sp + info.frame_size > stack_page + THREAD_SIZE - 32)
  425. return 0;
  426. if (leaf)
  427. /*
  428. * For some extreme cases, get_frame_info() can
  429. * consider wrongly a nested function as a leaf
  430. * one. In that cases avoid to return always the
  431. * same value.
  432. */
  433. pc = pc != *ra ? *ra : 0;
  434. else
  435. pc = ((unsigned long *)(*sp))[info.pc_offset];
  436. *sp += info.frame_size;
  437. *ra = 0;
  438. return __kernel_text_address(pc) ? pc : 0;
  439. }
  440. EXPORT_SYMBOL(unwind_stack_by_address);
  441. /* used by show_backtrace() */
  442. unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
  443. unsigned long pc, unsigned long *ra)
  444. {
  445. unsigned long stack_page = (unsigned long)task_stack_page(task);
  446. return unwind_stack_by_address(stack_page, sp, pc, ra);
  447. }
  448. #endif
  449. /*
  450. * get_wchan - a maintenance nightmare^W^Wpain in the ass ...
  451. */
  452. unsigned long get_wchan(struct task_struct *task)
  453. {
  454. unsigned long pc = 0;
  455. #ifdef CONFIG_KALLSYMS
  456. unsigned long sp;
  457. unsigned long ra = 0;
  458. #endif
  459. if (!task || task == current || task->state == TASK_RUNNING)
  460. goto out;
  461. if (!task_stack_page(task))
  462. goto out;
  463. pc = thread_saved_pc(task);
  464. #ifdef CONFIG_KALLSYMS
  465. sp = task->thread.reg29 + schedule_mfi.frame_size;
  466. while (in_sched_functions(pc))
  467. pc = unwind_stack(task, &sp, pc, &ra);
  468. #endif
  469. out:
  470. return pc;
  471. }
  472. /*
  473. * Don't forget that the stack pointer must be aligned on a 8 bytes
  474. * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
  475. */
  476. unsigned long arch_align_stack(unsigned long sp)
  477. {
  478. if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
  479. sp -= get_random_int() & ~PAGE_MASK;
  480. return sp & ALMASK;
  481. }
  482. static void arch_dump_stack(void *info)
  483. {
  484. struct pt_regs *regs;
  485. regs = get_irq_regs();
  486. if (regs)
  487. show_regs(regs);
  488. dump_stack();
  489. }
  490. void arch_trigger_all_cpu_backtrace(bool include_self)
  491. {
  492. smp_call_function(arch_dump_stack, NULL, 1);
  493. }
  494. int mips_get_process_fp_mode(struct task_struct *task)
  495. {
  496. int value = 0;
  497. if (!test_tsk_thread_flag(task, TIF_32BIT_FPREGS))
  498. value |= PR_FP_MODE_FR;
  499. if (test_tsk_thread_flag(task, TIF_HYBRID_FPREGS))
  500. value |= PR_FP_MODE_FRE;
  501. return value;
  502. }
  503. int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
  504. {
  505. const unsigned int known_bits = PR_FP_MODE_FR | PR_FP_MODE_FRE;
  506. unsigned long switch_count;
  507. struct task_struct *t;
  508. /* Check the value is valid */
  509. if (value & ~known_bits)
  510. return -EOPNOTSUPP;
  511. /* Avoid inadvertently triggering emulation */
  512. if ((value & PR_FP_MODE_FR) && cpu_has_fpu &&
  513. !(current_cpu_data.fpu_id & MIPS_FPIR_F64))
  514. return -EOPNOTSUPP;
  515. if ((value & PR_FP_MODE_FRE) && cpu_has_fpu && !cpu_has_fre)
  516. return -EOPNOTSUPP;
  517. /* FR = 0 not supported in MIPS R6 */
  518. if (!(value & PR_FP_MODE_FR) && cpu_has_fpu && cpu_has_mips_r6)
  519. return -EOPNOTSUPP;
  520. /* Save FP & vector context, then disable FPU & MSA */
  521. if (task->signal == current->signal)
  522. lose_fpu(1);
  523. /* Prevent any threads from obtaining live FP context */
  524. atomic_set(&task->mm->context.fp_mode_switching, 1);
  525. smp_mb__after_atomic();
  526. /*
  527. * If there are multiple online CPUs then wait until all threads whose
  528. * FP mode is about to change have been context switched. This approach
  529. * allows us to only worry about whether an FP mode switch is in
  530. * progress when FP is first used in a tasks time slice. Pretty much all
  531. * of the mode switch overhead can thus be confined to cases where mode
  532. * switches are actually occuring. That is, to here. However for the
  533. * thread performing the mode switch it may take a while...
  534. */
  535. if (num_online_cpus() > 1) {
  536. spin_lock_irq(&task->sighand->siglock);
  537. for_each_thread(task, t) {
  538. if (t == current)
  539. continue;
  540. switch_count = t->nvcsw + t->nivcsw;
  541. do {
  542. spin_unlock_irq(&task->sighand->siglock);
  543. cond_resched();
  544. spin_lock_irq(&task->sighand->siglock);
  545. } while ((t->nvcsw + t->nivcsw) == switch_count);
  546. }
  547. spin_unlock_irq(&task->sighand->siglock);
  548. }
  549. /*
  550. * There are now no threads of the process with live FP context, so it
  551. * is safe to proceed with the FP mode switch.
  552. */
  553. for_each_thread(task, t) {
  554. /* Update desired FP register width */
  555. if (value & PR_FP_MODE_FR) {
  556. clear_tsk_thread_flag(t, TIF_32BIT_FPREGS);
  557. } else {
  558. set_tsk_thread_flag(t, TIF_32BIT_FPREGS);
  559. clear_tsk_thread_flag(t, TIF_MSA_CTX_LIVE);
  560. }
  561. /* Update desired FP single layout */
  562. if (value & PR_FP_MODE_FRE)
  563. set_tsk_thread_flag(t, TIF_HYBRID_FPREGS);
  564. else
  565. clear_tsk_thread_flag(t, TIF_HYBRID_FPREGS);
  566. }
  567. /* Allow threads to use FP again */
  568. atomic_set(&task->mm->context.fp_mode_switching, 0);
  569. return 0;
  570. }