From 17a9f5662ecdd42507817765d19233858de681d1 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sat, 28 Jun 2003 02:09:52 +0000 Subject: [PATCH] smp/up collapse stage 1 of 2: Make UP use the globaldata structure the same way SMP does, and start removing all the bad macros and hacks that existed before. --- sys/cpu/i386/include/cpufunc.h | 33 ++-- sys/cpu/i386/include/npx.h | 5 +- sys/cpu/i386/include/pmap.h | 14 +- sys/cpu/i386/include/segments.h | 5 +- sys/cpu/i386/include/types.h | 5 +- sys/i386/i386/bios.c | 9 +- sys/i386/i386/exception.s | 15 +- sys/i386/i386/genassym.c | 11 +- sys/i386/i386/globals.s | 16 +- sys/i386/i386/locore.s | 45 +++--- sys/i386/i386/machdep.c | 56 +++---- sys/i386/i386/mp_machdep.c | 28 +--- sys/i386/i386/pmap.c | 208 ++++++++----------------- sys/i386/i386/support.s | 4 +- sys/i386/i386/swtch.s | 17 +- sys/i386/i386/sys_machdep.c | 6 +- sys/i386/i386/trap.c | 10 +- sys/i386/icu/icu_vector.s | 4 +- sys/i386/include/asnames.h | 9 +- sys/i386/include/cpufunc.h | 33 ++-- sys/i386/include/globaldata.h | 11 +- sys/i386/include/globals.h | 14 +- sys/i386/include/npx.h | 5 +- sys/i386/include/pcb.h | 4 +- sys/i386/include/pmap.h | 14 +- sys/i386/include/segments.h | 5 +- sys/i386/include/types.h | 5 +- sys/i386/isa/icu_vector.s | 4 +- sys/kern/init_main.c | 9 +- sys/kern/kern_synch.c | 3 +- sys/platform/pc32/i386/bios.c | 9 +- sys/platform/pc32/i386/exception.s | 15 +- sys/platform/pc32/i386/genassym.c | 11 +- sys/platform/pc32/i386/globals.s | 16 +- sys/platform/pc32/i386/locore.s | 45 +++--- sys/platform/pc32/i386/machdep.c | 56 +++---- sys/platform/pc32/i386/mp_machdep.c | 28 +--- sys/platform/pc32/i386/pmap.c | 208 ++++++++----------------- sys/platform/pc32/i386/support.s | 4 +- sys/platform/pc32/i386/swtch.s | 17 +- sys/platform/pc32/i386/sys_machdep.c | 6 +- sys/platform/pc32/i386/trap.c | 10 +- sys/platform/pc32/icu/icu_vector.s | 4 +- sys/platform/pc32/include/asnames.h | 9 +- sys/platform/pc32/include/globaldata.h | 11 +- sys/platform/pc32/include/globals.h | 14 +- sys/platform/pc32/include/pcb.h | 4 +- sys/platform/pc32/isa/icu_vector.s | 4 +- sys/platform/vkernel/i386/genassym.c | 11 +- sys/sys/systm.h | 4 +- 50 files changed, 402 insertions(+), 691 deletions(-) diff --git a/sys/cpu/i386/include/cpufunc.h b/sys/cpu/i386/include/cpufunc.h index 34be0732e4..14afba9018 100644 --- a/sys/cpu/i386/include/cpufunc.h +++ b/sys/cpu/i386/include/cpufunc.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/cpufunc.h,v 1.96.2.3 2002/04/28 22:50:54 dwmalone Exp $ - * $DragonFly: src/sys/cpu/i386/include/cpufunc.h,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/cpu/i386/include/cpufunc.h,v 1.3 2003/06/28 02:09:49 dillon Exp $ */ /* @@ -243,22 +243,29 @@ invd(void) __asm __volatile("invd"); } -#if defined(SMP) && defined(_KERNEL) +#if defined(_KERNEL) /* - * When using APIC IPI's, invlpg() is not simply the invlpg instruction - * (this is a bug) and the inlining cost is prohibitive since the call - * executes into the IPI transmission system. + * If we are not a true-SMP box then smp_invltlb() is a NOP. Note that this + * will cause the invl*() functions to be equivalent to the cpu_invl*() + * functions. */ -void invlpg __P((u_int addr)); -void invltlb __P((void)); +#ifndef SMP +#define smp_invltlb() +#endif +/* + * Invalidate a patricular VA on this cpu only + */ static __inline void cpu_invlpg(void *addr) { __asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory"); } +/* + * Invalidate the TLB on this cpu only + */ static __inline void cpu_invltlb(void) { @@ -274,14 +281,19 @@ cpu_invltlb(void) #endif } -#else /* !(SMP && _KERNEL) */ - +/* + * Invalidate a patricular VA on all cpus + */ static __inline void invlpg(u_int addr) { __asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory"); + smp_invltlb(); } +/* + * Invalidate the TLB on all cpus + */ static __inline void invltlb(void) { @@ -292,12 +304,13 @@ invltlb(void) */ __asm __volatile("movl %%cr3, %0; movl %0, %%cr3" : "=r" (temp) : : "memory"); + smp_invltlb(); #ifdef SWTCH_OPTIM_STATS ++tlb_flush_count; #endif } -#endif /* SMP && _KERNEL */ +#endif /* _KERNEL */ static __inline u_short inw(u_int port) diff --git a/sys/cpu/i386/include/npx.h b/sys/cpu/i386/include/npx.h index eb8c492c9c..ceeba29f1f 100644 --- a/sys/cpu/i386/include/npx.h +++ b/sys/cpu/i386/include/npx.h @@ -35,7 +35,7 @@ * * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 * $FreeBSD: src/sys/i386/include/npx.h,v 1.18.2.1 2001/08/15 01:23:52 peter Exp $ - * $DragonFly: src/sys/cpu/i386/include/npx.h,v 1.3 2003/06/18 07:04:28 dillon Exp $ + * $DragonFly: src/sys/cpu/i386/include/npx.h,v 1.4 2003/06/28 02:09:49 dillon Exp $ */ /* @@ -144,9 +144,6 @@ union savefpu { #define __INITIAL_NPXCW__ 0x127F #ifdef _KERNEL -#ifndef npxthread -extern struct thread *npxthread; -#endif int npxdna __P((void)); void npxexit __P((struct proc *p)); diff --git a/sys/cpu/i386/include/pmap.h b/sys/cpu/i386/include/pmap.h index dc0a93272d..7649b5b1d6 100644 --- a/sys/cpu/i386/include/pmap.h +++ b/sys/cpu/i386/include/pmap.h @@ -43,7 +43,7 @@ * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/include/pmap.h,v 1.65.2.3 2001/10/03 07:15:37 peter Exp $ - * $DragonFly: src/sys/cpu/i386/include/pmap.h,v 1.2 2003/06/17 04:28:36 dillon Exp $ + * $DragonFly: src/sys/cpu/i386/include/pmap.h,v 1.3 2003/06/28 02:09:49 dillon Exp $ */ #ifndef _MACHINE_PMAP_H_ @@ -101,11 +101,10 @@ #define NKPT 30 /* actual number of kernel page tables */ #endif #ifndef NKPDE -#ifdef SMP #define NKPDE (KVA_PAGES - 2) /* addressable number of page tables/pde's */ -#else -#define NKPDE (KVA_PAGES - 1) /* addressable number of page tables/pde's */ #endif +#if NKPDE > KVA_PAGES - 2 +#error "Maximum NKPDE is KVA_PAGES - 2" #endif /* @@ -117,12 +116,8 @@ * SMP_PRIVPAGES: The per-cpu address space is 0xff80000 -> 0xffbfffff */ #define APTDPTDI (NPDEPG-1) /* alt ptd entry that points to APTD */ -#ifdef SMP #define MPPTDI (APTDPTDI-1) /* per cpu ptd entry */ #define KPTDI (MPPTDI-NKPDE) /* start of kernel virtual pde's */ -#else -#define KPTDI (APTDPTDI-NKPDE)/* start of kernel virtual pde's */ -#endif /* SMP */ #define PTDPTDI (KPTDI-1) /* ptd entry that points to ptd! */ #define UMAXPTDI (PTDPTDI-1) /* ptd entry for user space end */ #define UMAXPTEOFF (NPTEPG) /* pte entry for user space end */ @@ -137,9 +132,6 @@ #include -typedef unsigned int *pd_entry_t; -typedef unsigned int *pt_entry_t; - #define PDESIZE sizeof(pd_entry_t) /* for assembly files */ #define PTESIZE sizeof(pt_entry_t) /* for assembly files */ diff --git a/sys/cpu/i386/include/segments.h b/sys/cpu/i386/include/segments.h index bf52b0f3f0..7e7b6ebd98 100644 --- a/sys/cpu/i386/include/segments.h +++ b/sys/cpu/i386/include/segments.h @@ -36,7 +36,7 @@ * * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 * $FreeBSD: src/sys/i386/include/segments.h,v 1.24 1999/12/29 04:33:07 peter Exp $ - * $DragonFly: src/sys/cpu/i386/include/segments.h,v 1.2 2003/06/17 04:28:36 dillon Exp $ + * $DragonFly: src/sys/cpu/i386/include/segments.h,v 1.3 2003/06/28 02:09:49 dillon Exp $ */ #ifndef _MACHINE_SEGMENTS_H_ @@ -244,9 +244,6 @@ struct region_descriptor { #define NLDT (LBSDICALLS_SEL + 1) #ifdef _KERNEL -#ifndef currentldt -extern int currentldt; -#endif extern int _default_ldt; extern union descriptor gdt[]; extern struct soft_segment_descriptor gdt_segs[]; diff --git a/sys/cpu/i386/include/types.h b/sys/cpu/i386/include/types.h index 953bbad918..797c3da0ad 100644 --- a/sys/cpu/i386/include/types.h +++ b/sys/cpu/i386/include/types.h @@ -32,7 +32,7 @@ * * @(#)types.h 8.3 (Berkeley) 1/5/94 * $FreeBSD: src/sys/i386/include/types.h,v 1.19.2.1 2001/03/21 10:50:58 peter Exp $ - * $DragonFly: src/sys/cpu/i386/include/types.h,v 1.2 2003/06/17 04:28:36 dillon Exp $ + * $DragonFly: src/sys/cpu/i386/include/types.h,v 1.3 2003/06/28 02:09:49 dillon Exp $ */ #ifndef _MACHINE_TYPES_H_ @@ -61,6 +61,9 @@ typedef int intfptr_t; typedef unsigned int uintfptr_t; #endif +typedef unsigned int *pd_entry_t; +typedef unsigned int *pt_entry_t; + /* Interrupt mask (spl, xxx_imask, etc) */ typedef __uint32_t intrmask_t; diff --git a/sys/i386/i386/bios.c b/sys/i386/i386/bios.c index c79fefa07b..8b7e35a10f 100644 --- a/sys/i386/i386/bios.c +++ b/sys/i386/i386/bios.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/bios.c,v 1.29.2.3 2001/07/19 18:07:35 imp Exp $ - * $DragonFly: src/sys/i386/i386/Attic/bios.c,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/bios.c,v 1.3 2003/06/28 02:09:47 dillon Exp $ */ /* @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -252,11 +253,7 @@ set_bios_selectors(struct bios_segments *seg, int flags) }; union descriptor *p_gdt; -#ifdef SMP - p_gdt = &gdt[cpuid * NGDT]; -#else - p_gdt = gdt; -#endif + p_gdt = &gdt[mycpu->gd_cpuid * NGDT]; ssd.ssd_base = seg->code32.base; ssd.ssd_limit = seg->code32.limit; diff --git a/sys/i386/i386/exception.s b/sys/i386/i386/exception.s index b26f4b483d..8830209de9 100644 --- a/sys/i386/i386/exception.s +++ b/sys/i386/i386/exception.s @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/exception.s,v 1.65.2.3 2001/08/15 01:23:49 peter Exp $ - * $DragonFly: src/sys/i386/i386/Attic/exception.s,v 1.5 2003/06/23 23:36:05 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/exception.s,v 1.6 2003/06/28 02:09:47 dillon Exp $ */ #include "npx.h" @@ -47,11 +47,6 @@ #include "assym.s" -#ifdef SMP -#define MOVL_KPSEL_EAX movl $KPSEL,%eax -#else -#define MOVL_KPSEL_EAX -#endif #define SEL_RPL_MASK 0x0003 .text @@ -172,7 +167,7 @@ IDTVEC(fpu) mov $KDSEL,%ax mov %ax,%ds mov %ax,%es - MOVL_KPSEL_EAX + movl $KPSEL,%eax mov %ax,%fs FAKE_MCOUNT(13*4(%esp)) @@ -226,7 +221,7 @@ alltraps_with_regs_pushed: mov $KDSEL,%ax mov %ax,%ds mov %ax,%es - MOVL_KPSEL_EAX + movl $KPSEL,%eax mov %ax,%fs FAKE_MCOUNT(13*4(%esp)) calltrap: @@ -273,7 +268,7 @@ IDTVEC(syscall) mov $KDSEL,%ax /* switch to kernel segments */ mov %ax,%ds mov %ax,%es - MOVL_KPSEL_EAX + movl $KPSEL,%eax mov %ax,%fs movl TF_ERR(%esp),%eax /* copy saved eflags to final spot */ movl %eax,TF_EFLAGS(%esp) @@ -313,7 +308,7 @@ IDTVEC(int0x80_syscall) mov $KDSEL,%ax /* switch to kernel segments */ mov %ax,%ds mov %ax,%es - MOVL_KPSEL_EAX + movl $KPSEL,%eax mov %ax,%fs movl $2,TF_ERR(%esp) /* sizeof "int 0x80" */ FAKE_MCOUNT(13*4(%esp)) diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index f06e249b23..6bfcdee2db 100644 --- a/sys/i386/i386/genassym.c +++ b/sys/i386/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/i386/i386/Attic/genassym.c,v 1.15 2003/06/27 20:27:15 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/genassym.c,v 1.16 2003/06/28 02:09:47 dillon Exp $ */ #include "opt_user_ldt.h" @@ -95,10 +95,8 @@ ASSYM(MTD_CPL, offsetof(struct mi_thread, mtd_cpl)); ASSYM(TDPRI_CRIT, TDPRI_CRIT); -#ifdef SMP ASSYM(P_ONCPU, offsetof(struct proc, p_oncpu)); ASSYM(P_LASTCPU, offsetof(struct proc, p_lastcpu)); -#endif ASSYM(SSLEEP, SSLEEP); ASSYM(SRUN, SRUN); @@ -196,7 +194,6 @@ ASSYM(GD_REQPRI, offsetof(struct globaldata, gd_reqpri)); ASSYM(GD_CURRENTLDT, offsetof(struct globaldata, gd_currentldt)); #endif -#ifdef SMP ASSYM(GD_CPUID, offsetof(struct globaldata, gd_cpuid)); ASSYM(GD_CPU_LOCKID, offsetof(struct globaldata, gd_cpu_lockid)); ASSYM(GD_OTHER_CPUS, offsetof(struct globaldata, gd_other_cpus)); @@ -210,17 +207,15 @@ ASSYM(GD_PRV_CADDR1, offsetof(struct globaldata, gd_prv_CADDR1)); ASSYM(GD_PRV_CADDR2, offsetof(struct globaldata, gd_prv_CADDR2)); ASSYM(GD_PRV_CADDR3, offsetof(struct globaldata, gd_prv_CADDR3)); ASSYM(GD_PRV_PADDR1, offsetof(struct globaldata, gd_prv_PADDR1)); -#endif + ASSYM(PS_IDLESTACK, offsetof(struct privatespace, idlestack)); +ASSYM(PS_IDLESTACK_PAGE, offsetof(struct privatespace, idlestack) / PAGE_SIZE); ASSYM(PS_IDLESTACK_TOP, sizeof(struct privatespace)); ASSYM(PS_SIZEOF, sizeof(struct privatespace)); ASSYM(KCSEL, GSEL(GCODE_SEL, SEL_KPL)); ASSYM(KDSEL, GSEL(GDATA_SEL, SEL_KPL)); - -#ifdef SMP ASSYM(KPSEL, GSEL(GPRIV_SEL, SEL_KPL)); -#endif ASSYM(BC32SEL, GSEL(GBIOSCODE32_SEL, SEL_KPL)); ASSYM(GPROC0_SEL, GPROC0_SEL); diff --git a/sys/i386/i386/globals.s b/sys/i386/i386/globals.s index fc5e0cb2d2..5816b5794e 100644 --- a/sys/i386/i386/globals.s +++ b/sys/i386/i386/globals.s @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/globals.s,v 1.13.2.1 2000/05/16 06:58:06 dillon Exp $ - * $DragonFly: src/sys/i386/i386/Attic/globals.s,v 1.9 2003/06/27 20:27:15 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/globals.s,v 1.10 2003/06/28 02:09:47 dillon Exp $ */ #include "opt_user_ldt.h" @@ -43,7 +43,6 @@ * segment. */ .data -#ifdef SMP .globl _CPU_prvspace, _lapic .set _CPU_prvspace,(MPPTDI << PDRSHIFT) .set _lapic,_CPU_prvspace + (NPTEPG-1) * PAGE_SIZE @@ -54,13 +53,6 @@ .globl globaldata .set globaldata,0 -#else - .globl _CPU_prvspace - ALIGN_PAGE -globaldata: -_CPU_prvspace: - .space PS_SIZEOF -#endif /* * Define layout of the global data. On SMP this lives in @@ -84,7 +76,7 @@ _CPU_prvspace: .set gd_currentldt,globaldata + GD_CURRENTLDT #endif -#ifndef SMP +#if 0 .globl _curthread, _npxthread, _astpending, _reqpri .globl _common_tss, _idlethread .set _curthread,globaldata + GD_CURTHREAD @@ -104,7 +96,6 @@ _CPU_prvspace: #endif #endif -#ifdef SMP /* * The BSP version of these get setup in locore.s and pmap.c, while * the AP versions are setup in mp_machdep.c. @@ -127,9 +118,8 @@ _CPU_prvspace: .set gd_prv_CADDR2,globaldata + GD_PRV_CADDR2 .set gd_prv_CADDR3,globaldata + GD_PRV_CADDR3 .set gd_prv_PADDR1,globaldata + GD_PRV_PADDR1 -#endif -#if defined(SMP) || defined(APIC_IO) +#if defined(APIC_IO) .globl lapic_eoi, lapic_svr, lapic_tpr, lapic_irr1, lapic_ver .globl lapic_icr_lo,lapic_icr_hi,lapic_isr1 /* diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s index 8c68ed43a3..bf8a65a245 100644 --- a/sys/i386/i386/locore.s +++ b/sys/i386/i386/locore.s @@ -35,7 +35,7 @@ * * from: @(#)locore.s 7.3 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/locore.s,v 1.132.2.10 2003/02/03 20:54:49 jhb Exp $ - * $DragonFly: src/sys/i386/i386/Attic/locore.s,v 1.3 2003/06/18 18:29:55 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/locore.s,v 1.4 2003/06/28 02:09:47 dillon Exp $ * * originally from: locore.s, by William F. Jolitz * @@ -116,22 +116,19 @@ _bootinfo: .space BOOTINFO_SIZE /* bootinfo that we can handle */ _KERNend: .long 0 /* phys addr end of kernel (just after bss) */ physfree: .long 0 /* phys addr of next free page */ -#ifdef SMP .globl _cpu0prvpage cpu0pp: .long 0 /* phys addr cpu0 private pg */ _cpu0prvpage: .long 0 /* relocated version */ +cpu0idlestk: .long 0 /* stack for the idle thread */ .globl _SMPpt SMPptpa: .long 0 /* phys addr SMP page table */ _SMPpt: .long 0 /* relocated version */ -#endif /* SMP */ .globl _IdlePTD _IdlePTD: .long 0 /* phys addr of kernel PTD */ -#ifdef SMP .globl _KPTphys -#endif _KPTphys: .long 0 /* phys addr of kernel page tables */ .globl _proc0paddr @@ -163,16 +160,16 @@ _pc98_system_parameter: #define R(foo) ((foo)-KERNBASE) -#define ALLOCPAGES(foo) \ - movl R(physfree), %esi ; \ - movl $((foo)*PAGE_SIZE), %eax ; \ - addl %esi, %eax ; \ - movl %eax, R(physfree) ; \ - movl %esi, %edi ; \ - movl $((foo)*PAGE_SIZE),%ecx ; \ - xorl %eax,%eax ; \ - cld ; \ - rep ; \ +#define ALLOCPAGES(foo) \ + movl R(physfree), %esi ; \ + movl $((foo)*PAGE_SIZE), %eax ; \ + addl %esi, %eax ; \ + movl %eax, R(physfree) ; \ + movl %esi, %edi ; \ + movl $((foo)*PAGE_SIZE),%ecx ; \ + xorl %eax,%eax ; \ + cld ; \ + rep ; \ stosb /* @@ -341,6 +338,7 @@ NON_GPROF_ENTRY(btext) orl $CR0_PE|CR0_PG,%eax /* enable paging */ movl %eax,%cr0 /* and let's page NOW! */ + #ifdef BDE_DEBUGGER /* * Complete the adjustments for paging so that we can keep tracing through @@ -355,6 +353,7 @@ NON_GPROF_ENTRY(btext) /* now running relocated at KERNBASE where the system is linked to run */ begin: + /* * set up the bootstrap stack. The pcb sits at the end of the * bootstrap stack. @@ -377,6 +376,7 @@ begin: movl physfree, %esi pushl %esi /* value of first for init386(first) */ + call _init386 /* wire 386 chip for unix operation */ popl %esi @@ -741,6 +741,7 @@ no_kernend: movl %esi,R(_KERNend) /* save end of kernel */ movl %esi,R(physfree) /* next free page is at end of kernel */ + /* Allocate Kernel Page Tables */ ALLOCPAGES(NKPT) movl %esi,R(_KPTphys) @@ -763,19 +764,21 @@ no_kernend: addl $KERNBASE, %esi movl %esi, R(_vm86paddr) -#ifdef SMP /* Allocate cpu0's private data page */ ALLOCPAGES(1) movl %esi,R(cpu0pp) addl $KERNBASE, %esi movl %esi, R(_cpu0prvpage) /* relocated to KVM space */ +/* Allocate cpu0's idle stack */ + ALLOCPAGES(UPAGES) + movl %esi,R(cpu0idlestk) + /* Allocate SMP page table page */ ALLOCPAGES(1) movl %esi,R(SMPptpa) addl $KERNBASE, %esi movl %esi, R(_SMPpt) /* relocated to KVM space */ -#endif /* SMP */ /* Map read-only from zero to the end of the kernel text section */ xorl %eax, %eax @@ -846,7 +849,6 @@ map_read_write: movl $ISA_HOLE_LENGTH>>PAGE_SHIFT, %ecx fillkpt(R(_vm86pa), $PG_RW|PG_U) -#ifdef SMP /* Map cpu0's private page into global kmem (4K @ cpu0prvpage) */ movl R(cpu0pp), %eax movl $1, %ecx @@ -863,6 +865,12 @@ map_read_write: movl $1, %ecx /* one private page coming right up */ fillkpt(R(SMPptpa), $PG_RW) +/* Map the cpu0's idle thread stack */ + movl R(cpu0idlestk), %eax + movl $PS_IDLESTACK_PAGE, %ebx + movl $UPAGES, %ecx + fillkpt(R(SMPptpa), $PG_RW) + /* ... and put the page table table in the pde. */ movl R(SMPptpa), %eax movl $MPPTDI, %ebx @@ -876,6 +884,7 @@ map_read_write: movl $1, %ecx /* one private pt coming right up */ fillkpt(R(SMPptpa), $PG_RW) +#ifdef SMP /* Initialize mp lock to allow early traps */ movl $1, R(_mp_lock) #endif /* SMP */ diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index c1f5833b3f..7e69029c2d 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -36,7 +36,7 @@ * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $ - * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.13 2003/06/27 03:30:37 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.14 2003/06/28 02:09:47 dillon Exp $ */ #include "apm.h" @@ -1146,14 +1146,10 @@ union descriptor gdt[NGDT * MAXCPU]; /* global descriptor table */ static struct gate_descriptor idt0[NIDT]; struct gate_descriptor *idt = &idt0[0]; /* interrupt descriptor table */ union descriptor ldt[NLDT]; /* local descriptor table */ -#ifdef SMP -/* table descriptors - used to load tables by microp */ + +/* table descriptors - used to load tables by cpu */ struct region_descriptor r_gdt, r_idt; -#endif -#ifndef SMP -extern struct segment_descriptor common_tssd, *tss_gdt; -#endif int private_tss; /* flag indicating private tss */ #if defined(I586_CPU) && !defined(NO_F00F_HACK) @@ -1648,7 +1644,7 @@ physmap_done: */ #ifdef SMP - /* make hole for AP bootstrap code */ + /* make hole for AP bootstrap code YYY */ physmap[1] = mp_bootaddress(physmap[1] / 1024); /* look for the MP hardware - needed for apic addresses */ @@ -1850,15 +1846,10 @@ physmap_done: } void -init386(first) - int first; +init386(int first) { struct gate_descriptor *gdp; int gsel_tss, metadata_missing, off, x; -#ifndef SMP - /* table descriptors - used to load tables by microp */ - struct region_descriptor r_gdt, r_idt; -#endif struct globaldata *gd; /* @@ -1900,17 +1891,15 @@ init386(first) */ gdt_segs[GCODE_SEL].ssd_limit = atop(0 - 1); gdt_segs[GDATA_SEL].ssd_limit = atop(0 - 1); -#ifdef SMP + gdt_segs[GPRIV_SEL].ssd_limit = atop(sizeof(struct privatespace) - 1); gdt_segs[GPRIV_SEL].ssd_base = (int) &CPU_prvspace[0]; gdt_segs[GPROC0_SEL].ssd_base = (int) &CPU_prvspace[0].globaldata.gd_common_tss; -#else - gdt_segs[GPRIV_SEL].ssd_limit = atop(0 - 1); - gdt_segs[GPROC0_SEL].ssd_base = (int) &common_tss; -#endif + gd->gd_prvspace = &CPU_prvspace[0]; + /* * Note: on both UP and SMP curthread must be set non-NULL * early in the boot sequence because the system assumes @@ -1946,7 +1935,7 @@ init386(first) _default_ldt = GSEL(GLDT_SEL, SEL_KPL); lldt(_default_ldt); #ifdef USER_LDT - currentldt = _default_ldt; + gd->gd_currentldt = _default_ldt; #endif /* exceptions */ @@ -2008,13 +1997,13 @@ init386(first) * make an initial tss so cpu can get interrupt stack on syscall! * The 16 bytes is to save room for a VM86 context. */ - common_tss.tss_esp0 = (int) thread0.td_pcb - 16; - common_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL) ; + gd->gd_common_tss.tss_esp0 = (int) thread0.td_pcb - 16; + gd->gd_common_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL) ; gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); private_tss = 0; - tss_gdt = &gdt[GPROC0_SEL].sd; - common_tssd = *tss_gdt; - common_tss.tss_ioopt = (sizeof common_tss) << 16; + gd->gd_tss_gdt = &gdt[GPROC0_SEL].sd; + gd->gd_common_tssd = *gd->gd_tss_gdt; + gd->gd_common_tss.tss_ioopt = (sizeof common_tss) << 16; ltr(gsel_tss); dblfault_tss.tss_esp = dblfault_tss.tss_esp0 = dblfault_tss.tss_esp1 = @@ -2067,16 +2056,18 @@ init386(first) thread0.td_pcb->pcb_flags = 0; thread0.td_pcb->pcb_cr3 = (int)IdlePTD; /* should already be setup */ #ifdef SMP +#if 0 thread0.td_pcb->pcb_mpnest = 1; +#endif #endif thread0.td_pcb->pcb_ext = 0; proc0.p_md.md_regs = &proc0_tf; } /* - * Initialize machine-dependant portions of the global data structure - * - * YYY do we need to reserve pcb space for idlethread? + * Initialize machine-dependant portions of the global data structure. + * Note that the global data area and cpu0's idlestack in the private + * data space were allocated in locore. */ void cpu_gdinit(struct globaldata *gd, int cpu) @@ -2085,7 +2076,8 @@ cpu_gdinit(struct globaldata *gd, int cpu) TAILQ_INIT(&gd->gd_tdfreeq); /* for pmap_{new,dispose}_thread() */ if (cpu) - gd->gd_curthread = &gd->gd_idlethread; + gd->gd_curthread = &gd->gd_idlethread; + sp = gd->gd_prvspace->idlestack; lwkt_init_thread(&gd->gd_idlethread, sp, 0); gd->gd_idlethread.td_switch = cpu_lwkt_switch; @@ -2098,11 +2090,9 @@ static void f00f_hack(void *unused); SYSINIT(f00f_hack, SI_SUB_INTRINSIC, SI_ORDER_FIRST, f00f_hack, NULL); static void -f00f_hack(void *unused) { +f00f_hack(void *unused) +{ struct gate_descriptor *new_idt; -#ifndef SMP - struct region_descriptor r_idt; -#endif vm_offset_t tmp; if (!has_f00f_bug) diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index 7af06078b4..85af26f0ca 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -23,7 +23,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/mp_machdep.c,v 1.115.2.15 2003/03/14 21:22:35 jhb Exp $ - * $DragonFly: src/sys/i386/i386/Attic/mp_machdep.c,v 1.6 2003/06/21 07:54:56 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/mp_machdep.c,v 1.7 2003/06/28 02:09:47 dillon Exp $ */ #include "opt_cpu.h" @@ -249,7 +249,6 @@ int current_postcode; extern struct region_descriptor r_gdt, r_idt; int bsp_apic_ready = 0; /* flags useability of BSP apic */ -int mp_ncpus; /* # of CPUs, including BSP */ int mp_naps; /* # of Applications processors */ int mp_nbusses; /* # of busses */ int mp_napics; /* # of IO APICs */ @@ -2384,31 +2383,6 @@ smp_invltlb(void) #endif /* APIC_IO */ } -void -invlpg(u_int addr) -{ - __asm __volatile("invlpg (%0)"::"r"(addr):"memory"); - - /* send a message to the other CPUs */ - smp_invltlb(); -} - -void -invltlb(void) -{ - u_long temp; - - /* - * This should be implemented as load_cr3(rcr3()) when load_cr3() is - * inlined. - */ - __asm __volatile("movl %%cr3, %0; movl %0, %%cr3":"=r"(temp) :: "memory"); - - /* send a message to the other CPUs */ - smp_invltlb(); -} - - /* * When called the executing CPU will send an IPI to all other CPUs * requesting that they halt execution. diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index 4548c717f4..8d2ff10356 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -40,7 +40,7 @@ * * from: @(#)pmap.c 7.7 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/i386/pmap.c,v 1.250.2.18 2002/03/06 22:48:53 silby Exp $ - * $DragonFly: src/sys/i386/i386/Attic/pmap.c,v 1.11 2003/06/27 03:30:37 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/pmap.c,v 1.12 2003/06/28 02:09:47 dillon Exp $ */ /* @@ -177,9 +177,7 @@ static struct pv_entry *pvinit; * All those kernel PT submaps that BSD is so fond of */ pt_entry_t *CMAP1 = 0; -static pt_entry_t *CMAP2, *ptmmap; caddr_t CADDR1 = 0, ptvmmap = 0; -static caddr_t CADDR2; static pt_entry_t *msgbufmap; struct msgbuf *msgbufp=0; @@ -189,12 +187,7 @@ struct msgbuf *msgbufp=0; static pt_entry_t *pt_crashdumpmap; static caddr_t crashdumpmap; -#ifdef SMP extern pt_entry_t *SMPpt; -#else -static pt_entry_t *PMAP1 = 0; -static unsigned *PADDR1 = 0; -#endif static PMAP_INLINE void free_pv_entry __P((pv_entry_t pv)); static unsigned * get_ptbase __P((pmap_t pmap)); @@ -285,9 +278,7 @@ pmap_bootstrap(firstaddr, loadaddr) { vm_offset_t va; pt_entry_t *pte; -#ifdef SMP struct globaldata *gd; -#endif int i; avail_start = firstaddr; @@ -337,19 +328,12 @@ pmap_bootstrap(firstaddr, loadaddr) * CMAP1/CMAP2 are used for zeroing and copying pages. */ SYSMAP(caddr_t, CMAP1, CADDR1, 1) - SYSMAP(caddr_t, CMAP2, CADDR2, 1) /* * Crashdump maps. */ SYSMAP(caddr_t, pt_crashdumpmap, crashdumpmap, MAXDUMPPGS); - /* - * ptvmmap is used for reading arbitrary physical pages via /dev/mem. - * XXX ptmmap is not used. - */ - SYSMAP(caddr_t, ptmmap, ptvmmap, 1) - /* * msgbufp is used to map the system message buffer. * XXX msgbufmap is not used. @@ -357,25 +341,17 @@ pmap_bootstrap(firstaddr, loadaddr) SYSMAP(struct msgbuf *, msgbufmap, msgbufp, atop(round_page(MSGBUF_SIZE))) -#if !defined(SMP) - /* - * ptemap is used for pmap_pte_quick - */ - SYSMAP(unsigned *, PMAP1, PADDR1, 1); -#endif - virtual_avail = va; - *(int *) CMAP1 = *(int *) CMAP2 = 0; + *(int *) CMAP1 = 0; for (i = 0; i < NKPT; i++) PTD[i] = 0; - pgeflag = 0; -#if !defined(SMP) /* XXX - see also mp_machdep.c */ - if (cpu_feature & CPUID_PGE) { + /* XXX - see also mp_machdep.c */ + if (ncpus == 1 && (cpu_feature & CPUID_PGE)) pgeflag = PG_G; - } -#endif + else + pgeflag = 0; /* * Initialize the 4MB page size flag @@ -399,34 +375,35 @@ pmap_bootstrap(firstaddr, loadaddr) ptditmp |= PG_V | PG_RW | PG_PS | PG_U | pgeflag; pdir4mb = ptditmp; -#if !defined(SMP) - /* - * Enable the PSE mode. - */ - load_cr4(rcr4() | CR4_PSE); + if (ncpus == 1) { + /* + * Enable the PSE mode. + */ + load_cr4(rcr4() | CR4_PSE); - /* - * We can do the mapping here for the single processor - * case. We simply ignore the old page table page from - * now on. - */ - /* - * For SMP, we still need 4K pages to bootstrap APs, - * PSE will be enabled as soon as all APs are up. - */ - PTD[KPTDI] = (pd_entry_t) ptditmp; - kernel_pmap->pm_pdir[KPTDI] = (pd_entry_t) ptditmp; - invltlb(); -#endif + /* + * We can do the mapping here for the single processor + * case. We simply ignore the old page table page from + * now on. + */ + /* + * For SMP, we still need 4K pages to bootstrap APs, + * PSE will be enabled as soon as all APs are up. + */ + PTD[KPTDI] = (pd_entry_t) ptditmp; + kernel_pmap->pm_pdir[KPTDI] = (pd_entry_t) ptditmp; + invltlb(); + } } #endif -#ifdef SMP +#ifdef APIC_IO if (cpu_apic_address == 0) panic("pmap_bootstrap: no local apic!"); /* local apic is mapped on last page */ SMPpt[NPTEPG - 1] = (pt_entry_t)(PG_V | PG_RW | PG_N | pgeflag | (cpu_apic_address & PG_FRAME)); +#endif /* BSP does this itself, AP's get it pre-set */ gd = &CPU_prvspace[0].globaldata; @@ -438,7 +415,6 @@ pmap_bootstrap(firstaddr, loadaddr) gd->gd_prv_CADDR2 = CPU_prvspace[0].CPAGE2; gd->gd_prv_CADDR3 = CPU_prvspace[0].CPAGE3; gd->gd_prv_PADDR1 = (unsigned *)CPU_prvspace[0].PPAGE1; -#endif invltlb(); } @@ -640,11 +616,11 @@ get_ptbase(pmap) */ static unsigned * -pmap_pte_quick(pmap, va) - register pmap_t pmap; - vm_offset_t va; +pmap_pte_quick(pmap_t pmap, vm_offset_t va) { + struct globaldata *gd = mycpu; unsigned pde, newpf; + if ((pde = (unsigned) pmap->pm_pdir[va >> PDRSHIFT]) != 0) { unsigned frame = (unsigned) pmap->pm_pdir[PTDPTDI] & PG_FRAME; unsigned index = i386_btop(va); @@ -654,19 +630,11 @@ pmap_pte_quick(pmap, va) return (unsigned *) PTmap + index; } newpf = pde & PG_FRAME; -#ifdef SMP - if ( ((* (unsigned *) prv_PMAP1) & PG_FRAME) != newpf) { - * (unsigned *) prv_PMAP1 = newpf | PG_RW | PG_V; - cpu_invlpg(prv_PADDR1); - } - return prv_PADDR1 + ((unsigned) index & (NPTEPG - 1)); -#else - if ( ((* (unsigned *) PMAP1) & PG_FRAME) != newpf) { - * (unsigned *) PMAP1 = newpf | PG_RW | PG_V; - invltlb_1pg((vm_offset_t) PADDR1); + if ( ((* (unsigned *) gd->gd_prv_PMAP1) & PG_FRAME) != newpf) { + * (unsigned *) gd->gd_prv_PMAP1 = newpf | PG_RW | PG_V; + cpu_invlpg(gd->gd_prv_PADDR1); } - return PADDR1 + ((unsigned) index & (NPTEPG - 1)); -#endif + return gd->gd_prv_PADDR1 + ((unsigned) index & (NPTEPG - 1)); } return (0); } @@ -1087,9 +1055,7 @@ pmap_pinit(pmap) if ((ptdpg->flags & PG_ZERO) == 0) bzero(pmap->pm_pdir, PAGE_SIZE); -#ifdef SMP pmap->pm_pdir[MPPTDI] = PTD[MPPTDI]; -#endif /* install self-referential address mapping entry */ *(unsigned *) (pmap->pm_pdir + PTDPTDI) = @@ -1147,9 +1113,7 @@ pmap_release_free_page(pmap, p) */ if (p->pindex == PTDPTDI) { bzero(pde + KPTDI, nkpt * PTESIZE); -#ifdef SMP pde[MPPTDI] = 0; -#endif pde[APTDPTDI] = 0; pmap_kremove((vm_offset_t) pmap->pm_pdir); } @@ -2653,39 +2617,25 @@ pmap_kernel() * the page into KVM and using bzero to clear its contents. */ void -pmap_zero_page(phys) - vm_offset_t phys; +pmap_zero_page(vm_offset_t phys) { -#ifdef SMP - if (*(int *) prv_CMAP3) + struct globaldata *gd = mycpu; + + if (*(int *)gd->gd_prv_CMAP3) panic("pmap_zero_page: prv_CMAP3 busy"); - *(int *) prv_CMAP3 = PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M; - cpu_invlpg(prv_CADDR3); + *(int *)gd->gd_prv_CMAP3 = + PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M; + cpu_invlpg(gd->gd_prv_CADDR3); #if defined(I686_CPU) if (cpu_class == CPUCLASS_686) - i686_pagezero(prv_CADDR3); + i686_pagezero(gd->gd_prv_CADDR3); else #endif - bzero(prv_CADDR3, PAGE_SIZE); - - *(int *) prv_CMAP3 = 0; -#else - if (*(int *) CMAP2) - panic("pmap_zero_page: CMAP2 busy"); - - *(int *) CMAP2 = PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M; - invltlb_1pg((vm_offset_t)CADDR2); + bzero(gd->gd_prv_CADDR3, PAGE_SIZE); -#if defined(I686_CPU) - if (cpu_class == CPUCLASS_686) - i686_pagezero(CADDR2); - else -#endif - bzero(CADDR2, PAGE_SIZE); - *(int *) CMAP2 = 0; -#endif + *(int *) gd->gd_prv_CMAP3 = 0; } /* @@ -2700,36 +2650,22 @@ pmap_zero_page_area(phys, off, size) int off; int size; { -#ifdef SMP - if (*(int *) prv_CMAP3) + struct globaldata *gd = mycpu; + + if (*(int *) gd->gd_prv_CMAP3) panic("pmap_zero_page: prv_CMAP3 busy"); - *(int *) prv_CMAP3 = PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M; - cpu_invlpg(prv_CADDR3); + *(int *) gd->gd_prv_CMAP3 = PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M; + cpu_invlpg(gd->gd_prv_CADDR3); #if defined(I686_CPU) if (cpu_class == CPUCLASS_686 && off == 0 && size == PAGE_SIZE) - i686_pagezero(prv_CADDR3); + i686_pagezero(gd->gd_prv_CADDR3); else #endif - bzero((char *)prv_CADDR3 + off, size); - - *(int *) prv_CMAP3 = 0; -#else - if (*(int *) CMAP2) - panic("pmap_zero_page: CMAP2 busy"); - - *(int *) CMAP2 = PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M; - invltlb_1pg((vm_offset_t)CADDR2); + bzero((char *)gd->gd_prv_CADDR3 + off, size); -#if defined(I686_CPU) - if (cpu_class == CPUCLASS_686 && off == 0 && size == PAGE_SIZE) - i686_pagezero(CADDR2); - else -#endif - bzero((char *)CADDR2 + off, size); - *(int *) CMAP2 = 0; -#endif + *(int *) gd->gd_prv_CMAP3 = 0; } /* @@ -2743,43 +2679,23 @@ pmap_copy_page(src, dst) vm_offset_t src; vm_offset_t dst; { -#ifdef SMP - if (*(int *) prv_CMAP1) + struct globaldata *gd = mycpu; + + if (*(int *) gd->gd_prv_CMAP1) panic("pmap_copy_page: prv_CMAP1 busy"); - if (*(int *) prv_CMAP2) + if (*(int *) gd->gd_prv_CMAP2) panic("pmap_copy_page: prv_CMAP2 busy"); - *(int *) prv_CMAP1 = PG_V | (src & PG_FRAME) | PG_A; - *(int *) prv_CMAP2 = PG_V | PG_RW | (dst & PG_FRAME) | PG_A | PG_M; - - cpu_invlpg(prv_CADDR1); - cpu_invlpg(prv_CADDR2); - - bcopy(prv_CADDR1, prv_CADDR2, PAGE_SIZE); - - *(int *) prv_CMAP1 = 0; - *(int *) prv_CMAP2 = 0; -#else - if (*(int *) CMAP1 || *(int *) CMAP2) - panic("pmap_copy_page: CMAP busy"); + *(int *) gd->gd_prv_CMAP1 = PG_V | (src & PG_FRAME) | PG_A; + *(int *) gd->gd_prv_CMAP2 = PG_V | PG_RW | (dst & PG_FRAME) | PG_A | PG_M; - *(int *) CMAP1 = PG_V | (src & PG_FRAME) | PG_A; - *(int *) CMAP2 = PG_V | PG_RW | (dst & PG_FRAME) | PG_A | PG_M; -#if defined(I386_CPU) - if (cpu_class == CPUCLASS_386) { - invltlb(); - } else -#endif - { - invlpg((u_int)CADDR1); - invlpg((u_int)CADDR2); - } + cpu_invlpg(gd->gd_prv_CADDR1); + cpu_invlpg(gd->gd_prv_CADDR2); - bcopy(CADDR1, CADDR2, PAGE_SIZE); + bcopy(gd->gd_prv_CADDR1, gd->gd_prv_CADDR2, PAGE_SIZE); - *(int *) CMAP1 = 0; - *(int *) CMAP2 = 0; -#endif + *(int *) gd->gd_prv_CMAP1 = 0; + *(int *) gd->gd_prv_CMAP2 = 0; } diff --git a/sys/i386/i386/support.s b/sys/i386/i386/support.s index f8d50d0eb4..290d1e3308 100644 --- a/sys/i386/i386/support.s +++ b/sys/i386/i386/support.s @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/support.s,v 1.67.2.5 2001/08/15 01:23:50 peter Exp $ - * $DragonFly: src/sys/i386/i386/Attic/support.s,v 1.5 2003/06/18 18:29:55 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/support.s,v 1.6 2003/06/28 02:09:47 dillon Exp $ */ #include "npx.h" @@ -1544,9 +1544,7 @@ ENTRY(lgdt) mov %ax,%es mov %ax,%gs mov %ax,%ss -#ifdef SMP movl $KPSEL,%eax -#endif mov %ax,%fs /* reload code selector by turning return into intersegmental return */ diff --git a/sys/i386/i386/swtch.s b/sys/i386/i386/swtch.s index 09261b02fc..ce326a2b7f 100644 --- a/sys/i386/i386/swtch.s +++ b/sys/i386/i386/swtch.s @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/swtch.s,v 1.89.2.10 2003/01/23 03:36:24 ps Exp $ - * $DragonFly: src/sys/i386/i386/Attic/swtch.s,v 1.14 2003/06/27 03:30:37 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/swtch.s,v 1.15 2003/06/28 02:09:47 dillon Exp $ */ #include "npx.h" @@ -304,12 +304,15 @@ ENTRY(cpu_heavy_restore) btrl %esi, _private_tss jae 3f -#ifdef SMP + + /* + * There is no way to get the address of a segment-accessed variable + * so we store a self-referential pointer at the base of the per-cpu + * data area and add the appropriate offset. + */ movl $gd_common_tssd, %edi addl %fs:0, %edi -#else - movl $_common_tssd, %edi -#endif + /* * Move the correct TSS descriptor into the GDT slot, then reload * tr. YYY not sure what is going on here @@ -328,11 +331,7 @@ ENTRY(cpu_heavy_restore) */ 3: movl P_VMSPACE(%ecx), %ebx -#ifdef SMP movl _cpuid, %eax -#else - xorl %eax, %eax -#endif btsl %eax, VM_PMAP+PM_ACTIVE(%ebx) /* diff --git a/sys/i386/i386/sys_machdep.c b/sys/i386/i386/sys_machdep.c index ad67da9fcf..3739e14099 100644 --- a/sys/i386/i386/sys_machdep.c +++ b/sys/i386/i386/sys_machdep.c @@ -32,7 +32,7 @@ * * from: @(#)sys_machdep.c 5.5 (Berkeley) 1/19/91 * $FreeBSD: src/sys/i386/i386/sys_machdep.c,v 1.47.2.3 2002/10/07 17:20:00 jhb Exp $ - * $DragonFly: src/sys/i386/i386/Attic/sys_machdep.c,v 1.5 2003/06/25 03:55:53 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/sys_machdep.c,v 1.6 2003/06/28 02:09:47 dillon Exp $ * */ @@ -257,7 +257,7 @@ set_user_ldt(struct pcb *pcb) gdt[GUSERLDT_SEL].sd = pcb_ldt->ldt_sd; #endif lldt(GSEL(GUSERLDT_SEL, SEL_KPL)); - currentldt = GSEL(GUSERLDT_SEL, SEL_KPL); + mycpu->gd_currentldt = GSEL(GUSERLDT_SEL, SEL_KPL); } struct pcb_ldt * @@ -305,7 +305,7 @@ user_ldt_free(struct pcb *pcb) if (pcb == curthread->td_pcb) { lldt(_default_ldt); - currentldt = _default_ldt; + mycpu->gd_currentldt = _default_ldt; } if (--pcb_ldt->ldt_refcnt == 0) { diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 27142c2caf..83032ca5b6 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -36,7 +36,7 @@ * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/trap.c,v 1.147.2.11 2003/02/27 19:09:59 luoqi Exp $ - * $DragonFly: src/sys/i386/i386/Attic/trap.c,v 1.8 2003/06/25 03:55:53 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/trap.c,v 1.9 2003/06/28 02:09:47 dillon Exp $ */ /* @@ -999,10 +999,12 @@ trap_fatal(frame, eva) void dblfault_handler() { + struct globaldata *gd = mycpu; + printf("\nFatal double fault:\n"); - printf("eip = 0x%x\n", common_tss.tss_eip); - printf("esp = 0x%x\n", common_tss.tss_esp); - printf("ebp = 0x%x\n", common_tss.tss_ebp); + printf("eip = 0x%x\n", gd->gd_common_tss.tss_eip); + printf("esp = 0x%x\n", gd->gd_common_tss.tss_esp); + printf("ebp = 0x%x\n", gd->gd_common_tss.tss_ebp); #ifdef SMP /* three seperate prints in case of a trap on an unmapped page */ printf("mp_lock = %08x; ", mp_lock); diff --git a/sys/i386/icu/icu_vector.s b/sys/i386/icu/icu_vector.s index 49d5c21fb3..5c15eaf1f5 100644 --- a/sys/i386/icu/icu_vector.s +++ b/sys/i386/icu/icu_vector.s @@ -1,7 +1,7 @@ /* * from: vector.s, 386BSD 0.1 unknown origin * $FreeBSD: src/sys/i386/isa/icu_vector.s,v 1.14.2.2 2000/07/18 21:12:42 dfr Exp $ - * $DragonFly: src/sys/i386/icu/Attic/icu_vector.s,v 1.4 2003/06/22 08:54:22 dillon Exp $ + * $DragonFly: src/sys/i386/icu/Attic/icu_vector.s,v 1.5 2003/06/28 02:09:52 dillon Exp $ */ /* @@ -101,6 +101,7 @@ IDTVEC(vec_name) ; \ pushl %fs ; \ mov $KDSEL,%ax ; \ mov %ax,%es ; \ + mov $KPSEL,%ax ; \ mov %ax,%fs ; \ movl (3+8+0)*4(%esp),%ecx ; /* ... %ecx from thin frame ... */ \ movl %ecx,(3+6)*4(%esp) ; /* ... to fat frame ... */ \ @@ -123,6 +124,7 @@ IDTVEC(vec_name) ; \ mov $KDSEL,%ax ; /* ... and reload with kernel's own ... */ \ mov %ax,%ds ; /* ... early for obsolete reasons */ \ mov %ax,%es ; \ + mov $KPSEL,%ax ; \ mov %ax,%fs ; \ maybe_extra_ipending ; \ movb _imen + IRQ_BYTE(irq_num),%al ; \ diff --git a/sys/i386/include/asnames.h b/sys/i386/include/asnames.h index 87f1cd653a..ee5071ed58 100644 --- a/sys/i386/include/asnames.h +++ b/sys/i386/include/asnames.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/asnames.h,v 1.44.2.8 2003/01/22 20:14:53 jhb Exp $ - * $DragonFly: src/sys/i386/include/Attic/asnames.h,v 1.8 2003/06/22 08:54:20 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/asnames.h,v 1.9 2003/06/28 02:09:49 dillon Exp $ */ #ifndef _MACHINE_ASNAMES_H_ @@ -330,12 +330,7 @@ #endif /* __ELF__ */ -#if defined(SMP) || defined(__ELF__) -#ifdef SMP #define FS(x) %fs:gd_ ## x -#else -#define FS(x) x -#endif #define _common_tss FS(common_tss) #define _common_tssd FS(common_tssd) @@ -364,6 +359,4 @@ #define _idlestack FS(idlestack) #define _idlestack_top FS(idlestack_top) -#endif - #endif /* !_MACHINE_ASNAMES_H_ */ diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h index 0d19ef2ce4..868819b7f3 100644 --- a/sys/i386/include/cpufunc.h +++ b/sys/i386/include/cpufunc.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/cpufunc.h,v 1.96.2.3 2002/04/28 22:50:54 dwmalone Exp $ - * $DragonFly: src/sys/i386/include/Attic/cpufunc.h,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/cpufunc.h,v 1.3 2003/06/28 02:09:49 dillon Exp $ */ /* @@ -243,22 +243,29 @@ invd(void) __asm __volatile("invd"); } -#if defined(SMP) && defined(_KERNEL) +#if defined(_KERNEL) /* - * When using APIC IPI's, invlpg() is not simply the invlpg instruction - * (this is a bug) and the inlining cost is prohibitive since the call - * executes into the IPI transmission system. + * If we are not a true-SMP box then smp_invltlb() is a NOP. Note that this + * will cause the invl*() functions to be equivalent to the cpu_invl*() + * functions. */ -void invlpg __P((u_int addr)); -void invltlb __P((void)); +#ifndef SMP +#define smp_invltlb() +#endif +/* + * Invalidate a patricular VA on this cpu only + */ static __inline void cpu_invlpg(void *addr) { __asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory"); } +/* + * Invalidate the TLB on this cpu only + */ static __inline void cpu_invltlb(void) { @@ -274,14 +281,19 @@ cpu_invltlb(void) #endif } -#else /* !(SMP && _KERNEL) */ - +/* + * Invalidate a patricular VA on all cpus + */ static __inline void invlpg(u_int addr) { __asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory"); + smp_invltlb(); } +/* + * Invalidate the TLB on all cpus + */ static __inline void invltlb(void) { @@ -292,12 +304,13 @@ invltlb(void) */ __asm __volatile("movl %%cr3, %0; movl %0, %%cr3" : "=r" (temp) : : "memory"); + smp_invltlb(); #ifdef SWTCH_OPTIM_STATS ++tlb_flush_count; #endif } -#endif /* SMP && _KERNEL */ +#endif /* _KERNEL */ static __inline u_short inw(u_int port) diff --git a/sys/i386/include/globaldata.h b/sys/i386/include/globaldata.h index 2dc2e43355..41ac641277 100644 --- a/sys/i386/include/globaldata.h +++ b/sys/i386/include/globaldata.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/globaldata.h,v 1.11.2.1 2000/05/16 06:58:10 dillon Exp $ - * $DragonFly: src/sys/i386/include/Attic/globaldata.h,v 1.11 2003/06/27 20:27:18 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/globaldata.h,v 1.12 2003/06/28 02:09:49 dillon Exp $ */ /* @@ -56,10 +56,11 @@ struct globaldata { int gd_currentldt; /* USER_LDT */ u_int gd_cpuid; struct timeval gd_stattv; -#ifdef SMP + struct thread gd_idlethread; + int gd_inside_intr; + u_int gd_cpu_lockid; u_int gd_other_cpus; - int gd_inside_intr; u_int gd_ss_eflags; pt_entry_t *gd_prv_CMAP1; pt_entry_t *gd_prv_CMAP2; @@ -69,9 +70,7 @@ struct globaldata { caddr_t gd_prv_CADDR2; caddr_t gd_prv_CADDR3; unsigned *gd_prv_PADDR1; -#endif u_int gd_astpending; - struct thread gd_idlethread; }; /* @@ -84,13 +83,11 @@ struct privatespace { struct globaldata globaldata; char __filler0[PAGE_SIZE - sizeof(struct globaldata)]; -#ifdef SMP /* page 1..4 - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */ char CPAGE1[PAGE_SIZE]; char CPAGE2[PAGE_SIZE]; char CPAGE3[PAGE_SIZE]; char PPAGE1[PAGE_SIZE]; -#endif /* page 5..4+UPAGES - idle stack (UPAGES pages) */ char idlestack[UPAGES * PAGE_SIZE]; diff --git a/sys/i386/include/globals.h b/sys/i386/include/globals.h index 1096bf6d04..fbc217e0ca 100644 --- a/sys/i386/include/globals.h +++ b/sys/i386/include/globals.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/globals.h,v 1.5.2.1 2000/05/16 06:58:10 dillon Exp $ - * $DragonFly: src/sys/i386/include/Attic/globals.h,v 1.7 2003/06/20 02:09:54 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/globals.h,v 1.8 2003/06/28 02:09:49 dillon Exp $ */ #ifndef _MACHINE_GLOBALS_H_ @@ -43,7 +43,6 @@ * move to another cpu preemptively so the 'gd' pointer is good until you * block. */ -#if defined(SMP) || defined(KLD_MODULE) || defined(ACTUALLY_LKM_NOT_KERNEL) extern int __mycpu__dummy; @@ -59,18 +58,13 @@ _get_mycpu(void) #define mycpu _get_mycpu() -#else - -#define mycpu (&CPU_prvspace[0].globaldata) - -#endif - /* * note: curthread is never NULL, but curproc can be. Also note that * in Turtle, the current pcb is stored in the thread structure. */ -#define curthread (mycpu->gd_curthread) -#define curproc (curthread->td_proc) +#define curthread mycpu->gd_curthread +#define curproc curthread->td_proc +#define npxthread mycpu->gd_npxthread #endif /* _KERNEL */ diff --git a/sys/i386/include/npx.h b/sys/i386/include/npx.h index e53c579d08..2033c8919e 100644 --- a/sys/i386/include/npx.h +++ b/sys/i386/include/npx.h @@ -35,7 +35,7 @@ * * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 * $FreeBSD: src/sys/i386/include/npx.h,v 1.18.2.1 2001/08/15 01:23:52 peter Exp $ - * $DragonFly: src/sys/i386/include/Attic/npx.h,v 1.3 2003/06/18 07:04:28 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/npx.h,v 1.4 2003/06/28 02:09:49 dillon Exp $ */ /* @@ -144,9 +144,6 @@ union savefpu { #define __INITIAL_NPXCW__ 0x127F #ifdef _KERNEL -#ifndef npxthread -extern struct thread *npxthread; -#endif int npxdna __P((void)); void npxexit __P((struct proc *p)); diff --git a/sys/i386/include/pcb.h b/sys/i386/include/pcb.h index 5aa3ba4623..a2896bb896 100644 --- a/sys/i386/include/pcb.h +++ b/sys/i386/include/pcb.h @@ -35,7 +35,7 @@ * * from: @(#)pcb.h 5.10 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/include/pcb.h,v 1.32.2.1 2001/08/15 01:23:52 peter Exp $ - * $DragonFly: src/sys/i386/include/Attic/pcb.h,v 1.3 2003/06/18 18:29:58 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/pcb.h,v 1.4 2003/06/28 02:09:49 dillon Exp $ */ #ifndef _I386_PCB_H_ @@ -73,10 +73,12 @@ struct pcb { #define FP_SOFTFP 0x01 /* process using software fltng pnt emulator */ #define PCB_DBREGS 0x02 /* process using debug registers */ caddr_t pcb_onfault; /* copyin/out fault recovery */ +#if 0 #ifdef SMP u_long pcb_mpnest; #else u_long pcb_mpnest_dontuse; +#endif #endif int pcb_gs; struct pcb_ext *pcb_ext; /* optional pcb extension */ diff --git a/sys/i386/include/pmap.h b/sys/i386/include/pmap.h index 92cc0403c7..0aa2c75f16 100644 --- a/sys/i386/include/pmap.h +++ b/sys/i386/include/pmap.h @@ -43,7 +43,7 @@ * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/include/pmap.h,v 1.65.2.3 2001/10/03 07:15:37 peter Exp $ - * $DragonFly: src/sys/i386/include/Attic/pmap.h,v 1.2 2003/06/17 04:28:36 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/pmap.h,v 1.3 2003/06/28 02:09:49 dillon Exp $ */ #ifndef _MACHINE_PMAP_H_ @@ -101,11 +101,10 @@ #define NKPT 30 /* actual number of kernel page tables */ #endif #ifndef NKPDE -#ifdef SMP #define NKPDE (KVA_PAGES - 2) /* addressable number of page tables/pde's */ -#else -#define NKPDE (KVA_PAGES - 1) /* addressable number of page tables/pde's */ #endif +#if NKPDE > KVA_PAGES - 2 +#error "Maximum NKPDE is KVA_PAGES - 2" #endif /* @@ -117,12 +116,8 @@ * SMP_PRIVPAGES: The per-cpu address space is 0xff80000 -> 0xffbfffff */ #define APTDPTDI (NPDEPG-1) /* alt ptd entry that points to APTD */ -#ifdef SMP #define MPPTDI (APTDPTDI-1) /* per cpu ptd entry */ #define KPTDI (MPPTDI-NKPDE) /* start of kernel virtual pde's */ -#else -#define KPTDI (APTDPTDI-NKPDE)/* start of kernel virtual pde's */ -#endif /* SMP */ #define PTDPTDI (KPTDI-1) /* ptd entry that points to ptd! */ #define UMAXPTDI (PTDPTDI-1) /* ptd entry for user space end */ #define UMAXPTEOFF (NPTEPG) /* pte entry for user space end */ @@ -137,9 +132,6 @@ #include -typedef unsigned int *pd_entry_t; -typedef unsigned int *pt_entry_t; - #define PDESIZE sizeof(pd_entry_t) /* for assembly files */ #define PTESIZE sizeof(pt_entry_t) /* for assembly files */ diff --git a/sys/i386/include/segments.h b/sys/i386/include/segments.h index a9010098e2..273a4fc990 100644 --- a/sys/i386/include/segments.h +++ b/sys/i386/include/segments.h @@ -36,7 +36,7 @@ * * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 * $FreeBSD: src/sys/i386/include/segments.h,v 1.24 1999/12/29 04:33:07 peter Exp $ - * $DragonFly: src/sys/i386/include/Attic/segments.h,v 1.2 2003/06/17 04:28:36 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/segments.h,v 1.3 2003/06/28 02:09:49 dillon Exp $ */ #ifndef _MACHINE_SEGMENTS_H_ @@ -244,9 +244,6 @@ struct region_descriptor { #define NLDT (LBSDICALLS_SEL + 1) #ifdef _KERNEL -#ifndef currentldt -extern int currentldt; -#endif extern int _default_ldt; extern union descriptor gdt[]; extern struct soft_segment_descriptor gdt_segs[]; diff --git a/sys/i386/include/types.h b/sys/i386/include/types.h index eb755067c3..903a5eeb62 100644 --- a/sys/i386/include/types.h +++ b/sys/i386/include/types.h @@ -32,7 +32,7 @@ * * @(#)types.h 8.3 (Berkeley) 1/5/94 * $FreeBSD: src/sys/i386/include/types.h,v 1.19.2.1 2001/03/21 10:50:58 peter Exp $ - * $DragonFly: src/sys/i386/include/Attic/types.h,v 1.2 2003/06/17 04:28:36 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/types.h,v 1.3 2003/06/28 02:09:49 dillon Exp $ */ #ifndef _MACHINE_TYPES_H_ @@ -61,6 +61,9 @@ typedef int intfptr_t; typedef unsigned int uintfptr_t; #endif +typedef unsigned int *pd_entry_t; +typedef unsigned int *pt_entry_t; + /* Interrupt mask (spl, xxx_imask, etc) */ typedef __uint32_t intrmask_t; diff --git a/sys/i386/isa/icu_vector.s b/sys/i386/isa/icu_vector.s index e05c47c7b0..a4ec0df3a6 100644 --- a/sys/i386/isa/icu_vector.s +++ b/sys/i386/isa/icu_vector.s @@ -1,7 +1,7 @@ /* * from: vector.s, 386BSD 0.1 unknown origin * $FreeBSD: src/sys/i386/isa/icu_vector.s,v 1.14.2.2 2000/07/18 21:12:42 dfr Exp $ - * $DragonFly: src/sys/i386/isa/Attic/icu_vector.s,v 1.4 2003/06/22 08:54:22 dillon Exp $ + * $DragonFly: src/sys/i386/isa/Attic/icu_vector.s,v 1.5 2003/06/28 02:09:52 dillon Exp $ */ /* @@ -101,6 +101,7 @@ IDTVEC(vec_name) ; \ pushl %fs ; \ mov $KDSEL,%ax ; \ mov %ax,%es ; \ + mov $KPSEL,%ax ; \ mov %ax,%fs ; \ movl (3+8+0)*4(%esp),%ecx ; /* ... %ecx from thin frame ... */ \ movl %ecx,(3+6)*4(%esp) ; /* ... to fat frame ... */ \ @@ -123,6 +124,7 @@ IDTVEC(vec_name) ; \ mov $KDSEL,%ax ; /* ... and reload with kernel's own ... */ \ mov %ax,%ds ; /* ... early for obsolete reasons */ \ mov %ax,%es ; \ + mov $KPSEL,%ax ; \ mov %ax,%fs ; \ maybe_extra_ipending ; \ movb _imen + IRQ_BYTE(irq_num),%al ; \ diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 08867f17c9..2ee226d0da 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -40,7 +40,7 @@ * * @(#)init_main.c 8.9 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/init_main.c,v 1.134.2.8 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/kern/init_main.c,v 1.13 2003/06/27 20:27:18 dillon Exp $ + * $DragonFly: src/sys/kern/init_main.c,v 1.14 2003/06/28 02:09:52 dillon Exp $ */ #include "opt_init_path.h" @@ -164,10 +164,9 @@ sysinit_add(struct sysinit **set) void mi_startup(void) { - - register struct sysinit **sipp; /* system initialization*/ - register struct sysinit **xipp; /* interior loop of sort*/ - register struct sysinit *save; /* bubble*/ + struct sysinit **sipp; /* system initialization*/ + struct sysinit **xipp; /* interior loop of sort*/ + struct sysinit *save; /* bubble*/ restart: /* diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index ed5f8d56fc..f8c32991d7 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -37,7 +37,7 @@ * * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95 * $FreeBSD: src/sys/kern/kern_synch.c,v 1.87.2.6 2002/10/13 07:29:53 kbyanc Exp $ - * $DragonFly: src/sys/kern/kern_synch.c,v 1.9 2003/06/27 01:53:25 dillon Exp $ + * $DragonFly: src/sys/kern/kern_synch.c,v 1.10 2003/06/28 02:09:52 dillon Exp $ */ #include "opt_ktrace.h" @@ -67,6 +67,7 @@ u_char curpriority; int hogticks; int lbolt; int sched_quantum; /* Roundrobin scheduling quantum in ticks. */ +int ncpus; static struct callout loadav_callout; diff --git a/sys/platform/pc32/i386/bios.c b/sys/platform/pc32/i386/bios.c index d3867178d8..d11764ae75 100644 --- a/sys/platform/pc32/i386/bios.c +++ b/sys/platform/pc32/i386/bios.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/bios.c,v 1.29.2.3 2001/07/19 18:07:35 imp Exp $ - * $DragonFly: src/sys/platform/pc32/i386/bios.c,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/bios.c,v 1.3 2003/06/28 02:09:47 dillon Exp $ */ /* @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -252,11 +253,7 @@ set_bios_selectors(struct bios_segments *seg, int flags) }; union descriptor *p_gdt; -#ifdef SMP - p_gdt = &gdt[cpuid * NGDT]; -#else - p_gdt = gdt; -#endif + p_gdt = &gdt[mycpu->gd_cpuid * NGDT]; ssd.ssd_base = seg->code32.base; ssd.ssd_limit = seg->code32.limit; diff --git a/sys/platform/pc32/i386/exception.s b/sys/platform/pc32/i386/exception.s index e04b0dcade..98053cc0e4 100644 --- a/sys/platform/pc32/i386/exception.s +++ b/sys/platform/pc32/i386/exception.s @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/exception.s,v 1.65.2.3 2001/08/15 01:23:49 peter Exp $ - * $DragonFly: src/sys/platform/pc32/i386/exception.s,v 1.5 2003/06/23 23:36:05 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/exception.s,v 1.6 2003/06/28 02:09:47 dillon Exp $ */ #include "npx.h" @@ -47,11 +47,6 @@ #include "assym.s" -#ifdef SMP -#define MOVL_KPSEL_EAX movl $KPSEL,%eax -#else -#define MOVL_KPSEL_EAX -#endif #define SEL_RPL_MASK 0x0003 .text @@ -172,7 +167,7 @@ IDTVEC(fpu) mov $KDSEL,%ax mov %ax,%ds mov %ax,%es - MOVL_KPSEL_EAX + movl $KPSEL,%eax mov %ax,%fs FAKE_MCOUNT(13*4(%esp)) @@ -226,7 +221,7 @@ alltraps_with_regs_pushed: mov $KDSEL,%ax mov %ax,%ds mov %ax,%es - MOVL_KPSEL_EAX + movl $KPSEL,%eax mov %ax,%fs FAKE_MCOUNT(13*4(%esp)) calltrap: @@ -273,7 +268,7 @@ IDTVEC(syscall) mov $KDSEL,%ax /* switch to kernel segments */ mov %ax,%ds mov %ax,%es - MOVL_KPSEL_EAX + movl $KPSEL,%eax mov %ax,%fs movl TF_ERR(%esp),%eax /* copy saved eflags to final spot */ movl %eax,TF_EFLAGS(%esp) @@ -313,7 +308,7 @@ IDTVEC(int0x80_syscall) mov $KDSEL,%ax /* switch to kernel segments */ mov %ax,%ds mov %ax,%es - MOVL_KPSEL_EAX + movl $KPSEL,%eax mov %ax,%fs movl $2,TF_ERR(%esp) /* sizeof "int 0x80" */ FAKE_MCOUNT(13*4(%esp)) diff --git a/sys/platform/pc32/i386/genassym.c b/sys/platform/pc32/i386/genassym.c index 7c7de231d7..88f9c9c546 100644 --- a/sys/platform/pc32/i386/genassym.c +++ b/sys/platform/pc32/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/platform/pc32/i386/genassym.c,v 1.15 2003/06/27 20:27:15 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/genassym.c,v 1.16 2003/06/28 02:09:47 dillon Exp $ */ #include "opt_user_ldt.h" @@ -95,10 +95,8 @@ ASSYM(MTD_CPL, offsetof(struct mi_thread, mtd_cpl)); ASSYM(TDPRI_CRIT, TDPRI_CRIT); -#ifdef SMP ASSYM(P_ONCPU, offsetof(struct proc, p_oncpu)); ASSYM(P_LASTCPU, offsetof(struct proc, p_lastcpu)); -#endif ASSYM(SSLEEP, SSLEEP); ASSYM(SRUN, SRUN); @@ -196,7 +194,6 @@ ASSYM(GD_REQPRI, offsetof(struct globaldata, gd_reqpri)); ASSYM(GD_CURRENTLDT, offsetof(struct globaldata, gd_currentldt)); #endif -#ifdef SMP ASSYM(GD_CPUID, offsetof(struct globaldata, gd_cpuid)); ASSYM(GD_CPU_LOCKID, offsetof(struct globaldata, gd_cpu_lockid)); ASSYM(GD_OTHER_CPUS, offsetof(struct globaldata, gd_other_cpus)); @@ -210,17 +207,15 @@ ASSYM(GD_PRV_CADDR1, offsetof(struct globaldata, gd_prv_CADDR1)); ASSYM(GD_PRV_CADDR2, offsetof(struct globaldata, gd_prv_CADDR2)); ASSYM(GD_PRV_CADDR3, offsetof(struct globaldata, gd_prv_CADDR3)); ASSYM(GD_PRV_PADDR1, offsetof(struct globaldata, gd_prv_PADDR1)); -#endif + ASSYM(PS_IDLESTACK, offsetof(struct privatespace, idlestack)); +ASSYM(PS_IDLESTACK_PAGE, offsetof(struct privatespace, idlestack) / PAGE_SIZE); ASSYM(PS_IDLESTACK_TOP, sizeof(struct privatespace)); ASSYM(PS_SIZEOF, sizeof(struct privatespace)); ASSYM(KCSEL, GSEL(GCODE_SEL, SEL_KPL)); ASSYM(KDSEL, GSEL(GDATA_SEL, SEL_KPL)); - -#ifdef SMP ASSYM(KPSEL, GSEL(GPRIV_SEL, SEL_KPL)); -#endif ASSYM(BC32SEL, GSEL(GBIOSCODE32_SEL, SEL_KPL)); ASSYM(GPROC0_SEL, GPROC0_SEL); diff --git a/sys/platform/pc32/i386/globals.s b/sys/platform/pc32/i386/globals.s index 0d19507956..7233aaaa59 100644 --- a/sys/platform/pc32/i386/globals.s +++ b/sys/platform/pc32/i386/globals.s @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/globals.s,v 1.13.2.1 2000/05/16 06:58:06 dillon Exp $ - * $DragonFly: src/sys/platform/pc32/i386/globals.s,v 1.9 2003/06/27 20:27:15 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/globals.s,v 1.10 2003/06/28 02:09:47 dillon Exp $ */ #include "opt_user_ldt.h" @@ -43,7 +43,6 @@ * segment. */ .data -#ifdef SMP .globl _CPU_prvspace, _lapic .set _CPU_prvspace,(MPPTDI << PDRSHIFT) .set _lapic,_CPU_prvspace + (NPTEPG-1) * PAGE_SIZE @@ -54,13 +53,6 @@ .globl globaldata .set globaldata,0 -#else - .globl _CPU_prvspace - ALIGN_PAGE -globaldata: -_CPU_prvspace: - .space PS_SIZEOF -#endif /* * Define layout of the global data. On SMP this lives in @@ -84,7 +76,7 @@ _CPU_prvspace: .set gd_currentldt,globaldata + GD_CURRENTLDT #endif -#ifndef SMP +#if 0 .globl _curthread, _npxthread, _astpending, _reqpri .globl _common_tss, _idlethread .set _curthread,globaldata + GD_CURTHREAD @@ -104,7 +96,6 @@ _CPU_prvspace: #endif #endif -#ifdef SMP /* * The BSP version of these get setup in locore.s and pmap.c, while * the AP versions are setup in mp_machdep.c. @@ -127,9 +118,8 @@ _CPU_prvspace: .set gd_prv_CADDR2,globaldata + GD_PRV_CADDR2 .set gd_prv_CADDR3,globaldata + GD_PRV_CADDR3 .set gd_prv_PADDR1,globaldata + GD_PRV_PADDR1 -#endif -#if defined(SMP) || defined(APIC_IO) +#if defined(APIC_IO) .globl lapic_eoi, lapic_svr, lapic_tpr, lapic_irr1, lapic_ver .globl lapic_icr_lo,lapic_icr_hi,lapic_isr1 /* diff --git a/sys/platform/pc32/i386/locore.s b/sys/platform/pc32/i386/locore.s index fdb3c6826f..2cd3e51833 100644 --- a/sys/platform/pc32/i386/locore.s +++ b/sys/platform/pc32/i386/locore.s @@ -35,7 +35,7 @@ * * from: @(#)locore.s 7.3 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/locore.s,v 1.132.2.10 2003/02/03 20:54:49 jhb Exp $ - * $DragonFly: src/sys/platform/pc32/i386/locore.s,v 1.3 2003/06/18 18:29:55 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/locore.s,v 1.4 2003/06/28 02:09:47 dillon Exp $ * * originally from: locore.s, by William F. Jolitz * @@ -116,22 +116,19 @@ _bootinfo: .space BOOTINFO_SIZE /* bootinfo that we can handle */ _KERNend: .long 0 /* phys addr end of kernel (just after bss) */ physfree: .long 0 /* phys addr of next free page */ -#ifdef SMP .globl _cpu0prvpage cpu0pp: .long 0 /* phys addr cpu0 private pg */ _cpu0prvpage: .long 0 /* relocated version */ +cpu0idlestk: .long 0 /* stack for the idle thread */ .globl _SMPpt SMPptpa: .long 0 /* phys addr SMP page table */ _SMPpt: .long 0 /* relocated version */ -#endif /* SMP */ .globl _IdlePTD _IdlePTD: .long 0 /* phys addr of kernel PTD */ -#ifdef SMP .globl _KPTphys -#endif _KPTphys: .long 0 /* phys addr of kernel page tables */ .globl _proc0paddr @@ -163,16 +160,16 @@ _pc98_system_parameter: #define R(foo) ((foo)-KERNBASE) -#define ALLOCPAGES(foo) \ - movl R(physfree), %esi ; \ - movl $((foo)*PAGE_SIZE), %eax ; \ - addl %esi, %eax ; \ - movl %eax, R(physfree) ; \ - movl %esi, %edi ; \ - movl $((foo)*PAGE_SIZE),%ecx ; \ - xorl %eax,%eax ; \ - cld ; \ - rep ; \ +#define ALLOCPAGES(foo) \ + movl R(physfree), %esi ; \ + movl $((foo)*PAGE_SIZE), %eax ; \ + addl %esi, %eax ; \ + movl %eax, R(physfree) ; \ + movl %esi, %edi ; \ + movl $((foo)*PAGE_SIZE),%ecx ; \ + xorl %eax,%eax ; \ + cld ; \ + rep ; \ stosb /* @@ -341,6 +338,7 @@ NON_GPROF_ENTRY(btext) orl $CR0_PE|CR0_PG,%eax /* enable paging */ movl %eax,%cr0 /* and let's page NOW! */ + #ifdef BDE_DEBUGGER /* * Complete the adjustments for paging so that we can keep tracing through @@ -355,6 +353,7 @@ NON_GPROF_ENTRY(btext) /* now running relocated at KERNBASE where the system is linked to run */ begin: + /* * set up the bootstrap stack. The pcb sits at the end of the * bootstrap stack. @@ -377,6 +376,7 @@ begin: movl physfree, %esi pushl %esi /* value of first for init386(first) */ + call _init386 /* wire 386 chip for unix operation */ popl %esi @@ -741,6 +741,7 @@ no_kernend: movl %esi,R(_KERNend) /* save end of kernel */ movl %esi,R(physfree) /* next free page is at end of kernel */ + /* Allocate Kernel Page Tables */ ALLOCPAGES(NKPT) movl %esi,R(_KPTphys) @@ -763,19 +764,21 @@ no_kernend: addl $KERNBASE, %esi movl %esi, R(_vm86paddr) -#ifdef SMP /* Allocate cpu0's private data page */ ALLOCPAGES(1) movl %esi,R(cpu0pp) addl $KERNBASE, %esi movl %esi, R(_cpu0prvpage) /* relocated to KVM space */ +/* Allocate cpu0's idle stack */ + ALLOCPAGES(UPAGES) + movl %esi,R(cpu0idlestk) + /* Allocate SMP page table page */ ALLOCPAGES(1) movl %esi,R(SMPptpa) addl $KERNBASE, %esi movl %esi, R(_SMPpt) /* relocated to KVM space */ -#endif /* SMP */ /* Map read-only from zero to the end of the kernel text section */ xorl %eax, %eax @@ -846,7 +849,6 @@ map_read_write: movl $ISA_HOLE_LENGTH>>PAGE_SHIFT, %ecx fillkpt(R(_vm86pa), $PG_RW|PG_U) -#ifdef SMP /* Map cpu0's private page into global kmem (4K @ cpu0prvpage) */ movl R(cpu0pp), %eax movl $1, %ecx @@ -863,6 +865,12 @@ map_read_write: movl $1, %ecx /* one private page coming right up */ fillkpt(R(SMPptpa), $PG_RW) +/* Map the cpu0's idle thread stack */ + movl R(cpu0idlestk), %eax + movl $PS_IDLESTACK_PAGE, %ebx + movl $UPAGES, %ecx + fillkpt(R(SMPptpa), $PG_RW) + /* ... and put the page table table in the pde. */ movl R(SMPptpa), %eax movl $MPPTDI, %ebx @@ -876,6 +884,7 @@ map_read_write: movl $1, %ecx /* one private pt coming right up */ fillkpt(R(SMPptpa), $PG_RW) +#ifdef SMP /* Initialize mp lock to allow early traps */ movl $1, R(_mp_lock) #endif /* SMP */ diff --git a/sys/platform/pc32/i386/machdep.c b/sys/platform/pc32/i386/machdep.c index 89b6bcb0ee..6bb3641a25 100644 --- a/sys/platform/pc32/i386/machdep.c +++ b/sys/platform/pc32/i386/machdep.c @@ -36,7 +36,7 @@ * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $ - * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.13 2003/06/27 03:30:37 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.14 2003/06/28 02:09:47 dillon Exp $ */ #include "apm.h" @@ -1146,14 +1146,10 @@ union descriptor gdt[NGDT * MAXCPU]; /* global descriptor table */ static struct gate_descriptor idt0[NIDT]; struct gate_descriptor *idt = &idt0[0]; /* interrupt descriptor table */ union descriptor ldt[NLDT]; /* local descriptor table */ -#ifdef SMP -/* table descriptors - used to load tables by microp */ + +/* table descriptors - used to load tables by cpu */ struct region_descriptor r_gdt, r_idt; -#endif -#ifndef SMP -extern struct segment_descriptor common_tssd, *tss_gdt; -#endif int private_tss; /* flag indicating private tss */ #if defined(I586_CPU) && !defined(NO_F00F_HACK) @@ -1648,7 +1644,7 @@ physmap_done: */ #ifdef SMP - /* make hole for AP bootstrap code */ + /* make hole for AP bootstrap code YYY */ physmap[1] = mp_bootaddress(physmap[1] / 1024); /* look for the MP hardware - needed for apic addresses */ @@ -1850,15 +1846,10 @@ physmap_done: } void -init386(first) - int first; +init386(int first) { struct gate_descriptor *gdp; int gsel_tss, metadata_missing, off, x; -#ifndef SMP - /* table descriptors - used to load tables by microp */ - struct region_descriptor r_gdt, r_idt; -#endif struct globaldata *gd; /* @@ -1900,17 +1891,15 @@ init386(first) */ gdt_segs[GCODE_SEL].ssd_limit = atop(0 - 1); gdt_segs[GDATA_SEL].ssd_limit = atop(0 - 1); -#ifdef SMP + gdt_segs[GPRIV_SEL].ssd_limit = atop(sizeof(struct privatespace) - 1); gdt_segs[GPRIV_SEL].ssd_base = (int) &CPU_prvspace[0]; gdt_segs[GPROC0_SEL].ssd_base = (int) &CPU_prvspace[0].globaldata.gd_common_tss; -#else - gdt_segs[GPRIV_SEL].ssd_limit = atop(0 - 1); - gdt_segs[GPROC0_SEL].ssd_base = (int) &common_tss; -#endif + gd->gd_prvspace = &CPU_prvspace[0]; + /* * Note: on both UP and SMP curthread must be set non-NULL * early in the boot sequence because the system assumes @@ -1946,7 +1935,7 @@ init386(first) _default_ldt = GSEL(GLDT_SEL, SEL_KPL); lldt(_default_ldt); #ifdef USER_LDT - currentldt = _default_ldt; + gd->gd_currentldt = _default_ldt; #endif /* exceptions */ @@ -2008,13 +1997,13 @@ init386(first) * make an initial tss so cpu can get interrupt stack on syscall! * The 16 bytes is to save room for a VM86 context. */ - common_tss.tss_esp0 = (int) thread0.td_pcb - 16; - common_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL) ; + gd->gd_common_tss.tss_esp0 = (int) thread0.td_pcb - 16; + gd->gd_common_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL) ; gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); private_tss = 0; - tss_gdt = &gdt[GPROC0_SEL].sd; - common_tssd = *tss_gdt; - common_tss.tss_ioopt = (sizeof common_tss) << 16; + gd->gd_tss_gdt = &gdt[GPROC0_SEL].sd; + gd->gd_common_tssd = *gd->gd_tss_gdt; + gd->gd_common_tss.tss_ioopt = (sizeof common_tss) << 16; ltr(gsel_tss); dblfault_tss.tss_esp = dblfault_tss.tss_esp0 = dblfault_tss.tss_esp1 = @@ -2067,16 +2056,18 @@ init386(first) thread0.td_pcb->pcb_flags = 0; thread0.td_pcb->pcb_cr3 = (int)IdlePTD; /* should already be setup */ #ifdef SMP +#if 0 thread0.td_pcb->pcb_mpnest = 1; +#endif #endif thread0.td_pcb->pcb_ext = 0; proc0.p_md.md_regs = &proc0_tf; } /* - * Initialize machine-dependant portions of the global data structure - * - * YYY do we need to reserve pcb space for idlethread? + * Initialize machine-dependant portions of the global data structure. + * Note that the global data area and cpu0's idlestack in the private + * data space were allocated in locore. */ void cpu_gdinit(struct globaldata *gd, int cpu) @@ -2085,7 +2076,8 @@ cpu_gdinit(struct globaldata *gd, int cpu) TAILQ_INIT(&gd->gd_tdfreeq); /* for pmap_{new,dispose}_thread() */ if (cpu) - gd->gd_curthread = &gd->gd_idlethread; + gd->gd_curthread = &gd->gd_idlethread; + sp = gd->gd_prvspace->idlestack; lwkt_init_thread(&gd->gd_idlethread, sp, 0); gd->gd_idlethread.td_switch = cpu_lwkt_switch; @@ -2098,11 +2090,9 @@ static void f00f_hack(void *unused); SYSINIT(f00f_hack, SI_SUB_INTRINSIC, SI_ORDER_FIRST, f00f_hack, NULL); static void -f00f_hack(void *unused) { +f00f_hack(void *unused) +{ struct gate_descriptor *new_idt; -#ifndef SMP - struct region_descriptor r_idt; -#endif vm_offset_t tmp; if (!has_f00f_bug) diff --git a/sys/platform/pc32/i386/mp_machdep.c b/sys/platform/pc32/i386/mp_machdep.c index d58be41847..65a4a1bb64 100644 --- a/sys/platform/pc32/i386/mp_machdep.c +++ b/sys/platform/pc32/i386/mp_machdep.c @@ -23,7 +23,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/mp_machdep.c,v 1.115.2.15 2003/03/14 21:22:35 jhb Exp $ - * $DragonFly: src/sys/platform/pc32/i386/mp_machdep.c,v 1.6 2003/06/21 07:54:56 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/mp_machdep.c,v 1.7 2003/06/28 02:09:47 dillon Exp $ */ #include "opt_cpu.h" @@ -249,7 +249,6 @@ int current_postcode; extern struct region_descriptor r_gdt, r_idt; int bsp_apic_ready = 0; /* flags useability of BSP apic */ -int mp_ncpus; /* # of CPUs, including BSP */ int mp_naps; /* # of Applications processors */ int mp_nbusses; /* # of busses */ int mp_napics; /* # of IO APICs */ @@ -2384,31 +2383,6 @@ smp_invltlb(void) #endif /* APIC_IO */ } -void -invlpg(u_int addr) -{ - __asm __volatile("invlpg (%0)"::"r"(addr):"memory"); - - /* send a message to the other CPUs */ - smp_invltlb(); -} - -void -invltlb(void) -{ - u_long temp; - - /* - * This should be implemented as load_cr3(rcr3()) when load_cr3() is - * inlined. - */ - __asm __volatile("movl %%cr3, %0; movl %0, %%cr3":"=r"(temp) :: "memory"); - - /* send a message to the other CPUs */ - smp_invltlb(); -} - - /* * When called the executing CPU will send an IPI to all other CPUs * requesting that they halt execution. diff --git a/sys/platform/pc32/i386/pmap.c b/sys/platform/pc32/i386/pmap.c index 6bdabe61aa..058b4dcada 100644 --- a/sys/platform/pc32/i386/pmap.c +++ b/sys/platform/pc32/i386/pmap.c @@ -40,7 +40,7 @@ * * from: @(#)pmap.c 7.7 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/i386/pmap.c,v 1.250.2.18 2002/03/06 22:48:53 silby Exp $ - * $DragonFly: src/sys/platform/pc32/i386/pmap.c,v 1.11 2003/06/27 03:30:37 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/pmap.c,v 1.12 2003/06/28 02:09:47 dillon Exp $ */ /* @@ -177,9 +177,7 @@ static struct pv_entry *pvinit; * All those kernel PT submaps that BSD is so fond of */ pt_entry_t *CMAP1 = 0; -static pt_entry_t *CMAP2, *ptmmap; caddr_t CADDR1 = 0, ptvmmap = 0; -static caddr_t CADDR2; static pt_entry_t *msgbufmap; struct msgbuf *msgbufp=0; @@ -189,12 +187,7 @@ struct msgbuf *msgbufp=0; static pt_entry_t *pt_crashdumpmap; static caddr_t crashdumpmap; -#ifdef SMP extern pt_entry_t *SMPpt; -#else -static pt_entry_t *PMAP1 = 0; -static unsigned *PADDR1 = 0; -#endif static PMAP_INLINE void free_pv_entry __P((pv_entry_t pv)); static unsigned * get_ptbase __P((pmap_t pmap)); @@ -285,9 +278,7 @@ pmap_bootstrap(firstaddr, loadaddr) { vm_offset_t va; pt_entry_t *pte; -#ifdef SMP struct globaldata *gd; -#endif int i; avail_start = firstaddr; @@ -337,19 +328,12 @@ pmap_bootstrap(firstaddr, loadaddr) * CMAP1/CMAP2 are used for zeroing and copying pages. */ SYSMAP(caddr_t, CMAP1, CADDR1, 1) - SYSMAP(caddr_t, CMAP2, CADDR2, 1) /* * Crashdump maps. */ SYSMAP(caddr_t, pt_crashdumpmap, crashdumpmap, MAXDUMPPGS); - /* - * ptvmmap is used for reading arbitrary physical pages via /dev/mem. - * XXX ptmmap is not used. - */ - SYSMAP(caddr_t, ptmmap, ptvmmap, 1) - /* * msgbufp is used to map the system message buffer. * XXX msgbufmap is not used. @@ -357,25 +341,17 @@ pmap_bootstrap(firstaddr, loadaddr) SYSMAP(struct msgbuf *, msgbufmap, msgbufp, atop(round_page(MSGBUF_SIZE))) -#if !defined(SMP) - /* - * ptemap is used for pmap_pte_quick - */ - SYSMAP(unsigned *, PMAP1, PADDR1, 1); -#endif - virtual_avail = va; - *(int *) CMAP1 = *(int *) CMAP2 = 0; + *(int *) CMAP1 = 0; for (i = 0; i < NKPT; i++) PTD[i] = 0; - pgeflag = 0; -#if !defined(SMP) /* XXX - see also mp_machdep.c */ - if (cpu_feature & CPUID_PGE) { + /* XXX - see also mp_machdep.c */ + if (ncpus == 1 && (cpu_feature & CPUID_PGE)) pgeflag = PG_G; - } -#endif + else + pgeflag = 0; /* * Initialize the 4MB page size flag @@ -399,34 +375,35 @@ pmap_bootstrap(firstaddr, loadaddr) ptditmp |= PG_V | PG_RW | PG_PS | PG_U | pgeflag; pdir4mb = ptditmp; -#if !defined(SMP) - /* - * Enable the PSE mode. - */ - load_cr4(rcr4() | CR4_PSE); + if (ncpus == 1) { + /* + * Enable the PSE mode. + */ + load_cr4(rcr4() | CR4_PSE); - /* - * We can do the mapping here for the single processor - * case. We simply ignore the old page table page from - * now on. - */ - /* - * For SMP, we still need 4K pages to bootstrap APs, - * PSE will be enabled as soon as all APs are up. - */ - PTD[KPTDI] = (pd_entry_t) ptditmp; - kernel_pmap->pm_pdir[KPTDI] = (pd_entry_t) ptditmp; - invltlb(); -#endif + /* + * We can do the mapping here for the single processor + * case. We simply ignore the old page table page from + * now on. + */ + /* + * For SMP, we still need 4K pages to bootstrap APs, + * PSE will be enabled as soon as all APs are up. + */ + PTD[KPTDI] = (pd_entry_t) ptditmp; + kernel_pmap->pm_pdir[KPTDI] = (pd_entry_t) ptditmp; + invltlb(); + } } #endif -#ifdef SMP +#ifdef APIC_IO if (cpu_apic_address == 0) panic("pmap_bootstrap: no local apic!"); /* local apic is mapped on last page */ SMPpt[NPTEPG - 1] = (pt_entry_t)(PG_V | PG_RW | PG_N | pgeflag | (cpu_apic_address & PG_FRAME)); +#endif /* BSP does this itself, AP's get it pre-set */ gd = &CPU_prvspace[0].globaldata; @@ -438,7 +415,6 @@ pmap_bootstrap(firstaddr, loadaddr) gd->gd_prv_CADDR2 = CPU_prvspace[0].CPAGE2; gd->gd_prv_CADDR3 = CPU_prvspace[0].CPAGE3; gd->gd_prv_PADDR1 = (unsigned *)CPU_prvspace[0].PPAGE1; -#endif invltlb(); } @@ -640,11 +616,11 @@ get_ptbase(pmap) */ static unsigned * -pmap_pte_quick(pmap, va) - register pmap_t pmap; - vm_offset_t va; +pmap_pte_quick(pmap_t pmap, vm_offset_t va) { + struct globaldata *gd = mycpu; unsigned pde, newpf; + if ((pde = (unsigned) pmap->pm_pdir[va >> PDRSHIFT]) != 0) { unsigned frame = (unsigned) pmap->pm_pdir[PTDPTDI] & PG_FRAME; unsigned index = i386_btop(va); @@ -654,19 +630,11 @@ pmap_pte_quick(pmap, va) return (unsigned *) PTmap + index; } newpf = pde & PG_FRAME; -#ifdef SMP - if ( ((* (unsigned *) prv_PMAP1) & PG_FRAME) != newpf) { - * (unsigned *) prv_PMAP1 = newpf | PG_RW | PG_V; - cpu_invlpg(prv_PADDR1); - } - return prv_PADDR1 + ((unsigned) index & (NPTEPG - 1)); -#else - if ( ((* (unsigned *) PMAP1) & PG_FRAME) != newpf) { - * (unsigned *) PMAP1 = newpf | PG_RW | PG_V; - invltlb_1pg((vm_offset_t) PADDR1); + if ( ((* (unsigned *) gd->gd_prv_PMAP1) & PG_FRAME) != newpf) { + * (unsigned *) gd->gd_prv_PMAP1 = newpf | PG_RW | PG_V; + cpu_invlpg(gd->gd_prv_PADDR1); } - return PADDR1 + ((unsigned) index & (NPTEPG - 1)); -#endif + return gd->gd_prv_PADDR1 + ((unsigned) index & (NPTEPG - 1)); } return (0); } @@ -1087,9 +1055,7 @@ pmap_pinit(pmap) if ((ptdpg->flags & PG_ZERO) == 0) bzero(pmap->pm_pdir, PAGE_SIZE); -#ifdef SMP pmap->pm_pdir[MPPTDI] = PTD[MPPTDI]; -#endif /* install self-referential address mapping entry */ *(unsigned *) (pmap->pm_pdir + PTDPTDI) = @@ -1147,9 +1113,7 @@ pmap_release_free_page(pmap, p) */ if (p->pindex == PTDPTDI) { bzero(pde + KPTDI, nkpt * PTESIZE); -#ifdef SMP pde[MPPTDI] = 0; -#endif pde[APTDPTDI] = 0; pmap_kremove((vm_offset_t) pmap->pm_pdir); } @@ -2653,39 +2617,25 @@ pmap_kernel() * the page into KVM and using bzero to clear its contents. */ void -pmap_zero_page(phys) - vm_offset_t phys; +pmap_zero_page(vm_offset_t phys) { -#ifdef SMP - if (*(int *) prv_CMAP3) + struct globaldata *gd = mycpu; + + if (*(int *)gd->gd_prv_CMAP3) panic("pmap_zero_page: prv_CMAP3 busy"); - *(int *) prv_CMAP3 = PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M; - cpu_invlpg(prv_CADDR3); + *(int *)gd->gd_prv_CMAP3 = + PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M; + cpu_invlpg(gd->gd_prv_CADDR3); #if defined(I686_CPU) if (cpu_class == CPUCLASS_686) - i686_pagezero(prv_CADDR3); + i686_pagezero(gd->gd_prv_CADDR3); else #endif - bzero(prv_CADDR3, PAGE_SIZE); - - *(int *) prv_CMAP3 = 0; -#else - if (*(int *) CMAP2) - panic("pmap_zero_page: CMAP2 busy"); - - *(int *) CMAP2 = PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M; - invltlb_1pg((vm_offset_t)CADDR2); + bzero(gd->gd_prv_CADDR3, PAGE_SIZE); -#if defined(I686_CPU) - if (cpu_class == CPUCLASS_686) - i686_pagezero(CADDR2); - else -#endif - bzero(CADDR2, PAGE_SIZE); - *(int *) CMAP2 = 0; -#endif + *(int *) gd->gd_prv_CMAP3 = 0; } /* @@ -2700,36 +2650,22 @@ pmap_zero_page_area(phys, off, size) int off; int size; { -#ifdef SMP - if (*(int *) prv_CMAP3) + struct globaldata *gd = mycpu; + + if (*(int *) gd->gd_prv_CMAP3) panic("pmap_zero_page: prv_CMAP3 busy"); - *(int *) prv_CMAP3 = PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M; - cpu_invlpg(prv_CADDR3); + *(int *) gd->gd_prv_CMAP3 = PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M; + cpu_invlpg(gd->gd_prv_CADDR3); #if defined(I686_CPU) if (cpu_class == CPUCLASS_686 && off == 0 && size == PAGE_SIZE) - i686_pagezero(prv_CADDR3); + i686_pagezero(gd->gd_prv_CADDR3); else #endif - bzero((char *)prv_CADDR3 + off, size); - - *(int *) prv_CMAP3 = 0; -#else - if (*(int *) CMAP2) - panic("pmap_zero_page: CMAP2 busy"); - - *(int *) CMAP2 = PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M; - invltlb_1pg((vm_offset_t)CADDR2); + bzero((char *)gd->gd_prv_CADDR3 + off, size); -#if defined(I686_CPU) - if (cpu_class == CPUCLASS_686 && off == 0 && size == PAGE_SIZE) - i686_pagezero(CADDR2); - else -#endif - bzero((char *)CADDR2 + off, size); - *(int *) CMAP2 = 0; -#endif + *(int *) gd->gd_prv_CMAP3 = 0; } /* @@ -2743,43 +2679,23 @@ pmap_copy_page(src, dst) vm_offset_t src; vm_offset_t dst; { -#ifdef SMP - if (*(int *) prv_CMAP1) + struct globaldata *gd = mycpu; + + if (*(int *) gd->gd_prv_CMAP1) panic("pmap_copy_page: prv_CMAP1 busy"); - if (*(int *) prv_CMAP2) + if (*(int *) gd->gd_prv_CMAP2) panic("pmap_copy_page: prv_CMAP2 busy"); - *(int *) prv_CMAP1 = PG_V | (src & PG_FRAME) | PG_A; - *(int *) prv_CMAP2 = PG_V | PG_RW | (dst & PG_FRAME) | PG_A | PG_M; - - cpu_invlpg(prv_CADDR1); - cpu_invlpg(prv_CADDR2); - - bcopy(prv_CADDR1, prv_CADDR2, PAGE_SIZE); - - *(int *) prv_CMAP1 = 0; - *(int *) prv_CMAP2 = 0; -#else - if (*(int *) CMAP1 || *(int *) CMAP2) - panic("pmap_copy_page: CMAP busy"); + *(int *) gd->gd_prv_CMAP1 = PG_V | (src & PG_FRAME) | PG_A; + *(int *) gd->gd_prv_CMAP2 = PG_V | PG_RW | (dst & PG_FRAME) | PG_A | PG_M; - *(int *) CMAP1 = PG_V | (src & PG_FRAME) | PG_A; - *(int *) CMAP2 = PG_V | PG_RW | (dst & PG_FRAME) | PG_A | PG_M; -#if defined(I386_CPU) - if (cpu_class == CPUCLASS_386) { - invltlb(); - } else -#endif - { - invlpg((u_int)CADDR1); - invlpg((u_int)CADDR2); - } + cpu_invlpg(gd->gd_prv_CADDR1); + cpu_invlpg(gd->gd_prv_CADDR2); - bcopy(CADDR1, CADDR2, PAGE_SIZE); + bcopy(gd->gd_prv_CADDR1, gd->gd_prv_CADDR2, PAGE_SIZE); - *(int *) CMAP1 = 0; - *(int *) CMAP2 = 0; -#endif + *(int *) gd->gd_prv_CMAP1 = 0; + *(int *) gd->gd_prv_CMAP2 = 0; } diff --git a/sys/platform/pc32/i386/support.s b/sys/platform/pc32/i386/support.s index 22eb2713d4..3b09cd7e36 100644 --- a/sys/platform/pc32/i386/support.s +++ b/sys/platform/pc32/i386/support.s @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/support.s,v 1.67.2.5 2001/08/15 01:23:50 peter Exp $ - * $DragonFly: src/sys/platform/pc32/i386/support.s,v 1.5 2003/06/18 18:29:55 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/support.s,v 1.6 2003/06/28 02:09:47 dillon Exp $ */ #include "npx.h" @@ -1544,9 +1544,7 @@ ENTRY(lgdt) mov %ax,%es mov %ax,%gs mov %ax,%ss -#ifdef SMP movl $KPSEL,%eax -#endif mov %ax,%fs /* reload code selector by turning return into intersegmental return */ diff --git a/sys/platform/pc32/i386/swtch.s b/sys/platform/pc32/i386/swtch.s index 90e8319501..11d6e75e21 100644 --- a/sys/platform/pc32/i386/swtch.s +++ b/sys/platform/pc32/i386/swtch.s @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/swtch.s,v 1.89.2.10 2003/01/23 03:36:24 ps Exp $ - * $DragonFly: src/sys/platform/pc32/i386/swtch.s,v 1.14 2003/06/27 03:30:37 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/swtch.s,v 1.15 2003/06/28 02:09:47 dillon Exp $ */ #include "npx.h" @@ -304,12 +304,15 @@ ENTRY(cpu_heavy_restore) btrl %esi, _private_tss jae 3f -#ifdef SMP + + /* + * There is no way to get the address of a segment-accessed variable + * so we store a self-referential pointer at the base of the per-cpu + * data area and add the appropriate offset. + */ movl $gd_common_tssd, %edi addl %fs:0, %edi -#else - movl $_common_tssd, %edi -#endif + /* * Move the correct TSS descriptor into the GDT slot, then reload * tr. YYY not sure what is going on here @@ -328,11 +331,7 @@ ENTRY(cpu_heavy_restore) */ 3: movl P_VMSPACE(%ecx), %ebx -#ifdef SMP movl _cpuid, %eax -#else - xorl %eax, %eax -#endif btsl %eax, VM_PMAP+PM_ACTIVE(%ebx) /* diff --git a/sys/platform/pc32/i386/sys_machdep.c b/sys/platform/pc32/i386/sys_machdep.c index bf3db2374f..2b6ee54ea4 100644 --- a/sys/platform/pc32/i386/sys_machdep.c +++ b/sys/platform/pc32/i386/sys_machdep.c @@ -32,7 +32,7 @@ * * from: @(#)sys_machdep.c 5.5 (Berkeley) 1/19/91 * $FreeBSD: src/sys/i386/i386/sys_machdep.c,v 1.47.2.3 2002/10/07 17:20:00 jhb Exp $ - * $DragonFly: src/sys/platform/pc32/i386/sys_machdep.c,v 1.5 2003/06/25 03:55:53 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/sys_machdep.c,v 1.6 2003/06/28 02:09:47 dillon Exp $ * */ @@ -257,7 +257,7 @@ set_user_ldt(struct pcb *pcb) gdt[GUSERLDT_SEL].sd = pcb_ldt->ldt_sd; #endif lldt(GSEL(GUSERLDT_SEL, SEL_KPL)); - currentldt = GSEL(GUSERLDT_SEL, SEL_KPL); + mycpu->gd_currentldt = GSEL(GUSERLDT_SEL, SEL_KPL); } struct pcb_ldt * @@ -305,7 +305,7 @@ user_ldt_free(struct pcb *pcb) if (pcb == curthread->td_pcb) { lldt(_default_ldt); - currentldt = _default_ldt; + mycpu->gd_currentldt = _default_ldt; } if (--pcb_ldt->ldt_refcnt == 0) { diff --git a/sys/platform/pc32/i386/trap.c b/sys/platform/pc32/i386/trap.c index bdb65a81ca..932980e45d 100644 --- a/sys/platform/pc32/i386/trap.c +++ b/sys/platform/pc32/i386/trap.c @@ -36,7 +36,7 @@ * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/trap.c,v 1.147.2.11 2003/02/27 19:09:59 luoqi Exp $ - * $DragonFly: src/sys/platform/pc32/i386/trap.c,v 1.8 2003/06/25 03:55:53 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/trap.c,v 1.9 2003/06/28 02:09:47 dillon Exp $ */ /* @@ -999,10 +999,12 @@ trap_fatal(frame, eva) void dblfault_handler() { + struct globaldata *gd = mycpu; + printf("\nFatal double fault:\n"); - printf("eip = 0x%x\n", common_tss.tss_eip); - printf("esp = 0x%x\n", common_tss.tss_esp); - printf("ebp = 0x%x\n", common_tss.tss_ebp); + printf("eip = 0x%x\n", gd->gd_common_tss.tss_eip); + printf("esp = 0x%x\n", gd->gd_common_tss.tss_esp); + printf("ebp = 0x%x\n", gd->gd_common_tss.tss_ebp); #ifdef SMP /* three seperate prints in case of a trap on an unmapped page */ printf("mp_lock = %08x; ", mp_lock); diff --git a/sys/platform/pc32/icu/icu_vector.s b/sys/platform/pc32/icu/icu_vector.s index c6b8a5469f..77cecc3694 100644 --- a/sys/platform/pc32/icu/icu_vector.s +++ b/sys/platform/pc32/icu/icu_vector.s @@ -1,7 +1,7 @@ /* * from: vector.s, 386BSD 0.1 unknown origin * $FreeBSD: src/sys/i386/isa/icu_vector.s,v 1.14.2.2 2000/07/18 21:12:42 dfr Exp $ - * $DragonFly: src/sys/platform/pc32/icu/icu_vector.s,v 1.4 2003/06/22 08:54:22 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/icu/icu_vector.s,v 1.5 2003/06/28 02:09:52 dillon Exp $ */ /* @@ -101,6 +101,7 @@ IDTVEC(vec_name) ; \ pushl %fs ; \ mov $KDSEL,%ax ; \ mov %ax,%es ; \ + mov $KPSEL,%ax ; \ mov %ax,%fs ; \ movl (3+8+0)*4(%esp),%ecx ; /* ... %ecx from thin frame ... */ \ movl %ecx,(3+6)*4(%esp) ; /* ... to fat frame ... */ \ @@ -123,6 +124,7 @@ IDTVEC(vec_name) ; \ mov $KDSEL,%ax ; /* ... and reload with kernel's own ... */ \ mov %ax,%ds ; /* ... early for obsolete reasons */ \ mov %ax,%es ; \ + mov $KPSEL,%ax ; \ mov %ax,%fs ; \ maybe_extra_ipending ; \ movb _imen + IRQ_BYTE(irq_num),%al ; \ diff --git a/sys/platform/pc32/include/asnames.h b/sys/platform/pc32/include/asnames.h index 0a8c8fbb50..317eadc1bc 100644 --- a/sys/platform/pc32/include/asnames.h +++ b/sys/platform/pc32/include/asnames.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/asnames.h,v 1.44.2.8 2003/01/22 20:14:53 jhb Exp $ - * $DragonFly: src/sys/platform/pc32/include/Attic/asnames.h,v 1.8 2003/06/22 08:54:20 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/include/Attic/asnames.h,v 1.9 2003/06/28 02:09:49 dillon Exp $ */ #ifndef _MACHINE_ASNAMES_H_ @@ -330,12 +330,7 @@ #endif /* __ELF__ */ -#if defined(SMP) || defined(__ELF__) -#ifdef SMP #define FS(x) %fs:gd_ ## x -#else -#define FS(x) x -#endif #define _common_tss FS(common_tss) #define _common_tssd FS(common_tssd) @@ -364,6 +359,4 @@ #define _idlestack FS(idlestack) #define _idlestack_top FS(idlestack_top) -#endif - #endif /* !_MACHINE_ASNAMES_H_ */ diff --git a/sys/platform/pc32/include/globaldata.h b/sys/platform/pc32/include/globaldata.h index a8c72497e4..43a0b6a4fe 100644 --- a/sys/platform/pc32/include/globaldata.h +++ b/sys/platform/pc32/include/globaldata.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/globaldata.h,v 1.11.2.1 2000/05/16 06:58:10 dillon Exp $ - * $DragonFly: src/sys/platform/pc32/include/globaldata.h,v 1.11 2003/06/27 20:27:18 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/include/globaldata.h,v 1.12 2003/06/28 02:09:49 dillon Exp $ */ /* @@ -56,10 +56,11 @@ struct globaldata { int gd_currentldt; /* USER_LDT */ u_int gd_cpuid; struct timeval gd_stattv; -#ifdef SMP + struct thread gd_idlethread; + int gd_inside_intr; + u_int gd_cpu_lockid; u_int gd_other_cpus; - int gd_inside_intr; u_int gd_ss_eflags; pt_entry_t *gd_prv_CMAP1; pt_entry_t *gd_prv_CMAP2; @@ -69,9 +70,7 @@ struct globaldata { caddr_t gd_prv_CADDR2; caddr_t gd_prv_CADDR3; unsigned *gd_prv_PADDR1; -#endif u_int gd_astpending; - struct thread gd_idlethread; }; /* @@ -84,13 +83,11 @@ struct privatespace { struct globaldata globaldata; char __filler0[PAGE_SIZE - sizeof(struct globaldata)]; -#ifdef SMP /* page 1..4 - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */ char CPAGE1[PAGE_SIZE]; char CPAGE2[PAGE_SIZE]; char CPAGE3[PAGE_SIZE]; char PPAGE1[PAGE_SIZE]; -#endif /* page 5..4+UPAGES - idle stack (UPAGES pages) */ char idlestack[UPAGES * PAGE_SIZE]; diff --git a/sys/platform/pc32/include/globals.h b/sys/platform/pc32/include/globals.h index ec16b7a6e9..cc916afd24 100644 --- a/sys/platform/pc32/include/globals.h +++ b/sys/platform/pc32/include/globals.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/globals.h,v 1.5.2.1 2000/05/16 06:58:10 dillon Exp $ - * $DragonFly: src/sys/platform/pc32/include/Attic/globals.h,v 1.7 2003/06/20 02:09:54 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/include/Attic/globals.h,v 1.8 2003/06/28 02:09:49 dillon Exp $ */ #ifndef _MACHINE_GLOBALS_H_ @@ -43,7 +43,6 @@ * move to another cpu preemptively so the 'gd' pointer is good until you * block. */ -#if defined(SMP) || defined(KLD_MODULE) || defined(ACTUALLY_LKM_NOT_KERNEL) extern int __mycpu__dummy; @@ -59,18 +58,13 @@ _get_mycpu(void) #define mycpu _get_mycpu() -#else - -#define mycpu (&CPU_prvspace[0].globaldata) - -#endif - /* * note: curthread is never NULL, but curproc can be. Also note that * in Turtle, the current pcb is stored in the thread structure. */ -#define curthread (mycpu->gd_curthread) -#define curproc (curthread->td_proc) +#define curthread mycpu->gd_curthread +#define curproc curthread->td_proc +#define npxthread mycpu->gd_npxthread #endif /* _KERNEL */ diff --git a/sys/platform/pc32/include/pcb.h b/sys/platform/pc32/include/pcb.h index 732881a8cf..a3b31552b9 100644 --- a/sys/platform/pc32/include/pcb.h +++ b/sys/platform/pc32/include/pcb.h @@ -35,7 +35,7 @@ * * from: @(#)pcb.h 5.10 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/include/pcb.h,v 1.32.2.1 2001/08/15 01:23:52 peter Exp $ - * $DragonFly: src/sys/platform/pc32/include/pcb.h,v 1.3 2003/06/18 18:29:58 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/include/pcb.h,v 1.4 2003/06/28 02:09:49 dillon Exp $ */ #ifndef _I386_PCB_H_ @@ -73,10 +73,12 @@ struct pcb { #define FP_SOFTFP 0x01 /* process using software fltng pnt emulator */ #define PCB_DBREGS 0x02 /* process using debug registers */ caddr_t pcb_onfault; /* copyin/out fault recovery */ +#if 0 #ifdef SMP u_long pcb_mpnest; #else u_long pcb_mpnest_dontuse; +#endif #endif int pcb_gs; struct pcb_ext *pcb_ext; /* optional pcb extension */ diff --git a/sys/platform/pc32/isa/icu_vector.s b/sys/platform/pc32/isa/icu_vector.s index 5bab1861dc..b2bdf4fb3c 100644 --- a/sys/platform/pc32/isa/icu_vector.s +++ b/sys/platform/pc32/isa/icu_vector.s @@ -1,7 +1,7 @@ /* * from: vector.s, 386BSD 0.1 unknown origin * $FreeBSD: src/sys/i386/isa/icu_vector.s,v 1.14.2.2 2000/07/18 21:12:42 dfr Exp $ - * $DragonFly: src/sys/platform/pc32/isa/Attic/icu_vector.s,v 1.4 2003/06/22 08:54:22 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/isa/Attic/icu_vector.s,v 1.5 2003/06/28 02:09:52 dillon Exp $ */ /* @@ -101,6 +101,7 @@ IDTVEC(vec_name) ; \ pushl %fs ; \ mov $KDSEL,%ax ; \ mov %ax,%es ; \ + mov $KPSEL,%ax ; \ mov %ax,%fs ; \ movl (3+8+0)*4(%esp),%ecx ; /* ... %ecx from thin frame ... */ \ movl %ecx,(3+6)*4(%esp) ; /* ... to fat frame ... */ \ @@ -123,6 +124,7 @@ IDTVEC(vec_name) ; \ mov $KDSEL,%ax ; /* ... and reload with kernel's own ... */ \ mov %ax,%ds ; /* ... early for obsolete reasons */ \ mov %ax,%es ; \ + mov $KPSEL,%ax ; \ mov %ax,%fs ; \ maybe_extra_ipending ; \ movb _imen + IRQ_BYTE(irq_num),%al ; \ diff --git a/sys/platform/vkernel/i386/genassym.c b/sys/platform/vkernel/i386/genassym.c index 27cdd371db..0e3cfb40b3 100644 --- a/sys/platform/vkernel/i386/genassym.c +++ b/sys/platform/vkernel/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/platform/vkernel/i386/genassym.c,v 1.15 2003/06/27 20:27:15 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/i386/genassym.c,v 1.16 2003/06/28 02:09:47 dillon Exp $ */ #include "opt_user_ldt.h" @@ -95,10 +95,8 @@ ASSYM(MTD_CPL, offsetof(struct mi_thread, mtd_cpl)); ASSYM(TDPRI_CRIT, TDPRI_CRIT); -#ifdef SMP ASSYM(P_ONCPU, offsetof(struct proc, p_oncpu)); ASSYM(P_LASTCPU, offsetof(struct proc, p_lastcpu)); -#endif ASSYM(SSLEEP, SSLEEP); ASSYM(SRUN, SRUN); @@ -196,7 +194,6 @@ ASSYM(GD_REQPRI, offsetof(struct globaldata, gd_reqpri)); ASSYM(GD_CURRENTLDT, offsetof(struct globaldata, gd_currentldt)); #endif -#ifdef SMP ASSYM(GD_CPUID, offsetof(struct globaldata, gd_cpuid)); ASSYM(GD_CPU_LOCKID, offsetof(struct globaldata, gd_cpu_lockid)); ASSYM(GD_OTHER_CPUS, offsetof(struct globaldata, gd_other_cpus)); @@ -210,17 +207,15 @@ ASSYM(GD_PRV_CADDR1, offsetof(struct globaldata, gd_prv_CADDR1)); ASSYM(GD_PRV_CADDR2, offsetof(struct globaldata, gd_prv_CADDR2)); ASSYM(GD_PRV_CADDR3, offsetof(struct globaldata, gd_prv_CADDR3)); ASSYM(GD_PRV_PADDR1, offsetof(struct globaldata, gd_prv_PADDR1)); -#endif + ASSYM(PS_IDLESTACK, offsetof(struct privatespace, idlestack)); +ASSYM(PS_IDLESTACK_PAGE, offsetof(struct privatespace, idlestack) / PAGE_SIZE); ASSYM(PS_IDLESTACK_TOP, sizeof(struct privatespace)); ASSYM(PS_SIZEOF, sizeof(struct privatespace)); ASSYM(KCSEL, GSEL(GCODE_SEL, SEL_KPL)); ASSYM(KDSEL, GSEL(GDATA_SEL, SEL_KPL)); - -#ifdef SMP ASSYM(KPSEL, GSEL(GPRIV_SEL, SEL_KPL)); -#endif ASSYM(BC32SEL, GSEL(GBIOSCODE32_SEL, SEL_KPL)); ASSYM(GPROC0_SEL, GPROC0_SEL); diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 91aba55fa5..3af265bbc3 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -37,7 +37,7 @@ * * @(#)systm.h 8.7 (Berkeley) 3/29/95 * $FreeBSD: src/sys/sys/systm.h,v 1.111.2.18 2002/12/17 18:04:02 sam Exp $ - * $DragonFly: src/sys/sys/systm.h,v 1.6 2003/06/25 03:56:10 dillon Exp $ + * $DragonFly: src/sys/sys/systm.h,v 1.7 2003/06/28 02:09:52 dillon Exp $ */ #ifndef _SYS_SYSTM_H_ @@ -77,6 +77,8 @@ extern int bootverbose; /* nonzero to print verbose messages */ extern int maxusers; /* system tune hint */ +extern int ncpus; /* total number of cpus (real, hyper, virtual)*/ + #ifdef INVARIANTS /* The option is always available */ #define KASSERT(exp,msg) do { if (!(exp)) panic msg; } while (0) #define KKASSERT(exp) if (!(exp)) panic("assertion: " #exp " in " __FUNCTION__) -- 2.41.0