Index: sys/i386/i386/locore.s @@ -72,17 +72,7 @@ .set PTD,PTmap + (PTDPTDI * PAGE_SIZE) .set PTDpde,PTD + (PTDPTDI * PDESIZE) -#ifdef SMP /* - * Define layout of per-cpu address space. - * This is "constructed" in locore.s on the BSP and in mp_machdep.c - * for each AP. DO NOT REORDER THESE WITHOUT UPDATING THE REST! - */ - .globl SMP_prvspace - .set SMP_prvspace,(MPPTDI << PDRSHIFT) -#endif /* SMP */ - -/* * Compiled KERNBASE location and the kernel load address */ .globl kernbase @@ -106,16 +96,6 @@ 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 */ - - .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 */ @@ -763,20 +743,6 @@ 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 SMP page table page */ - ALLOCPAGES(1) - movl %esi,R(SMPptpa) - addl $KERNBASE, %esi - movl %esi, R(SMPpt) /* relocated to KVM space */ -#endif /* SMP */ - /* Map page zero read-write so bios32 calls can use it */ xorl %eax, %eax movl $PG_RW,%edx @@ -870,37 +836,6 @@ 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 - fillkptphys($PG_RW) - -/* Map SMP page table page into global kmem FWIW */ - movl R(SMPptpa), %eax - movl $1, %ecx - fillkptphys($PG_RW) - -/* Map the private page into the SMP page table */ - movl R(cpu0pp), %eax - movl $0, %ebx /* pte offset = 0 */ - movl $1, %ecx /* one private page coming right up */ - fillkpt(R(SMPptpa), $PG_RW) - -/* ... and put the page table table in the pde. */ - movl R(SMPptpa), %eax - movl $MPPTDI, %ebx - movl $1, %ecx - fillkpt(R(IdlePTD), $PG_RW) - -/* Fakeup VA for the local apic to allow early traps. */ - ALLOCPAGES(1) - movl %esi, %eax - movl $(NPTEPG-1), %ebx /* pte offset = NTEPG-1 */ - movl $1, %ecx /* one private pt coming right up */ - fillkpt(R(SMPptpa), $PG_RW) -#endif /* SMP */ - /* install a pde for temporary double map of bottom of VA */ movl R(KPTphys), %eax xorl %ebx, %ebx Index: sys/i386/i386/machdep.c @@ -127,7 +127,6 @@ #include #endif #ifdef SMP -#include #include #endif @@ -210,9 +209,7 @@ struct kva_md_info kmi; static struct trapframe proc0_tf; -#ifndef SMP -static struct pcpu __pcpu; -#endif +struct pcpu __pcpu[MAXCPU]; struct mtx icu_lock; @@ -2124,11 +2121,7 @@ gdt_segs[GUFS_SEL].ssd_limit = atop(0 - 1); gdt_segs[GUGS_SEL].ssd_limit = atop(0 - 1); -#ifdef SMP - pc = &SMP_prvspace[0].pcpu; -#else - pc = &__pcpu; -#endif + pc = &__pcpu[0]; gdt_segs[GPRIV_SEL].ssd_limit = atop(0 - 1); gdt_segs[GPRIV_SEL].ssd_base = (int) pc; gdt_segs[GPROC0_SEL].ssd_base = (int) &pc->pc_common_tss; Index: sys/i386/i386/mp_machdep.c @@ -80,7 +80,6 @@ #include #include /** COUNT_XINVLTLB_HITS */ #include -#include #define WARMBOOT_TARGET 0 #define WARMBOOT_OFF (KERNBASE + 0x0467) @@ -156,6 +155,8 @@ int boot_cpu_id = -1; /* designated BSP */ extern int nkpt; +extern struct pcpu __pcpu[]; + /* * CPU topology map datastructures for HTT. */ @@ -166,12 +167,12 @@ char *bootSTK; static int bootAP; +/* Free these after use */ +void *bootstacks[MAXCPU]; + /* Hotwire a 0->4MB V==P mapping */ extern pt_entry_t *KPTphys; -/* SMP page table page */ -extern pt_entry_t *SMPpt; - struct pcb stoppcbs[MAXCPU]; /* Variables needed for SMP tlb shootdown. */ @@ -506,6 +507,7 @@ void init_secondary(void) { + struct pcpu *pc; vm_offset_t addr; int gsel_tss; int x, myid; @@ -513,11 +515,18 @@ /* bootAP is set in start_ap() to our ID. */ myid = bootAP; - gdt_segs[GPRIV_SEL].ssd_base = (int) &SMP_prvspace[myid]; - gdt_segs[GPROC0_SEL].ssd_base = - (int) &SMP_prvspace[myid].pcpu.pc_common_tss; - SMP_prvspace[myid].pcpu.pc_prvspace = - &SMP_prvspace[myid].pcpu; + + /* Get per-cpu data */ + pc = &__pcpu[myid]; + + /* prime data pabe or it to use */ + pcpu_init(pc, myid, sizeof(struct pcpu)); + pc->pc_apic_id = cpu_apic_ids[myid]; + pc->pc_prvspace = pc; + pc->pc_curthread = 0; + + gdt_segs[GPRIV_SEL].ssd_base = (int) pc; + gdt_segs[GPROC0_SEL].ssd_base = (int) &pc->pc_common_tss; for (x = 0; x < NGDT; x++) { ssdtosd(&gdt_segs[x], &gdt[myid * NGDT + x].sd); @@ -590,7 +599,6 @@ printf("SMP: cpuid = %d\n", PCPU_GET(cpuid)); printf("SMP: actual apic_id = %d\n", lapic_id()); printf("SMP: correct apic_id = %d\n", PCPU_GET(apic_id)); - printf("PTD[MPPTDI] = %#jx\n", (uintmax_t)PTD[MPPTDI]); panic("cpuid mismatch! boom!!"); } @@ -746,11 +754,9 @@ #ifndef PC98 u_char mpbiosreason; #endif - struct pcpu *pc; - char *stack; uintptr_t kptbase; u_int32_t mpbioswarmvec; - int apic_id, cpu, i, pg; + int apic_id, cpu, i; POSTCODE(START_ALL_APS_POST); @@ -778,24 +784,8 @@ for (cpu = 1; cpu < mp_ncpus; cpu++) { apic_id = cpu_apic_ids[cpu]; - /* first page of AP's private space */ - pg = cpu * i386_btop(sizeof(struct privatespace)); - - /* allocate a new private data page */ - pc = (struct pcpu *)kmem_alloc(kernel_map, PAGE_SIZE); - - /* wire it into the private page table page */ - SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(pc)); - /* allocate and set up an idle stack data page */ - stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); /* XXXKSE */ - for (i = 0; i < KSTACK_PAGES; i++) - SMPpt[pg + 1 + i] = (pt_entry_t) - (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); - - /* prime data page for it to use */ - pcpu_init(pc, cpu, sizeof(struct pcpu)); - pc->pc_apic_id = apic_id; + bootstacks[cpu] = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); /* setup a vector to our boot code */ *((volatile u_short *) WARMBOOT_OFF) = WARMBOOT_TARGET; @@ -805,8 +795,7 @@ outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */ #endif - bootSTK = &SMP_prvspace[cpu].idlekstack[KSTACK_PAGES * - PAGE_SIZE]; + bootSTK = (char *)bootstacks[cpu] + KSTACK_PAGES * PAGE_SIZE - 4; bootAP = cpu; /* attempt to start the Application Processor */ @@ -835,19 +824,6 @@ outb(CMOS_DATA, mpbiosreason); #endif - /* - * Set up the idle context for the BSP. Similar to above except - * that some was done by locore, some by pmap.c and some is implicit - * because the BSP is cpu#0 and the page is initially zero and also - * because we can refer to variables by name on the BSP.. - */ - - /* Allocate and setup BSP idle stack */ - stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); - for (i = 0; i < KSTACK_PAGES; i++) - SMPpt[1 + i] = (pt_entry_t) - (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); - for (i = 0; i < NKPT; i++) PTD[i] = 0; pmap_invalidate_range(kernel_pmap, 0, NKPT * NBPDR - 1); Index: sys/i386/i386/pmap.c @@ -233,9 +233,6 @@ */ static caddr_t crashdumpmap; -#ifdef SMP -extern pt_entry_t *SMPpt; -#endif static pt_entry_t *PMAP1 = 0, *PMAP2; static pt_entry_t *PADDR1 = 0, *PADDR2; #ifdef SMP @@ -1212,11 +1209,7 @@ LIST_INSERT_HEAD(&allpmaps, pmap, pm_list); mtx_unlock_spin(&allpmaps_lock); /* Wire in kernel global address entries. */ - /* XXX copies current process, does not fill in MPPTDI */ bcopy(PTD + KPTDI, pmap->pm_pdir + KPTDI, nkpt * sizeof(pd_entry_t)); -#ifdef SMP - pmap->pm_pdir[MPPTDI] = PTD[MPPTDI]; -#endif /* install self-referential address mapping entry(s) */ for (i = 0; i < NPGPTD; i++) { @@ -1453,9 +1446,6 @@ bzero(pmap->pm_pdir + PTDPTDI, (nkpt + NPGPTD) * sizeof(*pmap->pm_pdir)); -#ifdef SMP - pmap->pm_pdir[MPPTDI] = 0; -#endif pmap_qremove((vm_offset_t)pmap->pm_pdir, NPGPTD); Index: sys/i386/include/pmap.h @@ -120,15 +120,8 @@ * * XXX This works for now, but I am not real happy with it, I'll fix it * right after I fix locore.s and the magic 28K hole - * - * SMP_PRIVPAGES: The per-cpu address space is 0xff80000 -> 0xffbfffff */ -#ifdef SMP -#define MPPTDI (NPDEPTD-1) /* per cpu ptd entry */ -#define KPTDI (MPPTDI-NKPDE) /* start of kernel virtual pde's */ -#else -#define KPTDI (NPDEPTD-NKPDE)/* start of kernel virtual pde's */ -#endif /* SMP */ +#define KPTDI (NPDEPTD-NKPDE) /* start of kernel virtual pde's */ #define PTDPTDI (KPTDI-NPGPTD) /* ptd entry that points to ptd! */ /*