Don't jump to VA space until kernel is ready.

This fixes the race when first core sets up the pagetables, while
secondary cores do translating the address of __riscv_boot_ap.

This now allows us to smpboot in QEMU with 8 cores just fine.

Sponsored by:	DARPA, AFRL
This commit is contained in:
Ruslan Bukin 2018-06-13 10:32:21 +00:00
parent 3330a6d984
commit b626c976dc

View File

@ -263,6 +263,21 @@ END(mpentry)
* Called by a core when it is being brought online.
*/
ENTRY(mpentry)
/*
* Calculate the offset to __riscv_boot_ap
* for the current core, cpuid is in a0.
*/
li t1, 4
mulw t1, t1, a0
/* Get the pointer */
la t0, __riscv_boot_ap
add t0, t0, t1
1:
/* Wait the kernel to be ready */
lw t1, 0(t0)
beqz t1, 1b
/* Setup stack pointer */
la t0, secondary_stacks
li t1, (PAGE_SIZE * KSTACK_PAGES)
@ -296,20 +311,6 @@ mpva:
/* Ensure sscratch is zero */
li t0, 0
csrw sscratch, t0
/*
* Calculate the offset to __riscv_boot_ap
* for current core, cpuid in a0.
*/
li t1, 4
mulw t1, t1, a0
/* Get pointer */
la t0, __riscv_boot_ap
add t0, t0, t1
1:
/* Wait the kernel to be ready */
lw t1, 0(t0)
beqz t1, 1b
call init_secondary
END(mpentry)