@@ -252,15 +252,6 @@ apic_ap_start:
252
252
mov %cs , %ax
253
253
mov %ax , %ds
254
254
255
- /* Generate a new processor id. This is not the APIC id. We just
256
- need a way to find ourselves a stack without stomping on other
257
- APs that may be doing this concurrently. */
258
- xor %ax , %ax
259
- mov %ax , %bp
260
- inc %ax
261
- lock ; xaddw %ax , %ds :(ap_cpu_id - apic_ap_start)(%bp ) /* avoid relocation entries */
262
- mov %ax , %bx
263
-
264
255
xor %ax , %ax
265
256
mov %ax , %sp
266
257
@@ -281,14 +272,18 @@ apic_ap_start32:
281
272
mov %ax , %es
282
273
mov %ax , %fs
283
274
mov %ax , %gs
284
-
275
+
285
276
movl $0x8000 , %ebp
286
-
277
+
278
+ /* generate a unique ap cpu id (0 means 1st ap, not bsp!) */
279
+ xorl %eax , %eax
280
+ incl %eax
281
+ lock ; xaddl %eax , (ap_cpu_id - apic_ap_start)(%ebp ) /* avoid relocation entries */
282
+ movl %eax , %esi
283
+
287
284
/* find our allocated stack based on the generated id */
288
- andl 0x0000FFFF , %ebx
289
- movl %ebx , %esi
290
- movl (ap_cpu_init_stacks - apic_ap_start)(%ebp , %ebx , 4 ), %esp
291
-
285
+ movl (ap_cpu_init_stacks - apic_ap_start)(%ebp , %eax , 4 ), %esp
286
+
292
287
/* check if we support NX and enable it if we do */
293
288
movl $0x80000001 , %eax
294
289
cpuid
@@ -319,8 +314,8 @@ apic_ap_start32:
319
314
lgdt (ap_cpu_gdtr_initial2 - apic_ap_start + 0xc0008000 )
320
315
321
316
/* jump above 3GB into our identity mapped area now */
322
- ljmp $8 , $(1f - apic_ap_start + 0xc0008000 )
323
- 1 :
317
+ ljmp $8 , $(apic_ap_start32_2 - apic_ap_start + 0xc0008000 )
318
+ apic_ap_start32_2 :
324
319
/* flush the TLB */
325
320
movl %cr3 , %eax
326
321
movl %eax , %cr3
@@ -338,13 +333,20 @@ apic_ap_start32:
338
333
movl %eax , %cr0
339
334
movl (ap_cpu_init_cr4 - apic_ap_start)(%ebp ), %eax
340
335
movl %eax , %cr4
341
-
336
+
337
+ /* push the Processor pointer this CPU is going to use */
338
+ movl (ap_cpu_init_processor_info_array - apic_ap_start)(%ebp ), %eax
339
+ addl $0xc0000000 , %eax
340
+ movl 0 (%eax , %esi , 4 ), %eax
341
+ push %eax
342
+
343
+ /* push the cpu id, 0 representing the bsp and call into c++ */
344
+ incl %esi
345
+ push %esi
346
+
342
347
xor %ebp , %ebp
343
348
cld
344
349
345
- /* push the arbitrary cpu id, 0 representing the bsp and call into c++ */
346
- inc %esi
347
- push %esi
348
350
/* We are in identity mapped P0x8000 and the BSP will unload this code
349
351
once all APs are initialized, so call init_ap but return to our
350
352
infinite loop */
@@ -356,7 +358,7 @@ apic_ap_start32:
356
358
apic_ap_start_size:
357
359
.2byte end_apic_ap_start - apic_ap_start
358
360
ap_cpu_id:
359
- .2byte 0x0
361
+ .4byte 0x0
360
362
ap_cpu_gdt:
361
363
/* null */
362
364
.8byte 0x0
@@ -388,6 +390,9 @@ ap_cpu_init_cr3:
388
390
.global ap_cpu_init_cr4
389
391
ap_cpu_init_cr4:
390
392
.4byte 0x0 /* will be set at runtime */
393
+ .global ap_cpu_init_processor_info_array
394
+ ap_cpu_init_processor_info_array:
395
+ .4byte 0x0 /* will be set at runtime */
391
396
.global ap_cpu_init_stacks
392
397
ap_cpu_init_stacks:
393
398
/* array of allocated stack pointers */
0 commit comments