mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-31 06:13:53 -06:00

Move set_helper_retaddr and clear_helper_retaddr to a new header file. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
43 lines
1.1 KiB
C
43 lines
1.1 KiB
C
/*
|
|
* Get user helper pc for memory unwinding.
|
|
* SPDX-License-Identifier: LGPL-2.1-or-later
|
|
*/
|
|
|
|
#ifndef ACCEL_TCG_HELPER_RETADDR_H
|
|
#define ACCEL_TCG_HELPER_RETADDR_H
|
|
|
|
/*
|
|
* For user-only, helpers that use guest to host address translation
|
|
* must protect the actual host memory access by recording 'retaddr'
|
|
* for the signal handler. This is required for a race condition in
|
|
* which another thread unmaps the page between a probe and the
|
|
* actual access.
|
|
*/
|
|
#ifdef CONFIG_USER_ONLY
|
|
extern __thread uintptr_t helper_retaddr;
|
|
|
|
static inline void set_helper_retaddr(uintptr_t ra)
|
|
{
|
|
helper_retaddr = ra;
|
|
/*
|
|
* Ensure that this write is visible to the SIGSEGV handler that
|
|
* may be invoked due to a subsequent invalid memory operation.
|
|
*/
|
|
signal_barrier();
|
|
}
|
|
|
|
static inline void clear_helper_retaddr(void)
|
|
{
|
|
/*
|
|
* Ensure that previous memory operations have succeeded before
|
|
* removing the data visible to the signal handler.
|
|
*/
|
|
signal_barrier();
|
|
helper_retaddr = 0;
|
|
}
|
|
#else
|
|
#define set_helper_retaddr(ra) do { } while (0)
|
|
#define clear_helper_retaddr() do { } while (0)
|
|
#endif
|
|
|
|
#endif /* ACCEL_TCG_HELPER_RETADDR_H */
|