process.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. #include <linux/errno.h>
  2. #include <linux/kernel.h>
  3. #include <linux/mm.h>
  4. #include <linux/smp.h>
  5. #include <linux/prctl.h>
  6. #include <linux/slab.h>
  7. #include <linux/sched.h>
  8. #include <linux/module.h>
  9. #include <linux/pm.h>
  10. #include <linux/clockchips.h>
  11. #include <linux/random.h>
  12. #include <linux/user-return-notifier.h>
  13. #include <linux/dmi.h>
  14. #include <linux/utsname.h>
  15. #include <trace/events/power.h>
  16. #include <linux/hw_breakpoint.h>
  17. #include <asm/system.h>
  18. #include <asm/apic.h>
  19. #include <asm/syscalls.h>
  20. #include <asm/idle.h>
  21. #include <asm/uaccess.h>
  22. #include <asm/i387.h>
  23. #include <asm/ds.h>
  24. #include <asm/debugreg.h>
  25. unsigned long idle_halt;
  26. EXPORT_SYMBOL(idle_halt);
  27. unsigned long idle_nomwait;
  28. EXPORT_SYMBOL(idle_nomwait);
  29. struct kmem_cache *task_xstate_cachep;
  30. int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
  31. {
  32. int ret;
  33. *dst = *src;
  34. if (fpu_allocated(&src->thread.fpu)) {
  35. memset(&dst->thread.fpu, 0, sizeof(dst->thread.fpu));
  36. ret = fpu_alloc(&dst->thread.fpu);
  37. if (ret)
  38. return ret;
  39. fpu_copy(&dst->thread.fpu, &src->thread.fpu);
  40. }
  41. return 0;
  42. }
  43. void free_thread_xstate(struct task_struct *tsk)
  44. {
  45. fpu_free(&tsk->thread.fpu);
  46. WARN(tsk->thread.ds_ctx, "leaking DS context\n");
  47. }
  48. void free_thread_info(struct thread_info *ti)
  49. {
  50. free_thread_xstate(ti->task);
  51. free_pages((unsigned long)ti, get_order(THREAD_SIZE));
  52. }
  53. void arch_task_cache_init(void)
  54. {
  55. task_xstate_cachep =
  56. kmem_cache_create("task_xstate", xstate_size,
  57. __alignof__(union thread_xstate),
  58. SLAB_PANIC | SLAB_NOTRACK, NULL);
  59. }
  60. /*
  61. * Free current thread data structures etc..
  62. */
  63. void exit_thread(void)
  64. {
  65. struct task_struct *me = current;
  66. struct thread_struct *t = &me->thread;
  67. unsigned long *bp = t->io_bitmap_ptr;
  68. if (bp) {
  69. struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
  70. t->io_bitmap_ptr = NULL;
  71. clear_thread_flag(TIF_IO_BITMAP);
  72. /*
  73. * Careful, clear this in the TSS too:
  74. */
  75. memset(tss->io_bitmap, 0xff, t->io_bitmap_max);
  76. t->io_bitmap_max = 0;
  77. put_cpu();
  78. kfree(bp);
  79. }
  80. }
  81. void show_regs(struct pt_regs *regs)
  82. {
  83. show_registers(regs);
  84. show_trace(NULL, regs, (unsigned long *)kernel_stack_pointer(regs),
  85. regs->bp);
  86. }
  87. void show_regs_common(void)
  88. {
  89. const char *board, *product;
  90. board = dmi_get_system_info(DMI_BOARD_NAME);
  91. if (!board)
  92. board = "";
  93. product = dmi_get_system_info(DMI_PRODUCT_NAME);
  94. if (!product)
  95. product = "";
  96. printk(KERN_CONT "\n");
  97. printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s/%s\n",
  98. current->pid, current->comm, print_tainted(),
  99. init_utsname()->release,
  100. (int)strcspn(init_utsname()->version, " "),
  101. init_utsname()->version, board, product);
  102. }
  103. void flush_thread(void)
  104. {
  105. struct task_struct *tsk = current;
  106. flush_ptrace_hw_breakpoint(tsk);
  107. memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
  108. /*
  109. * Forget coprocessor state..
  110. */
  111. tsk->fpu_counter = 0;
  112. clear_fpu(tsk);
  113. clear_used_math();
  114. }
  115. static void hard_disable_TSC(void)
  116. {
  117. write_cr4(read_cr4() | X86_CR4_TSD);
  118. }
  119. void disable_TSC(void)
  120. {
  121. preempt_disable();
  122. if (!test_and_set_thread_flag(TIF_NOTSC))
  123. /*
  124. * Must flip the CPU state synchronously with
  125. * TIF_NOTSC in the current running context.
  126. */
  127. hard_disable_TSC();
  128. preempt_enable();
  129. }
  130. static void hard_enable_TSC(void)
  131. {
  132. write_cr4(read_cr4() & ~X86_CR4_TSD);
  133. }
  134. static void enable_TSC(void)
  135. {
  136. preempt_disable();
  137. if (test_and_clear_thread_flag(TIF_NOTSC))
  138. /*
  139. * Must flip the CPU state synchronously with
  140. * TIF_NOTSC in the current running context.
  141. */
  142. hard_enable_TSC();
  143. preempt_enable();
  144. }
  145. int get_tsc_mode(unsigned long adr)
  146. {
  147. unsigned int val;
  148. if (test_thread_flag(TIF_NOTSC))
  149. val = PR_TSC_SIGSEGV;
  150. else
  151. val = PR_TSC_ENABLE;
  152. return put_user(val, (unsigned int __user *)adr);
  153. }
  154. int set_tsc_mode(unsigned int val)
  155. {
  156. if (val == PR_TSC_SIGSEGV)
  157. disable_TSC();
  158. else if (val == PR_TSC_ENABLE)
  159. enable_TSC();
  160. else
  161. return -EINVAL;
  162. return 0;
  163. }
  164. void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p,
  165. struct tss_struct *tss)
  166. {
  167. struct thread_struct *prev, *next;
  168. prev = &prev_p->thread;
  169. next = &next_p->thread;
  170. if (test_tsk_thread_flag(next_p, TIF_DS_AREA_MSR) ||
  171. test_tsk_thread_flag(prev_p, TIF_DS_AREA_MSR))
  172. ds_switch_to(prev_p, next_p);
  173. else if (next->debugctlmsr != prev->debugctlmsr)
  174. update_debugctlmsr(next->debugctlmsr);
  175. if (test_tsk_thread_flag(prev_p, TIF_NOTSC) ^
  176. test_tsk_thread_flag(next_p, TIF_NOTSC)) {
  177. /* prev and next are different */
  178. if (test_tsk_thread_flag(next_p, TIF_NOTSC))
  179. hard_disable_TSC();
  180. else
  181. hard_enable_TSC();
  182. }
  183. if (test_tsk_thread_flag(next_p, TIF_IO_BITMAP)) {
  184. /*
  185. * Copy the relevant range of the IO bitmap.
  186. * Normally this is 128 bytes or less:
  187. */
  188. memcpy(tss->io_bitmap, next->io_bitmap_ptr,
  189. max(prev->io_bitmap_max, next->io_bitmap_max));
  190. } else if (test_tsk_thread_flag(prev_p, TIF_IO_BITMAP)) {
  191. /*
  192. * Clear any possible leftover bits:
  193. */
  194. memset(tss->io_bitmap, 0xff, prev->io_bitmap_max);
  195. }
  196. propagate_user_return_notify(prev_p, next_p);
  197. }
  198. int sys_fork(struct pt_regs *regs)
  199. {
  200. return do_fork(SIGCHLD, regs->sp, regs, 0, NULL, NULL);
  201. }
  202. /*
  203. * This is trivial, and on the face of it looks like it
  204. * could equally well be done in user mode.
  205. *
  206. * Not so, for quite unobvious reasons - register pressure.
  207. * In user mode vfork() cannot have a stack frame, and if
  208. * done by calling the "clone()" system call directly, you
  209. * do not have enough call-clobbered registers to hold all
  210. * the information you need.
  211. */
  212. int sys_vfork(struct pt_regs *regs)
  213. {
  214. return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp, regs, 0,
  215. NULL, NULL);
  216. }
  217. long
  218. sys_clone(unsigned long clone_flags, unsigned long newsp,
  219. void __user *parent_tid, void __user *child_tid, struct pt_regs *regs)
  220. {
  221. if (!newsp)
  222. newsp = regs->sp;
  223. return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
  224. }
  225. /*
  226. * This gets run with %si containing the
  227. * function to call, and %di containing
  228. * the "args".
  229. */
  230. extern void kernel_thread_helper(void);
  231. /*
  232. * Create a kernel thread
  233. */
  234. int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
  235. {
  236. struct pt_regs regs;
  237. memset(&regs, 0, sizeof(regs));
  238. regs.si = (unsigned long) fn;
  239. regs.di = (unsigned long) arg;
  240. #ifdef CONFIG_X86_32
  241. regs.ds = __USER_DS;
  242. regs.es = __USER_DS;
  243. regs.fs = __KERNEL_PERCPU;
  244. regs.gs = __KERNEL_STACK_CANARY;
  245. #else
  246. regs.ss = __KERNEL_DS;
  247. #endif
  248. regs.orig_ax = -1;
  249. regs.ip = (unsigned long) kernel_thread_helper;
  250. regs.cs = __KERNEL_CS | get_kernel_rpl();
  251. regs.flags = X86_EFLAGS_IF | 0x2;
  252. /* Ok, create the new process.. */
  253. return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
  254. }
  255. EXPORT_SYMBOL(kernel_thread);
  256. /*
  257. * sys_execve() executes a new program.
  258. */
  259. long sys_execve(char __user *name, char __user * __user *argv,
  260. char __user * __user *envp, struct pt_regs *regs)
  261. {
  262. long error;
  263. char *filename;
  264. filename = getname(name);
  265. error = PTR_ERR(filename);
  266. if (IS_ERR(filename))
  267. return error;
  268. error = do_execve(filename, argv, envp, regs);
  269. #ifdef CONFIG_X86_32
  270. if (error == 0) {
  271. /* Make sure we don't return using sysenter.. */
  272. set_thread_flag(TIF_IRET);
  273. }
  274. #endif
  275. putname(filename);
  276. return error;
  277. }
  278. /*
  279. * Idle related variables and functions
  280. */
  281. unsigned long boot_option_idle_override = 0;
  282. EXPORT_SYMBOL(boot_option_idle_override);
  283. /*
  284. * Powermanagement idle function, if any..
  285. */
  286. void (*pm_idle)(void);
  287. EXPORT_SYMBOL(pm_idle);
  288. #ifdef CONFIG_X86_32
  289. /*
  290. * This halt magic was a workaround for ancient floppy DMA
  291. * wreckage. It should be safe to remove.
  292. */
  293. static int hlt_counter;
  294. void disable_hlt(void)
  295. {
  296. hlt_counter++;
  297. }
  298. EXPORT_SYMBOL(disable_hlt);
  299. void enable_hlt(void)
  300. {
  301. hlt_counter--;
  302. }
  303. EXPORT_SYMBOL(enable_hlt);
  304. static inline int hlt_use_halt(void)
  305. {
  306. return (!hlt_counter && boot_cpu_data.hlt_works_ok);
  307. }
  308. #else
  309. static inline int hlt_use_halt(void)
  310. {
  311. return 1;
  312. }
  313. #endif
  314. /*
  315. * We use this if we don't have any better
  316. * idle routine..
  317. */
  318. void default_idle(void)
  319. {
  320. if (hlt_use_halt()) {
  321. trace_power_start(POWER_CSTATE, 1);
  322. current_thread_info()->status &= ~TS_POLLING;
  323. /*
  324. * TS_POLLING-cleared state must be visible before we
  325. * test NEED_RESCHED:
  326. */
  327. smp_mb();
  328. if (!need_resched())
  329. safe_halt(); /* enables interrupts racelessly */
  330. else
  331. local_irq_enable();
  332. current_thread_info()->status |= TS_POLLING;
  333. } else {
  334. local_irq_enable();
  335. /* loop is done by the caller */
  336. cpu_relax();
  337. }
  338. }
  339. #ifdef CONFIG_APM_MODULE
  340. EXPORT_SYMBOL(default_idle);
  341. #endif
  342. void stop_this_cpu(void *dummy)
  343. {
  344. local_irq_disable();
  345. /*
  346. * Remove this CPU:
  347. */
  348. set_cpu_online(smp_processor_id(), false);
  349. disable_local_APIC();
  350. for (;;) {
  351. if (hlt_works(smp_processor_id()))
  352. halt();
  353. }
  354. }
  355. static void do_nothing(void *unused)
  356. {
  357. }
  358. /*
  359. * cpu_idle_wait - Used to ensure that all the CPUs discard old value of
  360. * pm_idle and update to new pm_idle value. Required while changing pm_idle
  361. * handler on SMP systems.
  362. *
  363. * Caller must have changed pm_idle to the new value before the call. Old
  364. * pm_idle value will not be used by any CPU after the return of this function.
  365. */
  366. void cpu_idle_wait(void)
  367. {
  368. smp_mb();
  369. /* kick all the CPUs so that they exit out of pm_idle */
  370. smp_call_function(do_nothing, NULL, 1);
  371. }
  372. EXPORT_SYMBOL_GPL(cpu_idle_wait);
  373. /*
  374. * This uses new MONITOR/MWAIT instructions on P4 processors with PNI,
  375. * which can obviate IPI to trigger checking of need_resched.
  376. * We execute MONITOR against need_resched and enter optimized wait state
  377. * through MWAIT. Whenever someone changes need_resched, we would be woken
  378. * up from MWAIT (without an IPI).
  379. *
  380. * New with Core Duo processors, MWAIT can take some hints based on CPU
  381. * capability.
  382. */
  383. void mwait_idle_with_hints(unsigned long ax, unsigned long cx)
  384. {
  385. trace_power_start(POWER_CSTATE, (ax>>4)+1);
  386. if (!need_resched()) {
  387. if (cpu_has(&current_cpu_data, X86_FEATURE_CLFLUSH_MONITOR))
  388. clflush((void *)&current_thread_info()->flags);
  389. __monitor((void *)&current_thread_info()->flags, 0, 0);
  390. smp_mb();
  391. if (!need_resched())
  392. __mwait(ax, cx);
  393. }
  394. }
  395. /* Default MONITOR/MWAIT with no hints, used for default C1 state */
  396. static void mwait_idle(void)
  397. {
  398. if (!need_resched()) {
  399. trace_power_start(POWER_CSTATE, 1);
  400. if (cpu_has(&current_cpu_data, X86_FEATURE_CLFLUSH_MONITOR))
  401. clflush((void *)&current_thread_info()->flags);
  402. __monitor((void *)&current_thread_info()->flags, 0, 0);
  403. smp_mb();
  404. if (!need_resched())
  405. __sti_mwait(0, 0);
  406. else
  407. local_irq_enable();
  408. } else
  409. local_irq_enable();
  410. }
  411. /*
  412. * On SMP it's slightly faster (but much more power-consuming!)
  413. * to poll the ->work.need_resched flag instead of waiting for the
  414. * cross-CPU IPI to arrive. Use this option with caution.
  415. */
  416. static void poll_idle(void)
  417. {
  418. trace_power_start(POWER_CSTATE, 0);
  419. local_irq_enable();
  420. while (!need_resched())
  421. cpu_relax();
  422. trace_power_end(0);
  423. }
  424. /*
  425. * mwait selection logic:
  426. *
  427. * It depends on the CPU. For AMD CPUs that support MWAIT this is
  428. * wrong. Family 0x10 and 0x11 CPUs will enter C1 on HLT. Powersavings
  429. * then depend on a clock divisor and current Pstate of the core. If
  430. * all cores of a processor are in halt state (C1) the processor can
  431. * enter the C1E (C1 enhanced) state. If mwait is used this will never
  432. * happen.
  433. *
  434. * idle=mwait overrides this decision and forces the usage of mwait.
  435. */
  436. static int __cpuinitdata force_mwait;
  437. #define MWAIT_INFO 0x05
  438. #define MWAIT_ECX_EXTENDED_INFO 0x01
  439. #define MWAIT_EDX_C1 0xf0
  440. static int __cpuinit mwait_usable(const struct cpuinfo_x86 *c)
  441. {
  442. u32 eax, ebx, ecx, edx;
  443. if (force_mwait)
  444. return 1;
  445. if (c->cpuid_level < MWAIT_INFO)
  446. return 0;
  447. cpuid(MWAIT_INFO, &eax, &ebx, &ecx, &edx);
  448. /* Check, whether EDX has extended info about MWAIT */
  449. if (!(ecx & MWAIT_ECX_EXTENDED_INFO))
  450. return 1;
  451. /*
  452. * edx enumeratios MONITOR/MWAIT extensions. Check, whether
  453. * C1 supports MWAIT
  454. */
  455. return (edx & MWAIT_EDX_C1);
  456. }
  457. /*
  458. * Check for AMD CPUs, where APIC timer interrupt does not wake up CPU from C1e.
  459. * For more information see
  460. * - Erratum #400 for NPT family 0xf and family 0x10 CPUs
  461. * - Erratum #365 for family 0x11 (not affected because C1e not in use)
  462. */
  463. static int __cpuinit check_c1e_idle(const struct cpuinfo_x86 *c)
  464. {
  465. u64 val;
  466. if (c->x86_vendor != X86_VENDOR_AMD)
  467. goto no_c1e_idle;
  468. /* Family 0x0f models < rev F do not have C1E */
  469. if (c->x86 == 0x0F && c->x86_model >= 0x40)
  470. return 1;
  471. if (c->x86 == 0x10) {
  472. /*
  473. * check OSVW bit for CPUs that are not affected
  474. * by erratum #400
  475. */
  476. rdmsrl(MSR_AMD64_OSVW_ID_LENGTH, val);
  477. if (val >= 2) {
  478. rdmsrl(MSR_AMD64_OSVW_STATUS, val);
  479. if (!(val & BIT(1)))
  480. goto no_c1e_idle;
  481. }
  482. return 1;
  483. }
  484. no_c1e_idle:
  485. return 0;
  486. }
  487. static cpumask_var_t c1e_mask;
  488. static int c1e_detected;
  489. void c1e_remove_cpu(int cpu)
  490. {
  491. if (c1e_mask != NULL)
  492. cpumask_clear_cpu(cpu, c1e_mask);
  493. }
  494. /*
  495. * C1E aware idle routine. We check for C1E active in the interrupt
  496. * pending message MSR. If we detect C1E, then we handle it the same
  497. * way as C3 power states (local apic timer and TSC stop)
  498. */
  499. static void c1e_idle(void)
  500. {
  501. if (need_resched())
  502. return;
  503. if (!c1e_detected) {
  504. u32 lo, hi;
  505. rdmsr(MSR_K8_INT_PENDING_MSG, lo, hi);
  506. if (lo & K8_INTP_C1E_ACTIVE_MASK) {
  507. c1e_detected = 1;
  508. if (!boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
  509. mark_tsc_unstable("TSC halt in AMD C1E");
  510. printk(KERN_INFO "System has AMD C1E enabled\n");
  511. set_cpu_cap(&boot_cpu_data, X86_FEATURE_AMDC1E);
  512. }
  513. }
  514. if (c1e_detected) {
  515. int cpu = smp_processor_id();
  516. if (!cpumask_test_cpu(cpu, c1e_mask)) {
  517. cpumask_set_cpu(cpu, c1e_mask);
  518. /*
  519. * Force broadcast so ACPI can not interfere.
  520. */
  521. clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_FORCE,
  522. &cpu);
  523. printk(KERN_INFO "Switch to broadcast mode on CPU%d\n",
  524. cpu);
  525. }
  526. clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu);
  527. default_idle();
  528. /*
  529. * The switch back from broadcast mode needs to be
  530. * called with interrupts disabled.
  531. */
  532. local_irq_disable();
  533. clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu);
  534. local_irq_enable();
  535. } else
  536. default_idle();
  537. }
  538. void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
  539. {
  540. #ifdef CONFIG_SMP
  541. if (pm_idle == poll_idle && smp_num_siblings > 1) {
  542. printk_once(KERN_WARNING "WARNING: polling idle and HT enabled,"
  543. " performance may degrade.\n");
  544. }
  545. #endif
  546. if (pm_idle)
  547. return;
  548. if (cpu_has(c, X86_FEATURE_MWAIT) && mwait_usable(c)) {
  549. /*
  550. * One CPU supports mwait => All CPUs supports mwait
  551. */
  552. printk(KERN_INFO "using mwait in idle threads.\n");
  553. pm_idle = mwait_idle;
  554. } else if (check_c1e_idle(c)) {
  555. printk(KERN_INFO "using C1E aware idle routine\n");
  556. pm_idle = c1e_idle;
  557. } else
  558. pm_idle = default_idle;
  559. }
  560. void __init init_c1e_mask(void)
  561. {
  562. /* If we're using c1e_idle, we need to allocate c1e_mask. */
  563. if (pm_idle == c1e_idle)
  564. zalloc_cpumask_var(&c1e_mask, GFP_KERNEL);
  565. }
  566. static int __init idle_setup(char *str)
  567. {
  568. if (!str)
  569. return -EINVAL;
  570. if (!strcmp(str, "poll")) {
  571. printk("using polling idle threads.\n");
  572. pm_idle = poll_idle;
  573. } else if (!strcmp(str, "mwait"))
  574. force_mwait = 1;
  575. else if (!strcmp(str, "halt")) {
  576. /*
  577. * When the boot option of idle=halt is added, halt is
  578. * forced to be used for CPU idle. In such case CPU C2/C3
  579. * won't be used again.
  580. * To continue to load the CPU idle driver, don't touch
  581. * the boot_option_idle_override.
  582. */
  583. pm_idle = default_idle;
  584. idle_halt = 1;
  585. return 0;
  586. } else if (!strcmp(str, "nomwait")) {
  587. /*
  588. * If the boot option of "idle=nomwait" is added,
  589. * it means that mwait will be disabled for CPU C2/C3
  590. * states. In such case it won't touch the variable
  591. * of boot_option_idle_override.
  592. */
  593. idle_nomwait = 1;
  594. return 0;
  595. } else
  596. return -1;
  597. boot_option_idle_override = 1;
  598. return 0;
  599. }
  600. early_param("idle", idle_setup);
  601. unsigned long arch_align_stack(unsigned long sp)
  602. {
  603. if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
  604. sp -= get_random_int() % 8192;
  605. return sp & ~0xf;
  606. }
  607. unsigned long arch_randomize_brk(struct mm_struct *mm)
  608. {
  609. unsigned long range_end = mm->brk + 0x02000000;
  610. return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
  611. }