Skip to content

Commit

Permalink
Add check for XSP in dr_restore_reg and dr_save_reg on AArch64 (#4311)
Browse files Browse the repository at this point in the history
Adds early checks in dr_restore_reg() and dr_save_reg() to ensure that XSP is not used as a target on AArch64.
  • Loading branch information
yury-khrustalev authored Jun 3, 2020
1 parent 4964f9e commit 516ee2c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/lib/instrument.c
Original file line number Diff line number Diff line change
Expand Up @@ -5803,6 +5803,10 @@ dr_save_reg(void *drcontext, instrlist_t *ilist, instr_t *where, reg_id_t reg,

CLIENT_ASSERT(reg_is_pointer_sized(reg), "dr_save_reg requires pointer-sized gpr");

# ifdef AARCH64
CLIENT_ASSERT(reg != DR_REG_XSP, "dr_save_reg: store from XSP is not supported");
# endif

if (slot <= SPILL_SLOT_TLS_MAX) {
ushort offs = os_tls_offset(SPILL_SLOT_TLS_OFFS[slot]);
MINSERT(ilist, where,
Expand Down Expand Up @@ -5845,6 +5849,10 @@ dr_restore_reg(void *drcontext, instrlist_t *ilist, instr_t *where, reg_id_t reg
CLIENT_ASSERT(reg_is_pointer_sized(reg),
"dr_restore_reg requires a pointer-sized gpr");

# ifdef AARCH64
CLIENT_ASSERT(reg != DR_REG_XSP, "dr_restore_reg: load into XSP is not supported");
# endif

if (slot <= SPILL_SLOT_TLS_MAX) {
ushort offs = os_tls_offset(SPILL_SLOT_TLS_OFFS[slot]);
MINSERT(ilist, where,
Expand Down

0 comments on commit 516ee2c

Please sign in to comment.