summaryrefslogtreecommitdiffstats
path: root/sys/i386
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2008-08-01 20:31:07 +0000
committerjhb <jhb@FreeBSD.org>2008-08-01 20:31:07 +0000
commit9f24284792578fe6719ac047902f8d63965aad57 (patch)
treea5df1a2bec2302ce378a55d79695b00d447355ff /sys/i386
parent61015bfe529531b1b3b5fd8d8033c6640920321b (diff)
downloadFreeBSD-src-9f24284792578fe6719ac047902f8d63965aad57.zip
FreeBSD-src-9f24284792578fe6719ac047902f8d63965aad57.tar.gz
MFC: Drastically simplify the i386 pcpu backend by merging parts of the
amd64 mechanism over.
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/i386/locore.s65
-rw-r--r--sys/i386/i386/machdep.c11
-rw-r--r--sys/i386/i386/mp_machdep.c69
-rw-r--r--sys/i386/i386/pmap.c10
-rw-r--r--sys/i386/include/pmap.h13
5 files changed, 26 insertions, 142 deletions
diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s
index 7ca289c..58a5279 100644
--- a/sys/i386/i386/locore.s
+++ b/sys/i386/i386/locore.s
@@ -72,16 +72,6 @@
.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
*/
@@ -106,16 +96,6 @@ 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 */
-
- .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 @@ 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 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 @@ no_kernend:
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
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index 9489753..8e27e35 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -127,7 +127,6 @@ __FBSDID("$FreeBSD$");
#include <machine/perfmon.h>
#endif
#ifdef SMP
-#include <machine/privatespace.h>
#include <machine/smp.h>
#endif
@@ -210,9 +209,7 @@ vm_paddr_t dump_avail[PHYSMAP_SIZE + 2];
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;
@@ -2175,11 +2172,7 @@ init386(first)
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;
diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c
index 79a9df1..41c3c9a 100644
--- a/sys/i386/i386/mp_machdep.c
+++ b/sys/i386/i386/mp_machdep.c
@@ -79,7 +79,6 @@ __FBSDID("$FreeBSD$");
#include <machine/smp.h>
#include <machine/smptests.h> /** COUNT_XINVLTLB_HITS */
#include <machine/specialreg.h>
-#include <machine/privatespace.h>
#define WARMBOOT_TARGET 0
#define WARMBOOT_OFF (KERNBASE + 0x0467)
@@ -155,6 +154,8 @@ int mp_naps; /* # of Applications processors */
int boot_cpu_id = -1; /* designated BSP */
extern int nkpt;
+extern struct pcpu __pcpu[];
+
/*
* CPU topology map datastructures for HTT.
*/
@@ -165,12 +166,12 @@ static struct cpu_top mp_top;
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. */
@@ -505,6 +506,7 @@ cpu_mp_announce(void)
void
init_secondary(void)
{
+ struct pcpu *pc;
vm_offset_t addr;
int gsel_tss;
int x, myid;
@@ -512,11 +514,18 @@ init_secondary(void)
/* 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 page for 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);
@@ -589,7 +598,6 @@ init_secondary(void)
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!!");
}
@@ -745,11 +753,9 @@ start_all_aps(void)
#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);
@@ -777,24 +783,8 @@ start_all_aps(void)
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;
+ /* allocate and set up a boot stack data page */
+ 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;
@@ -804,8 +794,7 @@ start_all_aps(void)
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 */
@@ -834,19 +823,7 @@ start_all_aps(void)
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));
-
+ /* Undo V==P hack from above */
for (i = 0; i < NKPT; i++)
PTD[i] = 0;
pmap_invalidate_range(kernel_pmap, 0, NKPT * NBPDR - 1);
diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c
index 529b1eb..bb152e1 100644
--- a/sys/i386/i386/pmap.c
+++ b/sys/i386/i386/pmap.c
@@ -232,9 +232,6 @@ struct msgbuf *msgbufp = 0;
*/
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
@@ -1231,11 +1228,7 @@ pmap_pinit(pmap)
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++) {
@@ -1472,9 +1465,6 @@ pmap_release(pmap_t pmap)
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);
diff --git a/sys/i386/include/pmap.h b/sys/i386/include/pmap.h
index fd04c54..20bc3db 100644
--- a/sys/i386/include/pmap.h
+++ b/sys/i386/include/pmap.h
@@ -107,27 +107,16 @@
#endif
#endif
#ifndef NKPDE
-#ifdef SMP
-#define NKPDE (KVA_PAGES - 1) /* number of page tables/pde's */
-#else
#define NKPDE (KVA_PAGES) /* number of page tables/pde's */
#endif
-#endif
/*
* The *PTDI values control the layout of virtual memory
*
* 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! */
/*
OpenPOWER on IntegriCloud