loads-stores.rst: add footnote that clarifies GETPC usage
authorEmanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
Thu, 15 Oct 2020 09:51:47 +0000 (11:51 +0200)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 20 Oct 2020 15:12:00 +0000 (16:12 +0100)
Current documentation is not too clear on the GETPC usage.
In particular, when used outside the top level helper function
it causes unexpected behavior.

Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
Message-id: 20201015095147.1691-1-e.emanuelegiuseppe@gmail.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
docs/devel/loads-stores.rst

index 9a944ef1af6fc4bdbb114450c87444c8e79c9fd4..59c1225391cebb53077a9c2243d73befd1b8d336 100644 (file)
@@ -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: