From 6591cf699d533d7c7e220566199c2a5f2c9efb25 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 24 Aug 2022 19:24:26 -0600 Subject: [PATCH] Set aarch64 tcb --- src/ld_so/tcb.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ld_so/tcb.rs b/src/ld_so/tcb.rs index 0e281c76f6..404c84784b 100644 --- a/src/ld_so/tcb.rs +++ b/src/ld_so/tcb.rs @@ -248,7 +248,20 @@ impl Tcb { /// OS and architecture specific code to activate TLS - Redox aarch64 #[cfg(all(target_os = "redox", target_arch = "aarch64"))] unsafe fn os_arch_activate(tp: usize) { - //TODO: aarch64 + let mut env = syscall::EnvRegisters::default(); + + let file = syscall::open("thisproc:current/regs/env", syscall::O_CLOEXEC | syscall::O_RDWR) + .expect_notls("failed to open handle for process registers"); + + let _ = syscall::read(file, &mut env) + .expect_notls("failed to read thread pointer"); + + env.tpidr_el0 = tp; + + let _ = syscall::write(file, &env) + .expect_notls("failed to write thread pointer"); + + let _ = syscall::close(file); } /// OS and architecture specific code to activate TLS - Redox x86