Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/arch/i386/i386/locore.S,v rcsdiff: /ftp/cvs/cvsroot/src/sys/arch/i386/i386/locore.S,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.48.8.7 retrieving revision 1.50.2.6 diff -u -p -r1.48.8.7 -r1.50.2.6 --- src/sys/arch/i386/i386/locore.S 2007/12/09 19:35:21 1.48.8.7 +++ src/sys/arch/i386/i386/locore.S 2007/10/04 15:04:31 1.50.2.6 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.48.8.7 2007/12/09 19:35:21 jmcneill Exp $ */ +/* $NetBSD: locore.S,v 1.50.2.6 2007/10/04 15:04:31 yamt Exp $ */ /* * Copyright-o-rama! @@ -111,6 +111,7 @@ */ #include "opt_compat_oldboot.h" +#include "opt_cputype.h" #include "opt_ddb.h" #include "opt_realmem.h" #include "opt_vm86.h" @@ -463,11 +464,10 @@ try586: /* Use the `cpuid' instruction. addl $PGOFSET,%esi # page align up andl $~PGOFSET,%esi - /* nkptp[1] = (esi + ~L2_FRAME) >> L2_SHIFT + 1; */ + /* nkptp = (esi + ~L2_FRAME) >> L2_SHIFT; */ movl %esi,%eax addl $~L2_FRAME,%eax shrl $L2_SHIFT,%eax - incl %eax /* one more ptp for VAs stolen by bootstrap */ 1: movl %eax,RELOC(nkptp)+1*4 /* tablesize = (1 + UPAGES + nkptp) << PGSHIFT; */ @@ -479,7 +479,6 @@ try586: /* Use the `cpuid' instruction. addl %esi,%eax addl $~L2_FRAME,%eax shrl $L2_SHIFT,%eax - incl %eax cmpl %eax,RELOC(nkptp)+1*4 jnz 1b @@ -503,6 +502,7 @@ try586: /* Use the `cpuid' instruction. * 32 bit mode. So use the bottom 32 bits. */ movl $RELOC(__data_start),%edx + addl $PGOFSET,%edx andl $~PGOFSET,%edx /* @@ -688,6 +688,47 @@ NENTRY(sigcode) _C_LABEL(esigcode): /* + * void lgdt(struct region_descriptor *rdp); + * + * Load a new GDT pointer (and do any necessary cleanup). + * XXX It's somewhat questionable whether reloading all the segment registers + * is necessary, since the actual descriptor data is not changed except by + * process creation and exit, both of which clean up via task switches. OTOH, + * this only happens at run time when the GDT is resized. + */ +NENTRY(lgdt) + /* Reload the descriptor table. */ + movl 4(%esp),%eax + lgdt (%eax) + /* Flush the prefetch queue. */ + jmp 1f + nop +1: /* Reload "stale" selectors. */ + movl $GSEL(GDATA_SEL, SEL_KPL),%eax + movw %ax,%ds + movw %ax,%es + movw %ax,%gs + movw %ax,%ss + movl $GSEL(GCPU_SEL, SEL_KPL),%eax + movw %ax,%fs + /* Reload code selector by doing intersegment return. */ + popl %eax + pushl $GSEL(GCODE_SEL, SEL_KPL) + pushl %eax + lret + +/* + * void x86_flush() + * + * Flush instruction pipelines by doing an intersegment (far) return. + */ +NENTRY(x86_flush) + popl %eax + pushl $GSEL(GCODE_SEL, SEL_KPL) + pushl %eax + lret + +/* * int setjmp(label_t *) * * Used primarily by DDB. @@ -722,8 +763,7 @@ ENTRY(longjmp) ret /* - * struct lwp *cpu_switchto(struct lwp *oldlwp, struct newlwp, - * bool returning) + * struct lwp *cpu_switchto(struct lwp *oldlwp, struct newlwp) * * 1. if (oldlwp != NULL), save its context. * 2. then, restore context of newlwp. @@ -739,7 +779,6 @@ ENTRY(cpu_switchto) movl 16(%esp),%esi # oldlwp movl 20(%esp),%edi # newlwp - movl 24(%esp),%edx # returning testl %esi,%esi jz 1f @@ -753,35 +792,21 @@ ENTRY(cpu_switchto) movl PCB_EBP(%ebx),%ebp movl PCB_ESP(%ebx),%esp - /* Set curlwp. */ - movl %edi,CPUVAR(CURLWP) - - /* Skip the rest if returning to a pinned LWP. */ - testl %edx,%edx - jnz 4f - /* Switch TSS. Reset "task busy" flag before loading. */ movl %cr3,%eax movl %eax,PCB_CR3(%ebx) # for TSS gates - movl CPUVAR(GDT),%ecx + movl CPUVAR(GDT),%eax movl L_MD_TSS_SEL(%edi),%edx - andl $~0x0200,4(%ecx,%edx, 1) + andl $~0x0200,4(%eax,%edx, 1) ltr %dx + /* Set curlwp. */ + movl %edi,CPUVAR(CURLWP) + /* Don't bother with the rest if switching to a system process. */ testl $LW_SYSTEM,L_FLAG(%edi) jnz 4f - /* Restore thread-private %fs/%gs descriptors. */ - movl PCB_FSD(%ebx), %eax - movl PCB_FSD+4(%ebx), %edx - movl %eax, (GUFS_SEL*8)(%ecx) - movl %edx, (GUFS_SEL*8+4)(%ecx) - movl PCB_GSD(%ebx), %eax - movl PCB_GSD+4(%ebx), %edx - movl %eax, (GUGS_SEL*8)(%ecx) - movl %edx, (GUGS_SEL*8+4)(%ecx) - /* Is this process using RAS (restartable atomic sequences)? */ movl L_PROC(%edi),%eax cmpl $0,P_RASLIST(%eax) @@ -911,9 +936,10 @@ syscall1: pushl $4f call _C_LABEL(printf) addl $4,%esp - pushl $IPL_NONE - call _C_LABEL(spllower) - addl $4,%esp +#ifdef DDB + int $3 +#endif /* DDB */ + movl $IPL_NONE,CPUVAR(ILEVEL) jmp .Lsyscall_checkast 4: .asciz "WARNING: SPL NOT LOWERED ON SYSCALL EXIT\n" 5: .asciz "WARNING: SPL NOT ZERO ON SYSCALL ENTRY\n"