From: "Emilio G. Cota" <cota@braap.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/5] tcg: Split CONFIG_ATOMIC128
Date: Sat, 18 Aug 2018 16:36:19 -0400 [thread overview]
Message-ID: <20180818203619.GA13678@flamenco> (raw)
In-Reply-To: <20180816025452.21358-2-richard.henderson@linaro.org>
On Wed, Aug 15, 2018 at 19:54:48 -0700, Richard Henderson wrote:
> GCC7+ will no longer advertise support for 16-byte __atomic operations
> if only cmpxchg is supported, as for x86_64. Fortunately, x86_64 still
> has support for __sync_compare_and_swap_16 and we can make use of that.
> AArch64 does not have, nor ever has had such support, so open-code it.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
I just looked through patchew's mingw error messages. Fixes below.
> diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h
> index d751bcba48..a056b7b408 100644
> --- a/accel/tcg/atomic_template.h
> +++ b/accel/tcg/atomic_template.h
> @@ -100,19 +100,24 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
> DATA_TYPE ret;
>
> ATOMIC_TRACE_RMW;
> - ret = atomic_cmpxchg__nocheck(haddr, cmpv, newv);
> +#if DATA_SIZE == 16
> + ret = atomic16_cmpxchg(haddr, cmpv, newv);
> +#else
> + ret = atomic_cmpxchg(haddr, cmpv, newv);
Keep the __nocheck here.
(snip)
> +#if DATA_SIZE == 16
> + ret = atomic16_cmpxchg(haddr, BSWAP(cmpv), BSWAP(newv));
> +#else
> ret = atomic_cmpxchg__nocheck(haddr, BSWAP(cmpv), BSWAP(newv));
(As done here.)
(snip)
> diff --git a/include/qemu/atomic128.h b/include/qemu/atomic128.h
> new file mode 100644
> index 0000000000..2613ebd352
> --- /dev/null
> +++ b/include/qemu/atomic128.h
(snip)
> +#elif !defined(CONFIG_USER_ONLY)
> +# ifdef __aarch64__
> +/* We can do better than cmpxchg for AArch64. */
> +static inline Int128 atomic16_read(Int128 *ptr)
> +{
> + uint64_t l, h;
> + uint32_t tmp;
> +
> + /* The load must be paired with the store to guarantee not tearing. */
> + asm("0: ldxp %[l], %[h], %[mem]\n\t"
> + "stxp %w[tmp], %[l], %[h], %[mem]\n\t"
> + "cbz %w[tmp], 0b"
> + : [mem] "+m"(*ptr), [tmp] "=r"(tmp), [l] "=r"(l), [h] "=r"(h));
> +
> + return int128_make128(l, h);
> +}
> +
> +static inline void atomic16_set(Int128 *ptr, Int128 val)
> +{
> + uint64_t l = val, h = val >> 64, t1, t2;
> +
> + /* Load into temporaries to acquire the exclusive access lock. */
> + asm("0: ldxp %[t1], %[t2], %[mem]\n\t"
> + "stxp %w[t1], %[l], %[h], %[mem]\n\t"
> + "cbz %w[t1], 0b"
> + : [mem] "+m"(*ptr), [t1] "=&r"(t1), [t2] "=&r"(t2)
> + : [l] "r"(l), [h] "r"(h));
> +}
> +
> +# define HAVE_ATOMIC128 1
> +# elif HAVE_CMPXCHG128
# elif defined(HAVE_CMPXCHG128) && HAVE_CMPXCHG128
or similar.
Thanks,
Emilio
next prev parent reply other threads:[~2018-08-18 20:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-16 2:54 [Qemu-devel] [PATCH 0/5] tcg: Reorg 128-bit atomic operations Richard Henderson
2018-08-16 2:54 ` [Qemu-devel] [PATCH 1/5] tcg: Split CONFIG_ATOMIC128 Richard Henderson
2018-08-17 16:42 ` Emilio G. Cota
2018-08-20 19:26 ` Richard Henderson
2018-08-18 20:36 ` Emilio G. Cota [this message]
2018-08-16 2:54 ` [Qemu-devel] [PATCH 2/5] target/i386: Convert to HAVE_CMPXCHG128 Richard Henderson
2018-08-17 16:44 ` Emilio G. Cota
2018-08-16 2:54 ` [Qemu-devel] [PATCH 3/5] target/s390x: Convert to HAVE_CMPXCHG128 and HAVE_ATOMIC128 Richard Henderson
2018-08-17 17:03 ` Emilio G. Cota
2018-08-20 20:34 ` Richard Henderson
2018-08-16 2:54 ` [Qemu-devel] [PATCH 4/5] target/arm: Convert to HAVE_CMPXCHG128 Richard Henderson
2018-08-17 17:10 ` Emilio G. Cota
2018-08-16 2:54 ` [Qemu-devel] [PATCH 5/5] target/ppc: Convert to HAVE_CMPXCHG128 and HAVE_ATOMIC128 Richard Henderson
2018-08-17 17:20 ` Emilio G. Cota
2018-08-17 5:12 ` [Qemu-devel] [PATCH 0/5] tcg: Reorg 128-bit atomic operations no-reply
2018-08-17 5:17 ` no-reply
2018-08-18 12:51 ` no-reply
2018-08-18 12:58 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180818203619.GA13678@flamenco \
--to=cota@braap.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.