Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq
[safe/jmp/linux-2.6] / arch / x86 / kernel / process.c
index 8c03705..994dd6a 100644 (file)
@@ -8,12 +8,15 @@
 #include <linux/module.h>
 #include <linux/pm.h>
 #include <linux/clockchips.h>
+#include <linux/random.h>
 #include <trace/power.h>
 #include <asm/system.h>
 #include <asm/apic.h>
+#include <asm/syscalls.h>
 #include <asm/idle.h>
 #include <asm/uaccess.h>
 #include <asm/i387.h>
+#include <asm/ds.h>
 
 unsigned long idle_halt;
 EXPORT_SYMBOL(idle_halt);
@@ -45,6 +48,8 @@ void free_thread_xstate(struct task_struct *tsk)
                kmem_cache_free(task_xstate_cachep, tsk->thread.xstate);
                tsk->thread.xstate = NULL;
        }
+
+       WARN(tsk->thread.ds_ctx, "leaking DS context\n");
 }
 
 void free_thread_info(struct thread_info *ti)
@@ -58,7 +63,7 @@ void arch_task_cache_init(void)
         task_xstate_cachep =
                kmem_cache_create("task_xstate", xstate_size,
                                  __alignof__(union thread_xstate),
-                                 SLAB_PANIC, NULL);
+                                 SLAB_PANIC | SLAB_NOTRACK, NULL);
 }
 
 /*
@@ -68,11 +73,11 @@ void exit_thread(void)
 {
        struct task_struct *me = current;
        struct thread_struct *t = &me->thread;
+       unsigned long *bp = t->io_bitmap_ptr;
 
-       if (me->thread.io_bitmap_ptr) {
+       if (bp) {
                struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
 
-               kfree(t->io_bitmap_ptr);
                t->io_bitmap_ptr = NULL;
                clear_thread_flag(TIF_IO_BITMAP);
                /*
@@ -81,9 +86,8 @@ void exit_thread(void)
                memset(tss->io_bitmap, 0xff, t->io_bitmap_max);
                t->io_bitmap_max = 0;
                put_cpu();
+               kfree(bp);
        }
-
-       ds_exit_thread(current);
 }
 
 void flush_thread(void)
@@ -327,7 +331,7 @@ void stop_this_cpu(void *dummy)
        /*
         * Remove this CPU:
         */
-       cpu_clear(smp_processor_id(), cpu_online_map);
+       set_cpu_online(smp_processor_id(), false);
        disable_local_APIC();
 
        for (;;) {
@@ -477,12 +481,13 @@ static int __cpuinit check_c1e_idle(const struct cpuinfo_x86 *c)
        return 1;
 }
 
-static cpumask_t c1e_mask = CPU_MASK_NONE;
+static cpumask_var_t c1e_mask;
 static int c1e_detected;
 
 void c1e_remove_cpu(int cpu)
 {
-       cpu_clear(cpu, c1e_mask);
+       if (c1e_mask != NULL)
+               cpumask_clear_cpu(cpu, c1e_mask);
 }
 
 /*
@@ -511,8 +516,8 @@ static void c1e_idle(void)
        if (c1e_detected) {
                int cpu = smp_processor_id();
 
-               if (!cpu_isset(cpu, c1e_mask)) {
-                       cpu_set(cpu, c1e_mask);
+               if (!cpumask_test_cpu(cpu, c1e_mask)) {
+                       cpumask_set_cpu(cpu, c1e_mask);
                        /*
                         * Force broadcast so ACPI can not interfere. Needs
                         * to run with interrupts enabled as it uses
@@ -564,6 +569,15 @@ void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
                pm_idle = default_idle;
 }
 
+void __init init_c1e_mask(void)
+{
+       /* If we're using c1e_idle, we need to allocate c1e_mask. */
+       if (pm_idle == c1e_idle) {
+               alloc_cpumask_var(&c1e_mask, GFP_KERNEL);
+               cpumask_clear(c1e_mask);
+       }
+}
+
 static int __init idle_setup(char *str)
 {
        if (!str)
@@ -602,3 +616,16 @@ static int __init idle_setup(char *str)
 }
 early_param("idle", idle_setup);
 
+unsigned long arch_align_stack(unsigned long sp)
+{
+       if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
+               sp -= get_random_int() % 8192;
+       return sp & ~0xf;
+}
+
+unsigned long arch_randomize_brk(struct mm_struct *mm)
+{
+       unsigned long range_end = mm->brk + 0x02000000;
+       return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
+}
+