twizzler-operating-system / twizzler

The Twizzler Operating System
BSD 3-Clause "New" or "Revised" License
62 stars 13 forks source link

Add support for starting cores with PSCI #169

Closed PandaZ3D closed 5 months ago

PandaZ3D commented 5 months ago

In this PR we add basic support for SMP to the ARM version of the kernel. It uses PSCI to boot up cores. PSCI is the power management interface commonly supported by ARM devices. The kernel gets to the same place as before (running the startup terminal from init). There are still other stuff missing and issues related to synchronization (e.g. locks) which we plan to address in future PR's.

Two bugs surfaced while implementing this which required changes to the generic kernel code. One is that when creating the idle thread, before setting the current thread, the kernel tries to acquire a lock to allocate some memory. The issues is that all cores race to acquire the mutex which calls scheduler to run other work if they need to wait which then crashes since no current thread is defined. So we have the mutex avoid calling the scheduler if no current thread is defined. The second problem was that init_secondary was called in main (from the boot core) which caused issues with ARM initialization code. I tried to remove it, but it seemed to cause the x86_64 code to not boot. The workaround for now was to conditionally compile that in for x86_64 code.

Summary