mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
tcg: Introduce set/clear_helper_retaddr
At present we have a potential error in that helper_retaddr contains data for handle_cpu_signal, but we have not ensured that those stores will be scheduled properly before the operation that may fault. It might be that these races are not in practice observable, due to our use of -fno-strict-aliasing, but better safe than sorry. Adjust all of the setters of helper_retaddr. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
359896dfa4
commit
08b97f7ff2
5 changed files with 57 additions and 37 deletions
|
@ -89,6 +89,26 @@ typedef target_ulong abi_ptr;
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
/* In user-only mode we provide only the _code and _data accessors. */
|
||||
|
||||
#define MEMSUFFIX _data
|
||||
|
|
|
@ -78,9 +78,9 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
|
|||
uintptr_t retaddr)
|
||||
{
|
||||
RES_TYPE ret;
|
||||
helper_retaddr = retaddr;
|
||||
set_helper_retaddr(retaddr);
|
||||
ret = glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(env, ptr);
|
||||
helper_retaddr = 0;
|
||||
clear_helper_retaddr();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -102,9 +102,9 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
|
|||
uintptr_t retaddr)
|
||||
{
|
||||
int ret;
|
||||
helper_retaddr = retaddr;
|
||||
set_helper_retaddr(retaddr);
|
||||
ret = glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(env, ptr);
|
||||
helper_retaddr = 0;
|
||||
clear_helper_retaddr();
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
@ -128,9 +128,9 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
|
|||
RES_TYPE v,
|
||||
uintptr_t retaddr)
|
||||
{
|
||||
helper_retaddr = retaddr;
|
||||
set_helper_retaddr(retaddr);
|
||||
glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(env, ptr, v);
|
||||
helper_retaddr = 0;
|
||||
clear_helper_retaddr();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue