Skip to content

Commit

Permalink
Merge branch 'master' into iX-32bit-vnni-binutils-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
khuey authored Dec 16, 2024
2 parents 901536d + 9e2ed1f commit 7c25dc9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
20 changes: 10 additions & 10 deletions ext/drmgr/drmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2694,7 +2694,7 @@ static bool
drmgr_unreserve_tls_cls_field(bool *taken, int idx)
{
bool res = false;
if (idx < 0 || idx > MAX_NUM_TLS)
if (idx < 0 || idx >= MAX_NUM_TLS)
return false;
dr_mutex_lock(tls_lock);
if (taken[idx]) {
Expand Down Expand Up @@ -2726,7 +2726,7 @@ drmgr_get_tls_field(void *drcontext, int idx)
{
tls_array_t *tls = (tls_array_t *)dr_get_tls_field(drcontext);
/* no need to check for tls_taken since would return NULL anyway (i#484) */
if (idx < 0 || idx > MAX_NUM_TLS || tls == NULL)
if (idx < 0 || idx >= MAX_NUM_TLS || tls == NULL)
return NULL;
return tls->tls[idx];
}
Expand All @@ -2736,7 +2736,7 @@ bool
drmgr_set_tls_field(void *drcontext, int idx, void *value)
{
tls_array_t *tls = (tls_array_t *)dr_get_tls_field(drcontext);
if (idx < 0 || idx > MAX_NUM_TLS || tls == NULL)
if (idx < 0 || idx >= MAX_NUM_TLS || tls == NULL)
return false;
/* going DR's traditional route of efficiency over safety: making this
* a debug-only check to avoid cost in release build
Expand All @@ -2752,7 +2752,7 @@ drmgr_insert_read_tls_field(void *drcontext, int idx, instrlist_t *ilist, instr_
reg_id_t reg)
{
tls_array_t *tls = (tls_array_t *)dr_get_tls_field(drcontext);
if (idx < 0 || idx > MAX_NUM_TLS || !tls_taken[idx] || tls == NULL)
if (idx < 0 || idx >= MAX_NUM_TLS || !tls_taken[idx] || tls == NULL)
return false;
if (!reg_is_gpr(reg) || !reg_is_pointer_sized(reg))
return false;
Expand All @@ -2771,7 +2771,7 @@ drmgr_insert_write_tls_field(void *drcontext, int idx, instrlist_t *ilist, instr
reg_id_t reg, reg_id_t scratch)
{
tls_array_t *tls = (tls_array_t *)dr_get_tls_field(drcontext);
if (idx < 0 || idx > MAX_NUM_TLS || !tls_taken[idx] || tls == NULL)
if (idx < 0 || idx >= MAX_NUM_TLS || !tls_taken[idx] || tls == NULL)
return false;
if (!reg_is_gpr(reg) || !reg_is_pointer_sized(reg) || !reg_is_gpr(scratch) ||
!reg_is_pointer_sized(scratch))
Expand Down Expand Up @@ -3073,7 +3073,7 @@ void *
drmgr_get_cls_field(void *drcontext, int idx)
{
tls_array_t *tls = (tls_array_t *)dr_get_tls_field(drcontext);
if (idx < 0 || idx > MAX_NUM_TLS || !cls_taken[idx] || tls == NULL)
if (idx < 0 || idx >= MAX_NUM_TLS || !cls_taken[idx] || tls == NULL)
return NULL;
return tls->cls[idx];
}
Expand All @@ -3083,7 +3083,7 @@ bool
drmgr_set_cls_field(void *drcontext, int idx, void *value)
{
tls_array_t *tls = (tls_array_t *)dr_get_tls_field(drcontext);
if (idx < 0 || idx > MAX_NUM_TLS || !cls_taken[idx] || tls == NULL)
if (idx < 0 || idx >= MAX_NUM_TLS || !cls_taken[idx] || tls == NULL)
return false;
tls->cls[idx] = value;
return true;
Expand All @@ -3094,7 +3094,7 @@ void *
drmgr_get_parent_cls_field(void *drcontext, int idx)
{
tls_array_t *tls = (tls_array_t *)dr_get_tls_field(drcontext);
if (idx < 0 || idx > MAX_NUM_TLS || !cls_taken[idx] || tls == NULL)
if (idx < 0 || idx >= MAX_NUM_TLS || !cls_taken[idx] || tls == NULL)
return NULL;
if (tls->prev != NULL)
return tls->prev->cls[idx];
Expand All @@ -3107,7 +3107,7 @@ drmgr_insert_read_cls_field(void *drcontext, int idx, instrlist_t *ilist, instr_
reg_id_t reg)
{
tls_array_t *tls = (tls_array_t *)dr_get_tls_field(drcontext);
if (idx < 0 || idx > MAX_NUM_TLS || !cls_taken[idx] || tls == NULL)
if (idx < 0 || idx >= MAX_NUM_TLS || !cls_taken[idx] || tls == NULL)
return false;
if (!reg_is_gpr(reg) || !reg_is_pointer_sized(reg))
return false;
Expand All @@ -3126,7 +3126,7 @@ drmgr_insert_write_cls_field(void *drcontext, int idx, instrlist_t *ilist, instr
reg_id_t reg, reg_id_t scratch)
{
tls_array_t *tls = (tls_array_t *)dr_get_tls_field(drcontext);
if (idx < 0 || idx > MAX_NUM_TLS || !cls_taken[idx] || tls == NULL)
if (idx < 0 || idx >= MAX_NUM_TLS || !cls_taken[idx] || tls == NULL)
return false;
if (!reg_is_gpr(reg) || !reg_is_pointer_sized(reg) || !reg_is_gpr(scratch) ||
!reg_is_pointer_sized(scratch))
Expand Down
28 changes: 25 additions & 3 deletions suite/tests/linux/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,32 @@ make_clone3_syscall(void *clone_args, ulong clone_args_size, void (*fcn)(void))
[clone_args_size] "m"(clone_args_size), [fcn] "m"(fcn)
: "x0", "x1", "x2", "x8", "memory");
#elif defined(ARM)
/* XXX: Add asm wrapper for ARM.
* Currently we do not run this test on ARM, so this missing support doesn't
* cause any test failure.
/* The system call number has to go in R7, but R7 is also the frame
* pointer, which means that we are not allowed to include R7 in the
* list of clobbered registers. So we clobber R8 and R9, instead,
* with R7 being saved and restored.
* We use a local variable for sys_clone3 as the intermediate value
* is out of range for ARMv5.
*/
long sys_clone3 = CLONE3_SYSCALL_NUM;
asm volatile(".arch armv7-a\n\t"
".syntax unified\n\t"
"ldr r8, %[sys_clone3]\n\t"
"ldr r0, %[clone_args]\n\t"
"ldr r1, %[clone_args_size]\n\t"
"ldr r2, %[fcn]\n\t"
"mov r9, r7\n\t"
"mov r7, r8\n\t"
"svc #0\n\t"
"mov r7, r9\n\t"
"cbnz r0, 1f\n\t"
"blx r2\n\t"
"1:\n\t"
"str r0, %[result]\n\t"
: [result] "=m"(result)
: [sys_clone3] "m"(sys_clone3), [clone_args] "m"(clone_args),
[clone_args_size] "m"(clone_args_size), [fcn] "m"(fcn)
: "r0", "r1", "r2", "r8", "r9", "memory");
#else
# error Unsupported architecture
#endif
Expand Down

0 comments on commit 7c25dc9

Please sign in to comment.