Skip to contentSkip to conversation

loads-stores.rst: add footnote that clarifies GETPC usage

PATCH Applied Emanuele Giuseppe Esposito 2 participants 2 messages Oct 15, 2020 – Oct 20, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 loads-stores.rst: add footnote that clarifies GETPC usage

Current documentation is not too clear on the GETPC usage. In particular, when used outside the top level helper function it causes unexpected behavior.

---
 docs/devel/loads-stores.rst | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
docs/devel/loads-stores.rst +7 -1
index 9a944ef1af..59c1225391 100644
@@ -93,7 +93,13 @@ guest CPU state in case of a guest CPU exception.  This is passed
 to ``cpu_restore_state()``.  Therefore the value should either be 0,
 to indicate that the guest CPU state is already synchronized, or
 the result of ``GETPC()`` from the top level ``HELPER(foo)``
-function, which is a return address into the generated code.
+function, which is a return address into the generated code [#gpc]_.
+
+.. [#gpc] Note that ``GETPC()`` should be used with great care: calling
+          it in other functions that are *not* the top level
+          ``HELPER(foo)`` will cause unexpected behavior. Instead, the
+          value of ``GETPC()`` should be read from the helper and passed
+          if needed to the functions that the helper calls.
 
 Function names follow the pattern:
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 6 lines · Emanuele Giuseppe Esposito

Current documentation is not too clear on the GETPC usage. In particular, when used outside the top level helper function it causes unexpected behavior.

Applied to target-arm.next, thanks.

-- PMM