xref: /qemu/accel/tcg/user-retaddr.h (revision 8682ff69)
1 #ifndef ACCEL_TCG_USER_RETADDR_H
2 #define ACCEL_TCG_USER_RETADDR_H
3 
4 #include "qemu/atomic.h"
5 
6 extern __thread uintptr_t helper_retaddr;
7 
8 static inline void set_helper_retaddr(uintptr_t ra)
9 {
10     helper_retaddr = ra;
11     /*
12      * Ensure that this write is visible to the SIGSEGV handler that
13      * may be invoked due to a subsequent invalid memory operation.
14      */
15     signal_barrier();
16 }
17 
18 static inline void clear_helper_retaddr(void)
19 {
20     /*
21      * Ensure that previous memory operations have succeeded before
22      * removing the data visible to the signal handler.
23      */
24     signal_barrier();
25     helper_retaddr = 0;
26 }
27 
28 #endif
29