clone: implement CLONE_SETTLS

Set the TLS pointer when `CLONE_SETTLS` is set in `sys_clone`.
This commit is contained in:
Matthew Leach
2025-12-21 19:48:55 +00:00
committed by Ashwin Naren
parent 12076c7ad2
commit 3273d6451e

View File

@@ -46,7 +46,7 @@ pub async fn sys_clone(
newsp: UA,
_arent_tidptr: UA,
_child_tidptr: UA,
_tls: usize,
tls: usize,
) -> Result<usize> {
let flags = CloneFlags::from_bits_truncate(flags);
@@ -58,6 +58,11 @@ pub async fn sys_clone(
// TODO: Make this arch indepdenant. The child returns '0' on clone.
user_ctx.x[0] = 0;
if flags.contains(CloneFlags::CLONE_SETTLS) {
// TODO: Make this arch indepdenant.
user_ctx.tpid_el0 = tls as _;
}
let (tg, tid) = if flags.contains(CloneFlags::CLONE_THREAD) {
if !flags.contains(CloneFlags::CLONE_SIGHAND & CloneFlags::CLONE_VM) {
// CLONE_THREAD requires both CLONE_SIGHAND and CLONE_VM to be