From owner-p4-projects@FreeBSD.ORG Wed Nov 7 20:23:03 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E9F2316A41A; Wed, 7 Nov 2007 20:23:02 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2269416A417 for ; Wed, 7 Nov 2007 20:23:02 +0000 (UTC) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 143D413C4A7 for ; Wed, 7 Nov 2007 20:23:02 +0000 (UTC) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id lA7KN16S033645 for ; Wed, 7 Nov 2007 20:23:01 GMT (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id lA7KN1ns033642 for perforce@freebsd.org; Wed, 7 Nov 2007 20:23:01 GMT (envelope-from peter@freebsd.org) Date: Wed, 7 Nov 2007 20:23:01 GMT Message-Id: <200711072023.lA7KN1ns033642@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Cc: Subject: PERFORCE change 128789 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Nov 2007 20:23:03 -0000 http://perforce.freebsd.org/chv.cgi?CH=128789 Change 128789 by peter@peter_overcee on 2007/11/07 20:22:20 Theoretically finish backporting amd64 pcpu code and expunging nasty old relics of i386 fixed-va pcpu area. Affected files ... .. //depot/projects/hammer/sys/i386/i386/mp_machdep.c#67 edit Differences ... ==== //depot/projects/hammer/sys/i386/i386/mp_machdep.c#67 (text+ko) ==== @@ -145,6 +145,9 @@ char *bootSTK; static int bootAP; +/* Free these after use */ +void *bootstacks[MAXCPU]; + /* Hotwire a 0->4MB V==P mapping */ extern pt_entry_t *KPTphys; @@ -499,10 +502,18 @@ /* bootAP is set in start_ap() to our ID. */ myid = bootAP; + + /* 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->pcpu.pc_common_tss; - pc->pc_prvspace = pc; for (x = 0; x < NGDT; x++) { ssdtosd(&gdt_segs[x], &gdt[myid * NGDT + x].sd); @@ -726,10 +737,9 @@ 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; mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); @@ -755,19 +765,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 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)); - - /* 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; @@ -777,9 +776,7 @@ outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */ #endif - /* allocate kstack like on amd64 */ - 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 */ @@ -808,19 +805,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++) - /* YYYSMP */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);