DynamoRIO / DynamoRIO/dynamorio

Handle changes in SVE vector length on AArch64

Open
#6,625 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
3.2k
Forks
629
Avg merge
2d 18h
Merged PRs (30d)
30

Description

In the discussion for #6544 @derekbruening and @abhinav92003 raised the issue of applications which change the vector length at runtime. Currently DynamoRIO assumes that the VL doesn't change at run time, but it is possible that applications can do it anyway using the Linux `prctl()` system call.

@derekbruening said:

> Generally, we want to be able to run any program that the hardware supports, not just those that follow software conventions in compilers or ABIs, since there always seem to be real programs that violate those conventions, and there are cases where DR is used to run deliberately violating programs (analyzing malware, etc.). Only when such support is intractable do we reluctantly relax that and assume conventions: such as some rseq corner cases. So if it is practical to support it changing we would want to do that. We should add a handler for the prctl call that at least detects a change and provides a warning or error with a TODO to actually handle it.

The places I think of off the top of my head where changing VL definitely matters are:

1. Scatter/gather expansion. The expanded sequence is an unrolled loop based on the number of elements in the vector. If the vector length changes, so does the number of elements so the expansion won't be valid any more.

2. Machine context switching. We use ldr/str to save and restore the Z and P registers. Changing the vector length will scale the size of the offsets and transfer size for those instructions.

3. drmemtrace/raw2trace. We will need to record any vector length changes in the raw trace so it can be handled in raw2trace and any tools which decode instructions

Contributor guide

Open the contributing guide

Research direction

Start with the discussion in #6544 and the handling of Linux prctl() calls, then trace how SVE vector length is used by scatter/gather expansion, machine context switching, and drmemtrace/raw2trace. Done means runtime vector-length changes are detected and either handled across these paths or explicitly warned about with the documented TODO.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, linux
Domain
backend, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.