I'm having trouble finding information on how to configure the TLS for a new thread that should have a different vspace than the parent. This is necessary because the __sel4_ipc_buffer is stored in TLS, and so any IPC calls won't work unless it is set up. My understanding of the process is this:
Map a frame into the parent's vspace at some temporary address (e.x. PARENT_VADDR)
Call sel4runtime_write_tls_image(PARENT_VADDR), which copies the TLS image into this page
Call sel4runtime_set_tls_variable using the TLS base returned from the previous step, and pass the IPC buffer address
Remap the frame into the child thread vspace at some final address (e.x. CHILD_VADDR)
Call seL4_TCB_SetTLSBase using the child thread's TCB and the TLS base (with some offset of CHILD_VADDR - PARENT_VADDR added?)
The issue is step 2 sets some other pointers (see the lookup->tls_base assignment at the end of the copy_tls_data function). The value assigned depends on the the address passed to sel4runtime_write_tls_image - in this case PARENT_VADDR. This address has no meaning in the child's vspace and will probably point to some unmapped page, and will fault as soon as __sel4_ipc_buffer is accessed from the child thread.
I can manually write to the tls_base variable within my TLS page to point to where the page will be mapped in the child vspace, but this feels prone to breaking.
As an aside, I was looking through the include/sel4runtime.h header and the sel4runtime_get_tp_offset function appears to be unimplemented. I don't see a definition for it in this repo (or anywhere on Github). Trying to call it raises an undefined reference linker error, but the other functions I've spot-checked in that header link fine.
I'm having trouble finding information on how to configure the TLS for a new thread that should have a different vspace than the parent. This is necessary because the
__sel4_ipc_buffer
is stored in TLS, and so any IPC calls won't work unless it is set up. My understanding of the process is this:PARENT_VADDR
)sel4runtime_write_tls_image(PARENT_VADDR)
, which copies the TLS image into this pagesel4runtime_set_tls_variable
using the TLS base returned from the previous step, and pass the IPC buffer addressCHILD_VADDR
)seL4_TCB_SetTLSBase
using the child thread's TCB and the TLS base (with some offset ofCHILD_VADDR
-PARENT_VADDR
added?)The issue is step 2 sets some other pointers (see the
lookup->tls_base
assignment at the end of thecopy_tls_data
function). The value assigned depends on the the address passed tosel4runtime_write_tls_image
- in this case PARENT_VADDR. This address has no meaning in the child's vspace and will probably point to some unmapped page, and will fault as soon as__sel4_ipc_buffer
is accessed from the child thread.I can manually write to the
tls_base
variable within my TLS page to point to where the page will be mapped in the child vspace, but this feels prone to breaking.As an aside, I was looking through the
include/sel4runtime.h
header and thesel4runtime_get_tp_offset
function appears to be unimplemented. I don't see a definition for it in this repo (or anywhere on Github). Trying to call it raises an undefined reference linker error, but the other functions I've spot-checked in that header link fine.Thank you, any help is appreciated!