rivosinc / salus

Risc-V hypervisor for TEE development
92 stars 25 forks source link

Map Salus stack in a fixed VA address. #290

Closed glg-rv closed 1 year ago

glg-rv commented 1 year ago

Small patches, profound changes. Fixes #240

This PR maps salus stack in a VA space. Initialization happens now in two stages.

The first stage (init) is when everything (including stack) is mapped in a contiguous physical mapping in the VA. The second stage (launch) is called once the page table and the va-mapped stack has been setup.

Ideally, we whould like to push as much as possible into the second stage. But this is future work and requires more consideration.

glg-rv commented 1 year ago

Relatively major update. Originally I thought of this patch as something that wouldn't change smp.rs fundamentally in order to focus on the stack mapping size. Since the issues that this created came up in the review, decided to make this PR a bit more complex.

This new version of the PR forces all CPUs to have the same stack size. This makes the layout fixed and also simplifies the code.

PerCpu data doesn't live in the stack anymore. This slightly changes the AP bootstrap code because SP and TP are not the same anymore. As an advantage, we do not allocate an extra stack just for the bootstrap CPU PerCpu.