process.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  2. #include <linux/errno.h>
  3. #include <linux/kernel.h>
  4. #include <linux/mm.h>
  5. #include <linux/smp.h>
  6. #include <linux/prctl.h>
  7. #include <linux/slab.h>
  8. #include <linux/sched.h>
  9. #include <linux/module.h>
  10. #include <linux/pm.h>
  11. #include <linux/clockchips.h>
  12. #include <linux/random.h>
  13. #include <linux/user-return-notifier.h>
  14. #include <linux/dmi.h>
  15. #include <linux/utsname.h>
  16. #include <linux/stackprotector.h>
  17. #include <linux/tick.h>
  18. #include <linux/cpuidle.h>
  19. #include <trace/events/power.h>
  20. #include <linux/hw_breakpoint.h>
  21. #include <asm/cpu.h>
  22. #include <asm/apic.h>
  23. #include <asm/syscalls.h>
  24. #include <asm/idle.h>
  25. #include <asm/uaccess.h>
  26. #include <asm/i387.h>
  27. #include <asm/fpu-internal.h>
  28. #include <asm/debugreg.h>
  29. #include <asm/nmi.h>
  30. /*
  31. * per-CPU TSS segments. Threads are completely 'soft' on Linux,
  32. * no more per-task TSS's. The TSS size is kept cacheline-aligned
  33. * so they are allowed to end up in the .data..cacheline_aligned
  34. * section. Since TSS's are completely CPU-local, we want them
  35. * on exact cacheline boundaries, to eliminate cacheline ping-pong.
  36. */
  37. DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
  38. #ifdef CONFIG_X86_64
  39. static DEFINE_PER_CPU(unsigned char, is_idle);
  40. static ATOMIC_NOTIFIER_HEAD(idle_notifier);
  41. void idle_notifier_register(struct notifier_block *n)
  42. {
  43. atomic_notifier_chain_register(&idle_notifier, n);
  44. }
  45. EXPORT_SYMBOL_GPL(idle_notifier_register);
  46. void idle_notifier_unregister(struct notifier_block *n)
  47. {
  48. atomic_notifier_chain_unregister(&idle_notifier, n);
  49. }
  50. EXPORT_SYMBOL_GPL(idle_notifier_unregister);
  51. #endif
  52. struct kmem_cache *task_xstate_cachep;
  53. EXPORT_SYMBOL_GPL(task_xstate_cachep);
  54. /*
  55. * this gets called so that we can store lazy state into memory and copy the
  56. * current task into the new thread.
  57. */
  58. int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
  59. {
  60. int ret;
  61. unlazy_fpu(src);
  62. *dst = *src;
  63. if (fpu_allocated(&src->thread.fpu)) {
  64. memset(&dst->thread.fpu, 0, sizeof(dst->thread.fpu));
  65. ret = fpu_alloc(&dst->thread.fpu);
  66. if (ret)
  67. return ret;
  68. fpu_copy(&dst->thread.fpu, &src->thread.fpu);
  69. }
  70. return 0;
  71. }
  72. void free_thread_xstate(struct task_struct *tsk)
  73. {
  74. fpu_free(&tsk->thread.fpu);
  75. }
  76. void arch_release_task_struct(struct task_struct *tsk)
  77. {
  78. free_thread_xstate(tsk);
  79. }
  80. void arch_task_cache_init(void)
  81. {
  82. task_xstate_cachep =
  83. kmem_cache_create("task_xstate", xstate_size,
  84. __alignof__(union thread_xstate),
  85. SLAB_PANIC | SLAB_NOTRACK, NULL);
  86. }
  87. static inline void drop_fpu(struct task_struct *tsk)
  88. {
  89. /*
  90. * Forget coprocessor state..
  91. */
  92. tsk->fpu_counter = 0;
  93. clear_fpu(tsk);
  94. clear_used_math();
  95. }
  96. /*
  97. * Free current thread data structures etc..
  98. */
  99. void exit_thread(void)
  100. {
  101. struct task_struct *me = current;
  102. struct thread_struct *t = &me->thread;
  103. unsigned long *bp = t->io_bitmap_ptr;
  104. if (bp) {
  105. struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
  106. t->io_bitmap_ptr = NULL;
  107. clear_thread_flag(TIF_IO_BITMAP);
  108. /*
  109. * Careful, clear this in the TSS too:
  110. */
  111. memset(tss->io_bitmap, 0xff, t->io_bitmap_max);
  112. t->io_bitmap_max = 0;
  113. put_cpu();
  114. kfree(bp);
  115. }
  116. drop_fpu(me);
  117. }
  118. void show_regs_common(void)
  119. {
  120. const char *vendor, *product, *board;
  121. vendor = dmi_get_system_info(DMI_SYS_VENDOR);
  122. if (!vendor)
  123. vendor = "";
  124. product = dmi_get_system_info(DMI_PRODUCT_NAME);
  125. if (!product)
  126. product = "";
  127. /* Board Name is optional */
  128. board = dmi_get_system_info(DMI_BOARD_NAME);
  129. printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
  130. current->pid, current->comm, print_tainted(),
  131. init_utsname()->release,
  132. (int)strcspn(init_utsname()->version, " "),
  133. init_utsname()->version,
  134. vendor, product,
  135. board ? "/" : "",
  136. board ? board : "");
  137. }
  138. void flush_thread(void)
  139. {
  140. struct task_struct *tsk = current;
  141. flush_ptrace_hw_breakpoint(tsk);
  142. memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
  143. drop_fpu(tsk);
  144. }
  145. static void hard_disable_TSC(void)
  146. {
  147. write_cr4(read_cr4() | X86_CR4_TSD);
  148. }
  149. void disable_TSC(void)
  150. {
  151. preempt_disable();
  152. if (!test_and_set_thread_flag(TIF_NOTSC))
  153. /*
  154. * Must flip the CPU state synchronously with
  155. * TIF_NOTSC in the current running context.
  156. */
  157. hard_disable_TSC();
  158. preempt_enable();
  159. }
  160. static void hard_enable_TSC(void)
  161. {
  162. write_cr4(read_cr4() & ~X86_CR4_TSD);
  163. }
  164. static void enable_TSC(void)
  165. {
  166. preempt_disable();
  167. if (test_and_clear_thread_flag(TIF_NOTSC))
  168. /*
  169. * Must flip the CPU state synchronously with
  170. * TIF_NOTSC in the current running context.
  171. */
  172. hard_enable_TSC();
  173. preempt_enable();
  174. }
  175. int get_tsc_mode(unsigned long adr)
  176. {
  177. unsigned int val;
  178. if (test_thread_flag(TIF_NOTSC))
  179. val = PR_TSC_SIGSEGV;
  180. else
  181. val = PR_TSC_ENABLE;
  182. return put_user(val, (unsigned int __user *)adr);
  183. }
  184. int set_tsc_mode(unsigned int val)
  185. {
  186. if (val == PR_TSC_SIGSEGV)
  187. disable_TSC();
  188. else if (val == PR_TSC_ENABLE)
  189. enable_TSC();
  190. else
  191. return -EINVAL;
  192. return 0;
  193. }
  194. void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p,
  195. struct tss_struct *tss)
  196. {
  197. struct thread_struct *prev, *next;
  198. prev = &prev_p->thread;
  199. next = &next_p->thread;
  200. if (test_tsk_thread_flag(prev_p, TIF_BLOCKSTEP) ^
  201. test_tsk_thread_flag(next_p, TIF_BLOCKSTEP)) {
  202. unsigned long debugctl = get_debugctlmsr();
  203. debugctl &= ~DEBUGCTLMSR_BTF;
  204. if (test_tsk_thread_flag(next_p, TIF_BLOCKSTEP))
  205. debugctl |= DEBUGCTLMSR_BTF;
  206. update_debugctlmsr(debugctl);
  207. }
  208. if (test_tsk_thread_flag(prev_p, TIF_NOTSC) ^
  209. test_tsk_thread_flag(next_p, TIF_NOTSC)) {
  210. /* prev and next are different */
  211. if (test_tsk_thread_flag(next_p, TIF_NOTSC))
  212. hard_disable_TSC();
  213. else
  214. hard_enable_TSC();
  215. }
  216. if (test_tsk_thread_flag(next_p, TIF_IO_BITMAP)) {
  217. /*
  218. * Copy the relevant range of the IO bitmap.
  219. * Normally this is 128 bytes or less:
  220. */
  221. memcpy(tss->io_bitmap, next->io_bitmap_ptr,
  222. max(prev->io_bitmap_max, next->io_bitmap_max));
  223. } else if (test_tsk_thread_flag(prev_p, TIF_IO_BITMAP)) {
  224. /*
  225. * Clear any possible leftover bits:
  226. */
  227. memset(tss->io_bitmap, 0xff, prev->io_bitmap_max);
  228. }
  229. propagate_user_return_notify(prev_p, next_p);
  230. }
  231. int sys_fork(struct pt_regs *regs)
  232. {
  233. return do_fork(SIGCHLD, regs->sp, regs, 0, NULL, NULL);
  234. }
  235. /*
  236. * This is trivial, and on the face of it looks like it
  237. * could equally well be done in user mode.
  238. *
  239. * Not so, for quite unobvious reasons - register pressure.
  240. * In user mode vfork() cannot have a stack frame, and if
  241. * done by calling the "clone()" system call directly, you
  242. * do not have enough call-clobbered registers to hold all
  243. * the information you need.
  244. */
  245. int sys_vfork(struct pt_regs *regs)
  246. {
  247. return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp, regs, 0,
  248. NULL, NULL);
  249. }
  250. long
  251. sys_clone(unsigned long clone_flags, unsigned long newsp,
  252. void __user *parent_tid, void __user *child_tid, struct pt_regs *regs)
  253. {
  254. if (!newsp)
  255. newsp = regs->sp;
  256. return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
  257. }
  258. /*
  259. * Idle related variables and functions
  260. */
  261. unsigned long boot_option_idle_override = IDLE_NO_OVERRIDE;
  262. EXPORT_SYMBOL(boot_option_idle_override);
  263. /*
  264. * Powermanagement idle function, if any..
  265. */
  266. void (*pm_idle)(void);
  267. #ifdef CONFIG_APM_MODULE
  268. EXPORT_SYMBOL(pm_idle);
  269. #endif
  270. static inline int hlt_use_halt(void)
  271. {
  272. return 1;
  273. }
  274. #ifndef CONFIG_SMP
  275. static inline void play_dead(void)
  276. {
  277. BUG();
  278. }
  279. #endif
  280. #ifdef CONFIG_X86_64
  281. void enter_idle(void)
  282. {
  283. this_cpu_write(is_idle, 1);
  284. atomic_notifier_call_chain(&idle_notifier, IDLE_START, NULL);
  285. }
  286. static void __exit_idle(void)
  287. {
  288. if (x86_test_and_clear_bit_percpu(0, is_idle) == 0)
  289. return;
  290. atomic_notifier_call_chain(&idle_notifier, IDLE_END, NULL);
  291. }
  292. /* Called from interrupts to signify idle end */
  293. void exit_idle(void)
  294. {
  295. /* idle loop has pid 0 */
  296. if (current->pid)
  297. return;
  298. __exit_idle();
  299. }
  300. #endif
  301. /*
  302. * The idle thread. There's no useful work to be
  303. * done, so just try to conserve power and have a
  304. * low exit latency (ie sit in a loop waiting for
  305. * somebody to say that they'd like to reschedule)
  306. */
  307. void cpu_idle(void)
  308. {
  309. /*
  310. * If we're the non-boot CPU, nothing set the stack canary up
  311. * for us. CPU0 already has it initialized but no harm in
  312. * doing it again. This is a good place for updating it, as
  313. * we wont ever return from this function (so the invalid
  314. * canaries already on the stack wont ever trigger).
  315. */
  316. boot_init_stack_canary();
  317. current_thread_info()->status |= TS_POLLING;
  318. while (1) {
  319. tick_nohz_idle_enter();
  320. while (!need_resched()) {
  321. rmb();
  322. if (cpu_is_offline(smp_processor_id()))
  323. play_dead();
  324. /*
  325. * Idle routines should keep interrupts disabled
  326. * from here on, until they go to idle.
  327. * Otherwise, idle callbacks can misfire.
  328. */
  329. local_touch_nmi();
  330. local_irq_disable();
  331. enter_idle();
  332. /* Don't trace irqs off for idle */
  333. stop_critical_timings();
  334. /* enter_idle() needs rcu for notifiers */
  335. rcu_idle_enter();
  336. if (cpuidle_idle_call())
  337. pm_idle();
  338. rcu_idle_exit();
  339. start_critical_timings();
  340. /* In many cases the interrupt that ended idle
  341. has already called exit_idle. But some idle
  342. loops can be woken up without interrupt. */
  343. __exit_idle();
  344. }
  345. tick_nohz_idle_exit();
  346. preempt_enable_no_resched();
  347. schedule();
  348. preempt_disable();
  349. }
  350. }
  351. /*
  352. * We use this if we don't have any better
  353. * idle routine..
  354. */
  355. void default_idle(void)
  356. {
  357. if (hlt_use_halt()) {
  358. trace_power_start_rcuidle(POWER_CSTATE, 1, smp_processor_id());
  359. trace_cpu_idle_rcuidle(1, smp_processor_id());
  360. current_thread_info()->status &= ~TS_POLLING;
  361. /*
  362. * TS_POLLING-cleared state must be visible before we
  363. * test NEED_RESCHED:
  364. */
  365. smp_mb();
  366. if (!need_resched())
  367. safe_halt(); /* enables interrupts racelessly */
  368. else
  369. local_irq_enable();
  370. current_thread_info()->status |= TS_POLLING;
  371. trace_power_end_rcuidle(smp_processor_id());
  372. trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
  373. } else {
  374. local_irq_enable();
  375. /* loop is done by the caller */
  376. cpu_relax();
  377. }
  378. }
  379. #ifdef CONFIG_APM_MODULE
  380. EXPORT_SYMBOL(default_idle);
  381. #endif
  382. bool set_pm_idle_to_default(void)
  383. {
  384. bool ret = !!pm_idle;
  385. pm_idle = default_idle;
  386. return ret;
  387. }
  388. void stop_this_cpu(void *dummy)
  389. {
  390. local_irq_disable();
  391. /*
  392. * Remove this CPU:
  393. */
  394. set_cpu_online(smp_processor_id(), false);
  395. disable_local_APIC();
  396. for (;;) {
  397. if (hlt_works(smp_processor_id()))
  398. halt();
  399. }
  400. }
  401. /* Default MONITOR/MWAIT with no hints, used for default C1 state */
  402. static void mwait_idle(void)
  403. {
  404. if (!need_resched()) {
  405. trace_power_start_rcuidle(POWER_CSTATE, 1, smp_processor_id());
  406. trace_cpu_idle_rcuidle(1, smp_processor_id());
  407. if (this_cpu_has(X86_FEATURE_CLFLUSH_MONITOR))
  408. clflush((void *)&current_thread_info()->flags);
  409. __monitor((void *)&current_thread_info()->flags, 0, 0);
  410. smp_mb();
  411. if (!need_resched())
  412. __sti_mwait(0, 0);
  413. else
  414. local_irq_enable();
  415. trace_power_end_rcuidle(smp_processor_id());
  416. trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
  417. } else
  418. local_irq_enable();
  419. }
  420. /*
  421. * On SMP it's slightly faster (but much more power-consuming!)
  422. * to poll the ->work.need_resched flag instead of waiting for the
  423. * cross-CPU IPI to arrive. Use this option with caution.
  424. */
  425. static void poll_idle(void)
  426. {
  427. trace_power_start_rcuidle(POWER_CSTATE, 0, smp_processor_id());
  428. trace_cpu_idle_rcuidle(0, smp_processor_id());
  429. local_irq_enable();
  430. while (!need_resched())
  431. cpu_relax();
  432. trace_power_end_rcuidle(smp_processor_id());
  433. trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
  434. }
  435. /*
  436. * mwait selection logic:
  437. *
  438. * It depends on the CPU. For AMD CPUs that support MWAIT this is
  439. * wrong. Family 0x10 and 0x11 CPUs will enter C1 on HLT. Powersavings
  440. * then depend on a clock divisor and current Pstate of the core. If
  441. * all cores of a processor are in halt state (C1) the processor can
  442. * enter the C1E (C1 enhanced) state. If mwait is used this will never
  443. * happen.
  444. *
  445. * idle=mwait overrides this decision and forces the usage of mwait.
  446. */
  447. #define MWAIT_INFO 0x05
  448. #define MWAIT_ECX_EXTENDED_INFO 0x01
  449. #define MWAIT_EDX_C1 0xf0
  450. int mwait_usable(const struct cpuinfo_x86 *c)
  451. {
  452. u32 eax, ebx, ecx, edx;
  453. /* Use mwait if idle=mwait boot option is given */
  454. if (boot_option_idle_override == IDLE_FORCE_MWAIT)
  455. return 1;
  456. /*
  457. * Any idle= boot option other than idle=mwait means that we must not
  458. * use mwait. Eg: idle=halt or idle=poll or idle=nomwait
  459. */
  460. if (boot_option_idle_override != IDLE_NO_OVERRIDE)
  461. return 0;
  462. if (c->cpuid_level < MWAIT_INFO)
  463. return 0;
  464. cpuid(MWAIT_INFO, &eax, &ebx, &ecx, &edx);
  465. /* Check, whether EDX has extended info about MWAIT */
  466. if (!(ecx & MWAIT_ECX_EXTENDED_INFO))
  467. return 1;
  468. /*
  469. * edx enumeratios MONITOR/MWAIT extensions. Check, whether
  470. * C1 supports MWAIT
  471. */
  472. return (edx & MWAIT_EDX_C1);
  473. }
  474. bool amd_e400_c1e_detected;
  475. EXPORT_SYMBOL(amd_e400_c1e_detected);
  476. static cpumask_var_t amd_e400_c1e_mask;
  477. void amd_e400_remove_cpu(int cpu)
  478. {
  479. if (amd_e400_c1e_mask != NULL)
  480. cpumask_clear_cpu(cpu, amd_e400_c1e_mask);
  481. }
  482. /*
  483. * AMD Erratum 400 aware idle routine. We check for C1E active in the interrupt
  484. * pending message MSR. If we detect C1E, then we handle it the same
  485. * way as C3 power states (local apic timer and TSC stop)
  486. */
  487. static void amd_e400_idle(void)
  488. {
  489. if (need_resched())
  490. return;
  491. if (!amd_e400_c1e_detected) {
  492. u32 lo, hi;
  493. rdmsr(MSR_K8_INT_PENDING_MSG, lo, hi);
  494. if (lo & K8_INTP_C1E_ACTIVE_MASK) {
  495. amd_e400_c1e_detected = true;
  496. if (!boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
  497. mark_tsc_unstable("TSC halt in AMD C1E");
  498. pr_info("System has AMD C1E enabled\n");
  499. }
  500. }
  501. if (amd_e400_c1e_detected) {
  502. int cpu = smp_processor_id();
  503. if (!cpumask_test_cpu(cpu, amd_e400_c1e_mask)) {
  504. cpumask_set_cpu(cpu, amd_e400_c1e_mask);
  505. /*
  506. * Force broadcast so ACPI can not interfere.
  507. */
  508. clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_FORCE,
  509. &cpu);
  510. pr_info("Switch to broadcast mode on CPU%d\n", cpu);
  511. }
  512. clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu);
  513. default_idle();
  514. /*
  515. * The switch back from broadcast mode needs to be
  516. * called with interrupts disabled.
  517. */
  518. local_irq_disable();
  519. clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu);
  520. local_irq_enable();
  521. } else
  522. default_idle();
  523. }
  524. void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
  525. {
  526. #ifdef CONFIG_SMP
  527. if (pm_idle == poll_idle && smp_num_siblings > 1) {
  528. pr_warn_once("WARNING: polling idle and HT enabled, performance may degrade\n");
  529. }
  530. #endif
  531. if (pm_idle)
  532. return;
  533. if (cpu_has(c, X86_FEATURE_MWAIT) && mwait_usable(c)) {
  534. /*
  535. * One CPU supports mwait => All CPUs supports mwait
  536. */
  537. pr_info("using mwait in idle threads\n");
  538. pm_idle = mwait_idle;
  539. } else if (cpu_has_amd_erratum(amd_erratum_400)) {
  540. /* E400: APIC timer interrupt does not wake up CPU from C1e */
  541. pr_info("using AMD E400 aware idle routine\n");
  542. pm_idle = amd_e400_idle;
  543. } else
  544. pm_idle = default_idle;
  545. }
  546. void __init init_amd_e400_c1e_mask(void)
  547. {
  548. /* If we're using amd_e400_idle, we need to allocate amd_e400_c1e_mask. */
  549. if (pm_idle == amd_e400_idle)
  550. zalloc_cpumask_var(&amd_e400_c1e_mask, GFP_KERNEL);
  551. }
  552. static int __init idle_setup(char *str)
  553. {
  554. if (!str)
  555. return -EINVAL;
  556. if (!strcmp(str, "poll")) {
  557. pr_info("using polling idle threads\n");
  558. pm_idle = poll_idle;
  559. boot_option_idle_override = IDLE_POLL;
  560. } else if (!strcmp(str, "mwait")) {
  561. boot_option_idle_override = IDLE_FORCE_MWAIT;
  562. WARN_ONCE(1, "\"idle=mwait\" will be removed in 2012\n");
  563. } else if (!strcmp(str, "halt")) {
  564. /*
  565. * When the boot option of idle=halt is added, halt is
  566. * forced to be used for CPU idle. In such case CPU C2/C3
  567. * won't be used again.
  568. * To continue to load the CPU idle driver, don't touch
  569. * the boot_option_idle_override.
  570. */
  571. pm_idle = default_idle;
  572. boot_option_idle_override = IDLE_HALT;
  573. } else if (!strcmp(str, "nomwait")) {
  574. /*
  575. * If the boot option of "idle=nomwait" is added,
  576. * it means that mwait will be disabled for CPU C2/C3
  577. * states. In such case it won't touch the variable
  578. * of boot_option_idle_override.
  579. */
  580. boot_option_idle_override = IDLE_NOMWAIT;
  581. } else
  582. return -1;
  583. return 0;
  584. }
  585. early_param("idle", idle_setup);
  586. unsigned long arch_align_stack(unsigned long sp)
  587. {
  588. if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
  589. sp -= get_random_int() % 8192;
  590. return sp & ~0xf;
  591. }
  592. unsigned long arch_randomize_brk(struct mm_struct *mm)
  593. {
  594. unsigned long range_end = mm->brk + 0x02000000;
  595. return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
  596. }