diff -urN kernels/2.4/v2.4.13-ac8/arch/i386/kernel/entry.S v2.4.13-ac8+tr/arch/i386/kernel/entry.S --- kernels/2.4/v2.4.13-ac8/arch/i386/kernel/entry.S Tue Nov 6 20:43:22 2001 +++ v2.4.13-ac8+tr/arch/i386/kernel/entry.S Wed Nov 7 02:58:41 2001 @@ -45,6 +45,7 @@ #include #include #include +#include EBX = 0x00 ECX = 0x04 @@ -134,9 +135,6 @@ .long 3b,6b; \ .previous -#define GET_CURRENT(reg) \ - movl %cr2, reg - ENTRY(lcall7) pushfl # We get a different stack layout with call gates, pushl %eax # which has to be cleaned up later.. @@ -149,7 +147,7 @@ movl %ecx,CS(%esp) # movl %esp,%ebx pushl %ebx - GET_CURRENT(%ebx) + GET_CURRENT(%ebx,%bx) movl exec_domain(%ebx),%edx # Get the execution domain movl 4(%edx),%edx # Get the lcall7 handler for the domain pushl $0x7 @@ -170,7 +168,7 @@ movl %ecx,CS(%esp) # movl %esp,%ebx pushl %ebx - GET_CURRENT(%ebx) + GET_CURRENT(%ebx,%bx) movl exec_domain(%ebx),%edx # Get the execution domain movl 4(%edx),%edx # Get the lcall7 handler for the domain pushl $0x27 @@ -184,7 +182,7 @@ pushl %ebx call SYMBOL_NAME(schedule_tail) addl $4, %esp - GET_CURRENT(%ebx) + GET_CURRENT(%ebx,%bx) testb $0x02,tsk_ptrace(%ebx) # PT_TRACESYS jne tracesys_exit jmp ret_from_sys_call @@ -199,7 +197,7 @@ ENTRY(system_call) pushl %eax # save orig_eax SAVE_ALL - GET_CURRENT(%ebx) + GET_CURRENT(%ebx,%bx) cmpl $(NR_syscalls),%eax jae badsys testb $0x02,tsk_ptrace(%ebx) # PT_TRACESYS @@ -251,7 +249,7 @@ ALIGN ENTRY(ret_from_intr) - GET_CURRENT(%ebx) + GET_CURRENT(%ebx,%bx) ret_from_exception: movl EFLAGS(%esp),%eax # mix EFLAGS and CS movb CS(%esp),%al @@ -297,7 +295,7 @@ movl %edx,%ds 2: call *%edi addl $8,%esp - GET_CURRENT(%ebx) + GET_CURRENT(%ebx,%bx) jmp ret_from_exception ENTRY(coprocessor_error) @@ -313,7 +311,7 @@ ENTRY(device_not_available) pushl $-1 # mark this as an int SAVE_ALL - GET_CURRENT(%ebx) + GET_CURRENT(%ebx,%bx) movl %cr0,%eax testl $0x4,%eax # EM (math emulation bit) jne device_not_available_emulate diff -urN kernels/2.4/v2.4.13-ac8/arch/i386/kernel/ldt.c v2.4.13-ac8+tr/arch/i386/kernel/ldt.c --- kernels/2.4/v2.4.13-ac8/arch/i386/kernel/ldt.c Thu Nov 1 16:39:57 2001 +++ v2.4.13-ac8+tr/arch/i386/kernel/ldt.c Tue Nov 6 21:23:03 2001 @@ -17,6 +17,7 @@ #include #include #include +#include /* * read_ldt() is not really atomic - this is not a problem since diff -urN kernels/2.4/v2.4.13-ac8/arch/i386/kernel/nmi.c v2.4.13-ac8+tr/arch/i386/kernel/nmi.c --- kernels/2.4/v2.4.13-ac8/arch/i386/kernel/nmi.c Tue Nov 6 20:43:22 2001 +++ v2.4.13-ac8+tr/arch/i386/kernel/nmi.c Tue Nov 6 23:13:03 2001 @@ -264,7 +264,7 @@ /* * NMI can interrupt page faults, use hard_get_current. */ - int sum, cpu = hard_get_current()->processor; + int sum, cpu = smp_processor_id(); sum = apic_timer_irqs[cpu]; @@ -280,7 +280,6 @@ * We are in trouble anyway, lets at least try * to get a message out. */ - set_current(hard_get_current()); bust_spinlocks(1); printk("NMI Watchdog detected LOCKUP on CPU%d, registers:\n", cpu); show_registers(regs); diff -urN kernels/2.4/v2.4.13-ac8/arch/i386/kernel/setup.c v2.4.13-ac8+tr/arch/i386/kernel/setup.c --- kernels/2.4/v2.4.13-ac8/arch/i386/kernel/setup.c Tue Nov 6 20:43:22 2001 +++ v2.4.13-ac8+tr/arch/i386/kernel/setup.c Wed Nov 7 00:49:49 2001 @@ -108,6 +108,7 @@ #include #include #include +#include #include #include #include @@ -2852,8 +2853,9 @@ */ void __init cpu_init (void) { - int nr = smp_processor_id(); + int nr = hard_smp_processor_id(); struct tss_struct * t = &init_tss[nr]; + struct task_struct *cur; if (test_and_set_bit(nr, &cpu_initialized)) { printk(KERN_WARNING "CPU#%d already initialized!\n", nr); @@ -2884,17 +2886,20 @@ * set up and load the per-CPU TSS and LDT */ atomic_inc(&init_mm.mm_count); - current->active_mm = &init_mm; - if(current->mm) - BUG(); - enter_lazy_tlb(&init_mm, current, nr); + cur = hard_get_current(); - t->esp0 = current->thread.esp0; + t->esp0 = cur->thread.esp0; set_tss_desc(nr,t); gdt_table[__TSS(nr)].b &= 0xfffffdff; load_TR(nr); load_LDT(&init_mm); + set_current(cur); + cur->active_mm = &init_mm; + if(cur->mm) + BUG(); + enter_lazy_tlb(&init_mm, cur, nr); + /* * Clear all 6 debug registers: */ diff -urN kernels/2.4/v2.4.13-ac8/arch/i386/kernel/smp.c v2.4.13-ac8+tr/arch/i386/kernel/smp.c --- kernels/2.4/v2.4.13-ac8/arch/i386/kernel/smp.c Thu Nov 1 16:39:57 2001 +++ v2.4.13-ac8+tr/arch/i386/kernel/smp.c Tue Nov 6 23:34:00 2001 @@ -22,6 +22,8 @@ #include #include +struct task_struct *per_cpu_tasks[256]; + /* * Some notes on x86 processor bugs affecting SMP operation: * diff -urN kernels/2.4/v2.4.13-ac8/arch/i386/lib/getuser.S v2.4.13-ac8+tr/arch/i386/lib/getuser.S --- kernels/2.4/v2.4.13-ac8/arch/i386/lib/getuser.S Tue Nov 6 20:43:22 2001 +++ v2.4.13-ac8+tr/arch/i386/lib/getuser.S Wed Nov 7 02:58:08 2001 @@ -8,6 +8,7 @@ * return an error value in addition to the "real" * return value. */ +#include /* * __get_user_X @@ -27,7 +28,7 @@ .align 4 .globl __get_user_1 __get_user_1: - movl %cr2,%edx + GET_CURRENT(%edx,%dx) cmpl addr_limit(%edx),%eax jae bad_get_user 1: movzbl (%eax),%edx @@ -39,7 +40,7 @@ __get_user_2: addl $1,%eax jc bad_get_user - movl %cr2,%edx + GET_CURRENT(%edx,%dx) cmpl addr_limit(%edx),%eax jae bad_get_user 2: movzwl -1(%eax),%edx @@ -51,7 +52,7 @@ __get_user_4: addl $3,%eax jc bad_get_user - movl %cr2,%edx + GET_CURRENT(%edx,%dx) cmpl addr_limit(%edx),%eax jae bad_get_user 3: movl -3(%eax),%edx diff -urN kernels/2.4/v2.4.13-ac8/arch/i386/mm/fault.c v2.4.13-ac8+tr/arch/i386/mm/fault.c --- kernels/2.4/v2.4.13-ac8/arch/i386/mm/fault.c Tue Nov 6 20:43:22 2001 +++ v2.4.13-ac8+tr/arch/i386/mm/fault.c Tue Nov 6 23:15:35 2001 @@ -148,7 +148,6 @@ } asmlinkage void do_invalid_op(struct pt_regs *, unsigned long); -extern unsigned long idt; /* * This routine handles page faults. It determines the address, @@ -173,14 +172,13 @@ /* get the address */ __asm__("movl %%cr2,%0":"=r" (address)); - /* and restore current */ - tsk = hard_get_current(); - set_current(tsk); /* It's safe to allow irq's after cr2 has been saved */ if (regs->eflags & X86_EFLAGS_IF) local_irq_enable(); + tsk = current; + /* * We fault-in kernel-space virtual memory on-demand. The * 'reference' page table is init_mm.pgd. @@ -309,7 +307,7 @@ if (boot_cpu_data.f00f_bug) { unsigned long nr; - nr = (address - idt) >> 3; + nr = (address - (unsigned long)idt) >> 3; if (nr == 6) { do_invalid_op(regs, 0); diff -urN kernels/2.4/v2.4.13-ac8/include/asm-i386/current.h v2.4.13-ac8+tr/include/asm-i386/current.h --- kernels/2.4/v2.4.13-ac8/include/asm-i386/current.h Tue Nov 6 20:43:27 2001 +++ v2.4.13-ac8+tr/include/asm-i386/current.h Wed Nov 7 00:05:21 2001 @@ -1,13 +1,12 @@ #ifndef _I386_CURRENT_H #define _I386_CURRENT_H +extern struct task_struct *per_cpu_tasks[256]; struct task_struct; static inline struct task_struct * get_current(void) { - struct task_struct *tsk; - __asm__("movl %%cr2,%0;": "=r" (tsk)); - return tsk; + return per_cpu_tasks[smp_processor_id()]; } /* for within NMI, do_page_fault, cpu_init */ @@ -20,9 +19,7 @@ static inline void set_current(struct task_struct *tsk) { - __asm__("movl %0,%%cr2;" - : /* no output */ - :"r" (tsk)); + per_cpu_tasks[smp_processor_id()] = tsk; } /* Note: the implementation is hardcoded into arch/i386/lib/getuser.S */ diff -urN kernels/2.4/v2.4.13-ac8/include/asm-i386/current_asm.h v2.4.13-ac8+tr/include/asm-i386/current_asm.h --- kernels/2.4/v2.4.13-ac8/include/asm-i386/current_asm.h Wed Dec 31 19:00:00 1969 +++ v2.4.13-ac8+tr/include/asm-i386/current_asm.h Wed Nov 7 02:59:38 2001 @@ -0,0 +1,7 @@ +#define GET_CURRENT(reg, regw) \ + movl $0,reg \ + ; str regw \ + ; shrl $3,reg \ + ; subl $20,reg \ + ; movl per_cpu_tasks(reg),reg + diff -urN kernels/2.4/v2.4.13-ac8/include/asm-i386/desc.h v2.4.13-ac8+tr/include/asm-i386/desc.h --- kernels/2.4/v2.4.13-ac8/include/asm-i386/desc.h Tue Nov 6 20:43:27 2001 +++ v2.4.13-ac8+tr/include/asm-i386/desc.h Tue Nov 6 21:21:32 2001 @@ -68,40 +68,6 @@ #define __load_LDT(n) __asm__ __volatile__("lldt %%ax"::"a" (__LDT(n)<<3)) -/* - * This is the ldt that every process will get unless we need - * something other than this. - */ -extern struct desc_struct default_ldt[]; -extern void set_intr_gate(unsigned int irq, void * addr); -extern void set_ldt_desc(unsigned int n, void *addr, unsigned int size); -extern void set_tss_desc(unsigned int n, void *addr); - -static inline void clear_LDT(void) -{ - int cpu = smp_processor_id(); - set_ldt_desc(cpu, &default_ldt[0], 5); - __load_LDT(cpu); -} - -/* - * load one particular LDT into the current CPU - */ -static inline void load_LDT (struct mm_struct *mm) -{ - int cpu = smp_processor_id(); - void *segments = mm->context.segments; - int count = LDT_ENTRIES; - - if (!segments) { - segments = &default_ldt[0]; - count = 5; - } - - set_ldt_desc(cpu, segments, count); - __load_LDT(cpu); -} - #endif /* !__ASSEMBLY__ */ #endif diff -urN kernels/2.4/v2.4.13-ac8/include/asm-i386/descfn.h v2.4.13-ac8+tr/include/asm-i386/descfn.h --- kernels/2.4/v2.4.13-ac8/include/asm-i386/descfn.h Wed Dec 31 19:00:00 1969 +++ v2.4.13-ac8+tr/include/asm-i386/descfn.h Tue Nov 6 21:23:59 2001 @@ -0,0 +1,42 @@ +#ifndef __ARCH_DESCFN_H +#define __ARCH_DESCFN_H + +#ifndef __ARCH_DESC_H +#include +#endif + +/* + * This is the ldt that every process will get unless we need + * something other than this. + */ +extern struct desc_struct default_ldt[]; +extern void set_intr_gate(unsigned int irq, void * addr); +extern void set_ldt_desc(unsigned int n, void *addr, unsigned int size); +extern void set_tss_desc(unsigned int n, void *addr); + +static inline void clear_LDT(void) +{ + int cpu = smp_processor_id(); + set_ldt_desc(cpu, &default_ldt[0], 5); + __load_LDT(cpu); +} + +/* + * load one particular LDT into the current CPU + */ +static inline void load_LDT (struct mm_struct *mm) +{ + int cpu = smp_processor_id(); + void *segments = mm->context.segments; + int count = LDT_ENTRIES; + + if (!segments) { + segments = &default_ldt[0]; + count = 5; + } + + set_ldt_desc(cpu, segments, count); + __load_LDT(cpu); +} + +#endif /* __ARCH_DESCFN_H */ diff -urN kernels/2.4/v2.4.13-ac8/include/asm-i386/mmu_context.h v2.4.13-ac8+tr/include/asm-i386/mmu_context.h --- kernels/2.4/v2.4.13-ac8/include/asm-i386/mmu_context.h Tue Nov 6 21:23:24 2001 +++ v2.4.13-ac8+tr/include/asm-i386/mmu_context.h Wed Nov 7 02:19:33 2001 @@ -5,6 +5,7 @@ #include #include #include +#include /* * possibly do the LDT unload here? diff -urN kernels/2.4/v2.4.13-ac8/include/asm-i386/smp.h v2.4.13-ac8+tr/include/asm-i386/smp.h --- kernels/2.4/v2.4.13-ac8/include/asm-i386/smp.h Tue Nov 6 21:00:35 2001 +++ v2.4.13-ac8+tr/include/asm-i386/smp.h Wed Nov 7 02:19:26 2001 @@ -8,6 +8,7 @@ #include #include #include +#include #endif #ifdef CONFIG_X86_LOCAL_APIC @@ -101,7 +102,11 @@ * so this is correct in the x86 case. */ -#define smp_processor_id() (current->processor) +#define smp_processor_id() ({ \ + unsigned short tr; \ + __asm__("str %0" : "=g" (tr)); \ + ((tr >> 3) - __FIRST_TSS_ENTRY) >> 2; \ +}) static __inline int hard_smp_processor_id(void) {