message: Partial aarch64 implementation of relibc internal functions
diff: @@ -14,8 +14,17 @@ pub unsafe fn deactivate_tcb(open_via_dup: usize) -> Result<()> {
  }
  pub fn copy_env_regs(cur_pid_fd: usize, new_pid_fd: usize) -> Result<()> {
  - //TODO: aarch64
  - Err(Error::new(ENOSYS))
  + // Copy environment registers.
  + {
  + let cur_env_regs_fd = FdGuard::new(syscall::dup(cur_pid_fd, b"regs/env")?);
  + let new_env_regs_fd = FdGuard::new(syscall::dup(new_pid_fd, b"regs/env")?);
  +
  + let mut env_regs = syscall::EnvRegisters::default();
  + let _ = syscall::read(*cur_env_regs_fd, &mut env_regs)?;
  + let _ = syscall::write(*new_env_regs_fd, &env_regs)?;
  + }
  +
  + Ok(())
  }
  #[no_mangle]
  @@ -29,13 +38,29 @@ unsafe extern "C" fn __relibc_internal_fork_hook(cur_filetable_fd: usize, new_pi
  let _ = syscall::close(new_pid_fd);
  }
  -//TODO: aarch64
  core::arch::global_asm!("
  .p2align 6
  .globl __relibc_internal_fork_wrapper
  .type __relibc_internal_fork_wrapper, @function
  __relibc_internal_fork_wrapper:
  - b __relibc_internal_fork_wrapper
  + str x19, [sp, #-8]!
  + str x20, [sp, #-8]!
  + str x21, [sp, #-8]!
  + str x22, [sp, #-8]!
  + str x23, [sp, #-8]!
  + str x24, [sp, #-8]!
  + str x25, [sp, #-8]!
  + str x26, [sp, #-8]!
  + str x27, [sp, #-8]!
  + str x28, [sp, #-8]!
  + str x29, [sp, #-8]!
  + str x30, [sp, #-8]!
  +
  + //TODO: store floating point regs
  +
  + mov x0, sp
  + bl __relibc_internal_fork_impl
  + b 2f
  .size __relibc_internal_fork_wrapper, . - __relibc_internal_fork_wrapper
  @@ -43,7 +68,29 @@ __relibc_internal_fork_wrapper:
  .globl __relibc_internal_fork_ret
  .type __relibc_internal_fork_ret, @function
  __relibc_internal_fork_ret:
  - b __relibc_internal_fork_ret
  + ldr x0, [sp]
  + ldr x1, [sp], #8
  + bl __relibc_internal_fork_hook
  +
  + //TODO: load floating point regs
  +
  + ldr x0, #0
  +
  + .p2align 4
  +2:
  + ldr x30, [sp], #8
  + ldr x29, [sp], #8
  + ldr x28, [sp], #8
  + ldr x27, [sp], #8
  + ldr x26, [sp], #8
  + ldr x25, [sp], #8
  + ldr x24, [sp], #8
  + ldr x23, [sp], #8
  + ldr x22, [sp], #8
  + ldr x21, [sp], #8
  + ldr x20, [sp], #8
  + ldr x19, [sp], #8
  + ret
  .size __relibc_internal_fork_ret, . - __relibc_internal_fork_ret"
  );
  