Skip to content

Commit

Permalink
i#1569 AArch64: Implement restarting interrupted system calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
egrimley-arm committed Jun 2, 2016
1 parent 6f02d27 commit 14a1489
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions core/arch/arch_exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -1741,9 +1741,15 @@ enum {
#endif

/* Not under defines so we can have code that is less cluttered */
#ifdef AARCH64
INT_LENGTH = 4,
SYSCALL_LENGTH = 4,
SYSENTER_LENGTH = 4,
#else
INT_LENGTH = 2,
SYSCALL_LENGTH = 2,
SYSENTER_LENGTH = 2,
#endif
};

#define REL32_REACHABLE_OFFS(offs) ((offs) <= INT_MAX && (offs) >= INT_MIN)
Expand Down
6 changes: 4 additions & 2 deletions core/arch/emit_utils_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -4577,15 +4577,17 @@ emit_do_syscall_common(dcontext_t *dcontext, generated_code_t *code,
/* We will call this from handle_system_call, so need prefix on AArch64. */
APP(&ilist, instr_create_restore_from_tls(dcontext, ENTRY_PC_REG,
ENTRY_PC_SPILL_SLOT));
/* XXX: should have a proper patch list entry */
*syscall_offs += AARCH64_INSTR_SIZE;
#endif

#ifdef ARM
#if defined(ARM) || defined(AARCH64)
/* We have to save r0 in case the syscall is interrupted. We can't
* easily do this from dispatch b/c fcache_enter clobbers some TLS slots.
*/
APP(&ilist, instr_create_save_to_tls(dcontext, DR_REG_R0, TLS_REG0_SLOT));
/* XXX: should have a proper patch list entry */
*syscall_offs += THUMB_LONG_INSTR_SIZE;
*syscall_offs += IF_X64_ELSE(AARCH64_INSTR_SIZE, THUMB_LONG_INSTR_SIZE);
#endif

/* system call itself -- using same method we've observed OS using */
Expand Down
2 changes: 1 addition & 1 deletion core/unix/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3237,7 +3237,7 @@ adjust_syscall_for_restart(dcontext_t *dcontext, thread_sig_info_t *info, int si
}
#ifdef X86
sc->SC_SYSNUM_REG = sysnum;
#elif defined(ARM)
#elif defined(ARM) || defined(AARCH64)
/* We just need to restore the app's arg to the syscall into r0, which
* the kernel clobbered with -EINTR. We stored r0 into TLS.
*/
Expand Down

0 comments on commit 14a1489

Please sign in to comment.