vserver 1.9.3
[linux-2.6.git] / arch / ia64 / kernel / process.c
index 0d245cb..56ffa1a 100644 (file)
@@ -7,6 +7,7 @@
 #define __KERNEL_SYSCALLS__    /* see <asm/unistd.h> */
 #include <linux/config.h>
 
+#include <linux/cpu.h>
 #include <linux/pm.h>
 #include <linux/elf.h>
 #include <linux/errno.h>
@@ -14,6 +15,7 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/module.h>
+#include <linux/notifier.h>
 #include <linux/personality.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/thread_info.h>
 #include <linux/unistd.h>
 #include <linux/efi.h>
+#include <linux/interrupt.h>
 
+#include <asm/cpu.h>
 #include <asm/delay.h>
 #include <asm/elf.h>
 #include <asm/ia32.h>
+#include <asm/irq.h>
 #include <asm/pgalloc.h>
 #include <asm/processor.h>
 #include <asm/sal.h>
+#include <asm/tlbflush.h>
 #include <asm/uaccess.h>
 #include <asm/unwind.h>
 #include <asm/user.h>
@@ -68,12 +74,12 @@ void
 show_stack (struct task_struct *task, unsigned long *sp)
 {
        if (!task)
-               unw_init_running(ia64_do_show_stack, 0);
+               unw_init_running(ia64_do_show_stack, NULL);
        else {
                struct unw_frame_info info;
 
                unw_init_from_blocked_task(&info, task);
-               ia64_do_show_stack(&info, 0);
+               ia64_do_show_stack(&info, NULL);
        }
 }
 
@@ -90,6 +96,7 @@ show_regs (struct pt_regs *regs)
 {
        unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
 
+       print_modules();
        printk("\nPid: %d, CPU %d, comm: %20s\n", current->pid, smp_processor_id(), current->comm);
        printk("psr : %016lx ifs : %016lx ip  : [<%016lx>]    %s\n",
               regs->cr_ipsr, regs->cr_ifs, ip, print_tainted());
@@ -131,7 +138,7 @@ show_regs (struct pt_regs *regs)
                ndirty = (regs->loadrs >> 19);
                bsp = ia64_rse_skip_regs((unsigned long *) regs->ar_bspstore, ndirty);
                for (i = 0; i < sof; ++i) {
-                       get_user(val, ia64_rse_skip_regs(bsp, i));
+                       get_user(val, (unsigned long __user *) ia64_rse_skip_regs(bsp, i));
                        printk("r%-3u:%c%016lx%s", 32 + i, is_nat ? '*' : ' ', val,
                               ((i == sof - 1) || (i % 3) == 2) ? "\n" : " ");
                }
@@ -180,6 +187,40 @@ default_idle (void)
                        safe_halt();
 }
 
+#ifdef CONFIG_HOTPLUG_CPU
+/* We don't actually take CPU down, just spin without interrupts. */
+static inline void play_dead(void)
+{
+       extern void ia64_cpu_local_tick (void);
+       /* Ack it */
+       __get_cpu_var(cpu_state) = CPU_DEAD;
+
+       /* We shouldn't have to disable interrupts while dead, but
+        * some interrupts just don't seem to go away, and this makes
+        * it "work" for testing purposes. */
+       max_xtp();
+       local_irq_disable();
+       /* Death loop */
+       while (__get_cpu_var(cpu_state) != CPU_UP_PREPARE)
+               cpu_relax();
+
+       /*
+        * Enable timer interrupts from now on
+        * Not required if we put processor in SAL_BOOT_RENDEZ mode.
+        */
+       local_flush_tlb_all();
+       cpu_set(smp_processor_id(), cpu_online_map);
+       wmb();
+       ia64_cpu_local_tick ();
+       local_irq_enable();
+}
+#else
+static inline void play_dead(void)
+{
+       BUG();
+}
+#endif /* CONFIG_HOTPLUG_CPU */
+
 void __attribute__((noreturn))
 cpu_idle (void *unused)
 {
@@ -187,19 +228,26 @@ cpu_idle (void *unused)
 
        /* endless idle loop with no priority at all */
        while (1) {
-               void (*idle)(void) = pm_idle;
-               if (!idle)
-                       idle = default_idle;
-
 #ifdef CONFIG_SMP
                if (!need_resched())
                        min_xtp();
 #endif
-
                while (!need_resched()) {
+                       void (*idle)(void);
+
                        if (mark_idle)
                                (*mark_idle)(1);
+                       /*
+                        * Mark this as an RCU critical section so that
+                        * synchronize_kernel() in the unload path waits
+                        * for our completion.
+                        */
+                       rcu_read_lock();
+                       idle = pm_idle;
+                       if (!idle)
+                               idle = default_idle;
                        (*idle)();
+                       rcu_read_unlock();
                }
 
                if (mark_idle)
@@ -210,6 +258,8 @@ cpu_idle (void *unused)
 #endif
                schedule();
                check_pgt_cache();
+               if (cpu_is_offline(smp_processor_id()))
+                       play_dead();
        }
 }
 
@@ -397,6 +447,10 @@ copy_thread (int nr, unsigned long clone_flags,
                ia32_save_state(p);
                if (clone_flags & CLONE_SETTLS)
                        retval = ia32_clone_tls(p, child_ptregs);
+
+               /* Copy partially mapped page list */
+               if (!retval)
+                       retval = ia32_copy_partial_page_list(p, clone_flags);
        }
 #endif
 
@@ -556,30 +610,22 @@ dump_fpu (struct pt_regs *pt, elf_fpregset_t dst)
 }
 
 asmlinkage long
-sys_execve (char *filename, char **argv, char **envp, struct pt_regs *regs)
+sys_execve (char __user *filename, char __user * __user *argv, char __user * __user *envp,
+           struct pt_regs *regs)
 {
+       char *fname;
        int error;
 
-       filename = getname(filename);
-       error = PTR_ERR(filename);
-       if (IS_ERR(filename))
+       fname = getname(filename);
+       error = PTR_ERR(fname);
+       if (IS_ERR(fname))
                goto out;
-       error = do_execve(filename, argv, envp, regs);
-       putname(filename);
+       error = do_execve(fname, argv, envp, regs);
+       putname(fname);
 out:
        return error;
 }
 
-void
-ia64_set_personality (struct elf64_hdr *elf_ex, int ibcs2_interpreter)
-{
-       set_personality(PER_LINUX);
-       if (elf_ex->e_flags & EF_IA_64_LINUX_EXECUTABLE_STACK)
-               current->thread.flags |= IA64_THREAD_XSTACK;
-       else
-               current->thread.flags &= ~IA64_THREAD_XSTACK;
-}
-
 pid_t
 kernel_thread (int (*fn)(void *), void *arg, unsigned long flags)
 {
@@ -630,6 +676,8 @@ flush_thread (void)
        /* drop floating-point and debug-register state if it exists: */
        current->thread.flags &= ~(IA64_THREAD_FPH_VALID | IA64_THREAD_DBG_VALID);
        ia64_drop_fpu(current);
+       if (IS_IA32_PROCESS(ia64_task_regs(current)))
+               ia32_drop_partial_page_list(current);
 }
 
 /*
@@ -649,6 +697,8 @@ exit_thread (void)
        if (current->thread.flags & IA64_THREAD_DBG_VALID)
                pfm_release_debug_registers(current);
 #endif
+       if (IS_IA32_PROCESS(ia64_task_regs(current)))
+               ia32_drop_partial_page_list(current);
 }
 
 unsigned long
@@ -657,11 +707,6 @@ get_wchan (struct task_struct *p)
        struct unw_frame_info info;
        unsigned long ip;
        int count = 0;
-       /*
-        * These bracket the sleeping functions..
-        */
-#      define first_sched      ((unsigned long) scheduling_functions_start_here)
-#      define last_sched       ((unsigned long) scheduling_functions_end_here)
 
        /*
         * Note: p may not be a blocked task (it could be current or
@@ -676,12 +721,10 @@ get_wchan (struct task_struct *p)
                if (unw_unwind(&info) < 0)
                        return 0;
                unw_get_ip(&info, &ip);
-               if (ip < first_sched || ip >= last_sched)
+               if (!in_sched_functions(ip))
                        return ip;
        } while (count++ < 16);
        return 0;
-#      undef first_sched
-#      undef last_sched
 }
 
 void
@@ -710,7 +753,7 @@ cpu_halt (void)
 void
 machine_restart (char *restart_cmd)
 {
-       (*efi.reset_system)(EFI_RESET_WARM, 0, 0, 0);
+       (*efi.reset_system)(EFI_RESET_WARM, 0, 0, NULL);
 }
 
 EXPORT_SYMBOL(machine_restart);