PERFORCE change 128784 for review
Peter Wemm
peter at FreeBSD.org
Wed Nov 7 11:58:35 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=128784
Change 128784 by peter at peter_overcee on 2007/11/07 19:57:56
Begin backporting amd64 smp startup.
Eliminates a whole mess of bogus code that dates back to the early
i386 smp pcpu stuff at a fixed virtual address. This became a sewer
dumping ground for stuff that didn't need to be there. It also isn't
minidump friendly.
Affected files ...
.. //depot/projects/hammer/sys/i386/i386/locore.s#17 edit
.. //depot/projects/hammer/sys/i386/i386/machdep.c#80 edit
.. //depot/projects/hammer/sys/i386/i386/mp_machdep.c#66 edit
.. //depot/projects/hammer/sys/i386/i386/pmap.c#98 edit
.. //depot/projects/hammer/sys/i386/include/pmap.h#31 edit
.. //depot/projects/hammer/sys/i386/include/privatespace.h#3 delete
Differences ...
==== //depot/projects/hammer/sys/i386/i386/locore.s#17 (text+ko) ====
@@ -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 */
-
/*
* Enable PSE and PGE.
*/
@@ -854,37 +820,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 */
-
/*
* Create an identity mapping for low physical memory, including the kernel.
* The part of this mapping that covers the first 1 MB of physical memory
==== //depot/projects/hammer/sys/i386/i386/machdep.c#80 (text+ko) ====
@@ -127,7 +127,6 @@
#include <machine/perfmon.h>
#endif
#ifdef SMP
-#include <machine/privatespace.h>
#include <machine/smp.h>
#endif
@@ -207,9 +206,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;
@@ -2116,11 +2113,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;
==== //depot/projects/hammer/sys/i386/i386/mp_machdep.c#66 (text+ko) ====
@@ -78,7 +78,6 @@
#include <machine/psl.h>
#include <machine/smp.h>
#include <machine/specialreg.h>
-#include <machine/privatespace.h>
#define WARMBOOT_TARGET 0
#define WARMBOOT_OFF (KERNBASE + 0x0467)
@@ -134,6 +133,8 @@
int boot_cpu_id = -1; /* designated BSP */
extern int nkpt;
+extern struct pcpu __pcpu[];
+
/*
* CPU topology map datastructures for HTT.
*/
@@ -147,9 +148,6 @@
/* 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. */
@@ -493,6 +491,7 @@
void
init_secondary(void)
{
+ struct pcpu *pc;
vm_offset_t addr;
int gsel_tss;
int x, myid;
@@ -500,11 +499,10 @@
/* 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;
+ pc = &__pcpu[myid];
+ gdt_segs[GPRIV_SEL].ssd_base = (int) &pc;
+ gdt_segs[GPROC0_SEL].ssd_base = (int) &pc->pcpu.pc_common_tss;
+ pc->pc_prvspace = pc;
for (x = 0; x < NGDT; x++) {
ssdtosd(&gdt_segs[x], &gdt[myid * NGDT + x].sd);
@@ -760,15 +758,10 @@
/* 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++)
+ /* YYYSMP fix */
SMPpt[pg + 1 + i] = (pt_entry_t)
(PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
@@ -784,6 +777,7 @@
outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */
#endif
+ /* allocate kstack like on amd64 */
bootSTK = &SMP_prvspace[cpu].idlekstack[KSTACK_PAGES *
PAGE_SIZE];
bootAP = cpu;
@@ -824,7 +818,7 @@
/* 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)
+ /* YYYSMP */SMPpt[1 + i] = (pt_entry_t)
(PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
for (i = 0; i < NKPT; i++)
==== //depot/projects/hammer/sys/i386/i386/pmap.c#98 (text+ko) ====
@@ -1305,11 +1305,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++) {
@@ -1552,9 +1548,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);
==== //depot/projects/hammer/sys/i386/include/pmap.h#31 (text+ko) ====
@@ -133,15 +133,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! */
/*
More information about the p4-projects
mailing list