patch-2.1.37 linux/arch/i386/kernel/process.c

Next file: linux/arch/i386/kernel/ptrace.c
Previous file: linux/arch/i386/kernel/irq.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.36/linux/arch/i386/kernel/process.c linux/arch/i386/kernel/process.c
@@ -30,6 +30,7 @@
 #include <linux/delay.h>
 #include <linux/smp.h>
 #include <linux/reboot.h>
+#include <linux/init.h>
 #if defined(CONFIG_APM) && defined(CONFIG_APM_POWER_OFF)
 #include <linux/apm_bios.h>
 #endif
@@ -149,7 +150,8 @@
 	current->priority = -100;
 	while(1)
 	{
-		if(cpu_data[smp_processor_id()].hlt_works_ok && !hlt_counter && !need_resched)
+		if(cpu_data[smp_processor_id()].hlt_works_ok &&
+		 		!hlt_counter && !need_resched)
 			__asm("hlt");
 		/*
 		 * tq_scheduler currently assumes we're running in a process
@@ -183,7 +185,7 @@
 static int reboot_mode = 0;
 static int reboot_thru_bios = 0;
 
-void reboot_setup(char *str, int *ints)
+__initfunc(void reboot_setup(char *str, int *ints))
 {
 	while(1) {
 		switch (*str) {
@@ -324,11 +326,14 @@
 
 	pg0 [0] = 7;
 
-	/* Use `swapper_pg_dir' as our page directory.  Don't bother with
-	   `SET_PAGE_DIR' because interrupts are disabled and we're rebooting.
-	   This instruction flushes the TLB. */
+	/*
+	 * Use `swapper_pg_dir' as our page directory.  We bother with
+	 * `SET_PAGE_DIR' because although might be rebooting, but if we change
+	 * the way we set root page dir in the future, then we wont break a
+	 * seldom used feature ;)
+	 */
 
-	__asm__ __volatile__ ("movl %0,%%cr3" : : "a" (swapper_pg_dir) : "memory");
+	SET_PAGE_DIR(current,swapper_pg_dir);
 
 	/* Write 0x1234 to absolute memory location 0x472.  The BIOS reads
 	   this on booting to tell it to "Bypass memory test (also warm
@@ -473,6 +478,8 @@
 	int i;
 	struct pt_regs * childregs;
 
+	p->tss.tr = _TSS(nr);
+	p->tss.ldt = _LDT(nr);
 	p->tss.es = KERNEL_DS;
 	p->tss.cs = KERNEL_CS;
 	p->tss.ss = KERNEL_DS;
@@ -480,9 +487,8 @@
 	p->tss.fs = USER_DS;
 	p->tss.gs = USER_DS;
 	p->tss.ss0 = KERNEL_DS;
-	p->tss.esp0 = p->kernel_stack_page + PAGE_SIZE;
-	p->tss.tr = _TSS(nr);
-	childregs = ((struct pt_regs *) (p->kernel_stack_page + PAGE_SIZE)) - 1;
+	p->tss.esp0 = 2*PAGE_SIZE + (unsigned long) p;
+	childregs = ((struct pt_regs *) (p->tss.esp0)) - 1;
 	p->tss.esp = (unsigned long) childregs;
 #ifdef __SMP__
 	p->tss.eip = (unsigned long) ret_from_smpfork;
@@ -496,7 +502,6 @@
 	childregs->eax = 0;
 	childregs->esp = esp;
 	p->tss.back_link = 0;
-	p->tss.ldt = _LDT(nr);
 	if (p->ldt) {
 		p->ldt = (struct desc_struct*) vmalloc(LDT_ENTRIES*LDT_ENTRY_SIZE);
 		if (p->ldt != NULL)
@@ -512,6 +517,7 @@
 		p->tss.io_bitmap[i] = ~0;
 	if (last_task_used_math == current)
 		__asm__("clts ; fnsave %0 ; frstor %0":"=m" (p->tss.i387));
+
 	return 0;
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov