Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/amd64/mp_machdep.c
Show First 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* AP CPU's call this to initialize themselves. | * AP CPU's call this to initialize themselves. | ||||
*/ | */ | ||||
void | void | ||||
init_secondary(void) | init_secondary(void) | ||||
{ | { | ||||
struct pcpu *pc; | struct pcpu *pc; | ||||
struct nmi_pcpu *np; | struct nmi_pcpu *np; | ||||
u_int64_t msr, cr0; | u_int64_t cr0; | ||||
int cpu, gsel_tss, x; | int cpu, gsel_tss, x; | ||||
struct region_descriptor ap_gdt; | struct region_descriptor ap_gdt; | ||||
/* Set by the startup code for us to use */ | /* Set by the startup code for us to use */ | ||||
cpu = bootAP; | cpu = bootAP; | ||||
/* Init tss */ | /* Init tss */ | ||||
common_tss[cpu] = common_tss[0]; | common_tss[cpu] = common_tss[0]; | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | init_secondary(void) | ||||
* Set to a known state: | * Set to a known state: | ||||
* Set by mpboot.s: CR0_PG, CR0_PE | * Set by mpboot.s: CR0_PG, CR0_PE | ||||
* Set by cpu_setregs: CR0_NE, CR0_MP, CR0_TS, CR0_WP, CR0_AM | * Set by cpu_setregs: CR0_NE, CR0_MP, CR0_TS, CR0_WP, CR0_AM | ||||
*/ | */ | ||||
cr0 = rcr0(); | cr0 = rcr0(); | ||||
cr0 &= ~(CR0_CD | CR0_NW | CR0_EM); | cr0 &= ~(CR0_CD | CR0_NW | CR0_EM); | ||||
load_cr0(cr0); | load_cr0(cr0); | ||||
/* Set up the fast syscall stuff */ | amd64_conf_fast_syscall(); | ||||
msr = rdmsr(MSR_EFER) | EFER_SCE; | |||||
wrmsr(MSR_EFER, msr); | |||||
wrmsr(MSR_LSTAR, (u_int64_t)IDTVEC(fast_syscall)); | |||||
wrmsr(MSR_CSTAR, (u_int64_t)IDTVEC(fast_syscall32)); | |||||
msr = ((u_int64_t)GSEL(GCODE_SEL, SEL_KPL) << 32) | | |||||
((u_int64_t)GSEL(GUCODE32_SEL, SEL_UPL) << 48); | |||||
wrmsr(MSR_STAR, msr); | |||||
wrmsr(MSR_SF_MASK, PSL_NT|PSL_T|PSL_I|PSL_C|PSL_D); | |||||
/* signal our startup to the BSP. */ | /* signal our startup to the BSP. */ | ||||
mp_naps++; | mp_naps++; | ||||
/* Spin until the BSP releases the AP's. */ | /* Spin until the BSP releases the AP's. */ | ||||
while (atomic_load_acq_int(&aps_ready) == 0) | while (atomic_load_acq_int(&aps_ready) == 0) | ||||
ia32_pause(); | ia32_pause(); | ||||
▲ Show 20 Lines • Show All 177 Lines • Show Last 20 Lines |