Initialize SPRG0 before its first possible use

At early boot, PCPU_GET(), that obtains a pointer from SPRG0, was being
used with SPRG0 not yet initialized. If it pointed to an invalid
address, the machine would hang.

Approved by:	re(gjb), jhibbits(mentor)
This commit is contained in:
Leandro Lupori 2018-10-15 16:43:07 +00:00
parent c32a9d66fb
commit 461298ffa6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=339360

View File

@ -383,12 +383,12 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp,
if (platform_smp_get_bsp(&bsp) != 0)
bsp.cr_cpuid = 0;
pc = &__pcpu[bsp.cr_cpuid];
__asm __volatile("mtsprg 0, %0" :: "r"(pc));
pcpu_init(pc, bsp.cr_cpuid, sizeof(struct pcpu));
pc->pc_curthread = &thread0;
thread0.td_oncpu = bsp.cr_cpuid;
pc->pc_cpuid = bsp.cr_cpuid;
pc->pc_hwref = bsp.cr_hwref;
__asm __volatile("mtsprg 0, %0" :: "r"(pc));
/*
* Init KDB