The early SP read-only code is loaded inside non pageable memory before the thread is started. Free this memory so we can use it for something else.
After the initial investigation I found two possible approaches to the task:
- Use the OP-TEE pager and put the SP code into paged memory.
- Implement a reclaim mechanism similar to TF-A BL31 init code reclaiming.
I asked Jens from Linaro about this, it turns out option 2 is not ideal in this case, and they're already using option 1 for the StMM prototype. He also suggested a 3rd option, to map the embedded SP binary directly to user mode, but that requires deeper understanding and modifications to OP-TEE memory management.
Considering these, I'll implement option 1 for this task, and maybe later adopt option 3 if there is progress in this direction from Linaro.