Skip to content

Commit 4916c3c

Browse files
committed
Address Omair's comments
1 parent 4838ed0 commit 4916c3c

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

lldb/docs/use/aarch64-linux.md

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -256,27 +256,37 @@ extensions like GCS.
256256

257257
### Expression Evaluation
258258

259-
To execute an expression, LLDB must push the return address of the expression
260-
wrapper (usually the entry point of the program) to the Guarded Control Stack.
261-
It does this by decrementing `gcspr_el0` and writing to the location that
262-
`gcspr_el0` then points to (instead of using the GCS push instructions).
263-
264-
After an expression finishes, LLDB will restore the contents of all 3 registers,
265-
apart from the enable bit of `gcs_features_enabled`.
266-
267-
This is because there are limits on how often and from where you can set this
268-
value. We cannot enable GCS from ptrace at all and it is expected that a process
259+
To execute an expression when GCS is enabled, LLDB must push the return
260+
address of the expression wrapper (usually the entry point of the program)
261+
to the Guarded Control Stack. It does this by decrementing `gcspr_el0` and
262+
writing to the location now pointed to by `gcspr_el0` (instead of using the
263+
GCS push instructions).
264+
265+
After an expression finishes, LLDB will restore the contents of all 3
266+
GCS registers, apart from the enable bit of `gcs_features_enabled`. This is
267+
because there are limits on how often and from where you can set this
268+
bit.
269+
270+
We cannot enable GCS from ptrace at all and it is expected that a process
269271
that has enabled GCS then disabled it, will not enable it again. The simplest
270-
choice was to not restore the enable bit at all. It's up to the user or
271-
program to manage that value.
272+
choice was to not restore the enable bit at all. It is up to the user or
273+
program to manage that bit.
272274

273-
The return address that was pushed onto the Guarded Control Stack will be left
275+
The return address that LLDB pushed onto the Guarded Control Stack will be left
274276
in place. As will any values that were pushed to the stack by functions run
275277
during the expresison.
276278

277279
When the process resumes, `gcspr_el0` will be pointing to the original entry
278-
on the stack. So the other values will have no effect and likely be overwritten
279-
by future function calls.
280+
on the guarded control stack. So the other values will have no effect and
281+
likely be overwritten by future function calls.
280282

281283
LLDB does not track and restore changes to general memory during expressions,
282284
so not restoring the GCS contents fits with the current behaviour.
285+
286+
Note that if GCS is disabled and an expression enables it, LLDB will not
287+
be able to setup the return address and it is up to that expression to do that
288+
if it wants to return to LLDB correctly.
289+
290+
If it does not do this, the expression will fail and although most process
291+
state will be restored, GCS will be left enabled. Which means that the program
292+
is very unlikely to be able to progress.

0 commit comments

Comments
 (0)