Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/amd64/mp_machdep.c
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | |||||
#define AP_BOOTPT_SZ (PAGE_SIZE * 4) | #define AP_BOOTPT_SZ (PAGE_SIZE * 4) | ||||
/* Temporary variables for init_secondary() */ | /* Temporary variables for init_secondary() */ | ||||
static char *doublefault_stack; | static char *doublefault_stack; | ||||
static char *mce_stack; | static char *mce_stack; | ||||
static char *nmi_stack; | static char *nmi_stack; | ||||
static char *dbg_stack; | static char *dbg_stack; | ||||
void *bootpcpu; | |||||
extern u_int mptramp_la57; | extern u_int mptramp_la57; | ||||
extern u_int mptramp_nx; | extern u_int mptramp_nx; | ||||
/* | /* | ||||
* Local data and functions. | * Local data and functions. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | init_secondary(void) | ||||
int cpu, gsel_tss, x; | int cpu, gsel_tss, x; | ||||
/* Set by the startup code for us to use */ | /* Set by the startup code for us to use */ | ||||
cpu = bootAP; | cpu = bootAP; | ||||
/* Update microcode before doing anything else. */ | /* Update microcode before doing anything else. */ | ||||
ucode_load_ap(cpu); | ucode_load_ap(cpu); | ||||
/* Get per-cpu data and save */ | /* Initialize the PCPU area. */ | ||||
pc = &__pcpu[cpu]; | pc = bootpcpu; | ||||
/* prime data page for it to use */ | |||||
pcpu_init(pc, cpu, sizeof(struct pcpu)); | pcpu_init(pc, cpu, sizeof(struct pcpu)); | ||||
dpcpu_init(dpcpu, cpu); | dpcpu_init(dpcpu, cpu); | ||||
pc->pc_apic_id = cpu_apic_ids[cpu]; | pc->pc_apic_id = cpu_apic_ids[cpu]; | ||||
pc->pc_prvspace = pc; | pc->pc_prvspace = pc; | ||||
pc->pc_curthread = 0; | pc->pc_curthread = 0; | ||||
pc->pc_tssp = &pc->pc_common_tss; | pc->pc_tssp = &pc->pc_common_tss; | ||||
pc->pc_rsp0 = 0; | pc->pc_rsp0 = 0; | ||||
pc->pc_pti_rsp0 = (((vm_offset_t)&pc->pc_pti_stack + | pc->pc_pti_rsp0 = (((vm_offset_t)&pc->pc_pti_stack + | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | init_secondary(void) | ||||
} | } | ||||
ssdtosyssd(&gdt_segs[GPROC0_SEL], | ssdtosyssd(&gdt_segs[GPROC0_SEL], | ||||
(struct system_segment_descriptor *)&gdt[GPROC0_SEL]); | (struct system_segment_descriptor *)&gdt[GPROC0_SEL]); | ||||
ap_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1; | ap_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1; | ||||
ap_gdt.rd_base = (u_long)gdt; | ap_gdt.rd_base = (u_long)gdt; | ||||
lgdt(&ap_gdt); /* does magic intra-segment return */ | lgdt(&ap_gdt); /* does magic intra-segment return */ | ||||
wrmsr(MSR_FSBASE, 0); /* User value */ | wrmsr(MSR_FSBASE, 0); /* User value */ | ||||
wrmsr(MSR_GSBASE, (u_int64_t)pc); | wrmsr(MSR_GSBASE, (uint64_t)pc); | ||||
wrmsr(MSR_KGSBASE, (u_int64_t)pc); /* XXX User value while we're in the kernel */ | wrmsr(MSR_KGSBASE, 0); /* User value */ | ||||
fix_cpuid(); | fix_cpuid(); | ||||
lidt(&r_idt); | lidt(&r_idt); | ||||
gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); | gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); | ||||
ltr(gsel_tss); | ltr(gsel_tss); | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | mce_stack = (char *)kmem_malloc(MCE_STACK_SIZE, | ||||
M_WAITOK | M_ZERO); | M_WAITOK | M_ZERO); | ||||
nmi_stack = (char *)kmem_malloc_domainset( | nmi_stack = (char *)kmem_malloc_domainset( | ||||
DOMAINSET_PREF(domain), NMI_STACK_SIZE, M_WAITOK | M_ZERO); | DOMAINSET_PREF(domain), NMI_STACK_SIZE, M_WAITOK | M_ZERO); | ||||
dbg_stack = (char *)kmem_malloc_domainset( | dbg_stack = (char *)kmem_malloc_domainset( | ||||
DOMAINSET_PREF(domain), DBG_STACK_SIZE, M_WAITOK | M_ZERO); | DOMAINSET_PREF(domain), DBG_STACK_SIZE, M_WAITOK | M_ZERO); | ||||
dpcpu = (void *)kmem_malloc_domainset(DOMAINSET_PREF(domain), | dpcpu = (void *)kmem_malloc_domainset(DOMAINSET_PREF(domain), | ||||
DPCPU_SIZE, M_WAITOK | M_ZERO); | DPCPU_SIZE, M_WAITOK | M_ZERO); | ||||
bootpcpu = &__pcpu[cpu]; | |||||
bootSTK = (char *)bootstacks[cpu] + | bootSTK = (char *)bootstacks[cpu] + | ||||
kstack_pages * PAGE_SIZE - 8; | kstack_pages * PAGE_SIZE - 8; | ||||
bootAP = cpu; | bootAP = cpu; | ||||
/* attempt to start the Application Processor */ | /* attempt to start the Application Processor */ | ||||
if (!start_ap(apic_id)) { | if (!start_ap(apic_id)) { | ||||
/* restore the warmstart vector */ | /* restore the warmstart vector */ | ||||
*(u_int32_t *) WARMBOOT_OFF = mpbioswarmvec; | *(u_int32_t *) WARMBOOT_OFF = mpbioswarmvec; | ||||
▲ Show 20 Lines • Show All 656 Lines • Show Last 20 Lines |