genodelabs / genode

Genode OS Framework
https://genode.org/
Other
1.04k stars 248 forks source link

hw: handle cap-slab exhaustion during `Cpu_thread::start` #5256

Open nfeske opened 2 weeks ago

nfeske commented 2 weeks ago

On the hw kernel, the Cpu_thread::start operation wraps up the initialization of the Core::Platform_thread. As part of this procedure, there happens to be a cap slot allocation that is needed to send the initial IPC from core's starting thread to the newly created thread. Should the PD's capability slab be exhausted at this point, this allocation fails. This condition, however, cannot be reflected to the client because the Cpu_thread::start RPC has no result. At the interface level, such allocation issues should be reflected during Cpu_session::create_thread.

To cleanly solve this issue, we should move the final steps of the thread initialization from the start operation to the point of the Platform_thread construction. Currently this is not easily possible because the Platform_thread lacks the Platform_pd at construction time.

As an interim solution, we can detect the corner case by evaluating the PD's remaining cap-slab capacity ahead of the start call, and upgrading the cap slab opportunistically.

nfeske commented 2 weeks ago

Commit https://github.com/genodelabs/genode/commit/4b9a307b1504bc3ade51579fd0a58fefc583a3b2 implements the interim solution.