[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 03/10] qemu/atomic: Add aligned_{int64,uint64}_t types
From: |
Peter Maydell |
Subject: |
Re: [PATCH v3 03/10] qemu/atomic: Add aligned_{int64,uint64}_t types |
Date: |
Mon, 19 Jul 2021 13:39:30 +0100 |
On Sat, 17 Jul 2021 at 20:24, Richard Henderson
<richard.henderson@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é <f4bug@amsat.org>
> Signed-off-by: Richard Henderson <richard.henderson@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.maydell@linaro.org>
thanks
-- PMM
- [PATCH v3 00/10] Atomic cleanup + clang-12 build fix, Richard Henderson, 2021/07/17
- [PATCH v3 01/10] qemu/atomic: Use macros for CONFIG_ATOMIC64, Richard Henderson, 2021/07/17
- [PATCH v3 03/10] qemu/atomic: Add aligned_{int64,uint64}_t types, Richard Henderson, 2021/07/17
- Re: [PATCH v3 03/10] qemu/atomic: Add aligned_{int64,uint64}_t types,
Peter Maydell <=
- [PATCH v3 04/10] tcg: Rename helper_atomic_*_mmu and provide for user-only, Richard Henderson, 2021/07/17
- [PATCH v3 02/10] qemu/atomic: Remove pre-C11 atomic fallbacks, Richard Henderson, 2021/07/17
- [PATCH v3 06/10] accel/tcg: Fold EXTRA_ARGS into atomic_template.h, Richard Henderson, 2021/07/17
- [PATCH v3 07/10] accel/tcg: Remove ATOMIC_MMU_DECLS, Richard Henderson, 2021/07/17