On Sat, 17 Jul 2021 at 20:24, Richard Henderson <richard.hender...@linaro.org> wrote: > > Use it to avoid some clang-12 -Watomic-alignment errors, > forcing some structures to be aligned and as a pointer when > we have ensured that the address is aligned. > > Reviewed-by: Philippe Mathieu-Daudé <f4...@amsat.org> > Signed-off-by: Richard Henderson <richard.hender...@linaro.org> > --- > accel/tcg/atomic_template.h | 4 ++-- > include/qemu/atomic.h | 14 +++++++++++++- > include/qemu/stats64.h | 2 +- > softmmu/timers-state.h | 2 +- > linux-user/hppa/cpu_loop.c | 2 +- > util/qsp.c | 4 ++-- > 6 files changed, 20 insertions(+), 8 deletions(-)
> diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c > index 3aaaf3337c..82d8183821 100644 > --- a/linux-user/hppa/cpu_loop.c > +++ b/linux-user/hppa/cpu_loop.c > @@ -82,7 +82,7 @@ static abi_ulong hppa_lws(CPUHPPAState *env) > o64 = *(uint64_t *)g2h(cs, old); > n64 = *(uint64_t *)g2h(cs, new); > #ifdef CONFIG_ATOMIC64 > - r64 = qatomic_cmpxchg__nocheck((uint64_t *)g2h(cs, addr), > + r64 = qatomic_cmpxchg__nocheck((aligned_uint64_t *)g2h(cs, > addr), > o64, n64); This cast is OK, but it took me a while to verify that: * we check that 'addr' is 8-aligned further up in this function * we check that guest_base is at least page-aligned in probe_guest_base(), and there's no way to avoid that function getting called if you specify a guest-base value on the command line Is it worth asserting that the value we get back from g2h() really is 8-aligned before casting ? Anyway, Reviewed-by: Peter Maydell <peter.mayd...@linaro.org> thanks -- PMM