From patchwork Wed Oct 3 19:39:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148082 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp63365lji; Wed, 3 Oct 2018 12:47:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV63YCWhMHO7+jo+OtQnOxHcy+SzEHB8Z7Ww6QY0Nu6LHJWXuoCzDdL3doEZ6ALmB3RI/5/Et X-Received: by 2002:aed:2422:: with SMTP id r31-v6mr2698834qtc.128.1538596070208; Wed, 03 Oct 2018 12:47:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538596070; cv=none; d=google.com; s=arc-20160816; b=eFtLr1SXDMGJ0oQ5yZgBIBDyVg/aqO3Q+Eq/ffvJSOxluVX5wBGMNlqb5Z0OvlMOEP Y8XR3iBbz80hcADigDsaLc7DaPrgeI3+yjmDGAC+coNuxsAqo0NDNTCSn9fqbTFskoV/ /KAo22N8Bhm/ARr66qc8XXWGJu3SApJlG6TetODVrWLYcR5Ww/iiQO+uvNcHWuLVnfzt C1hTTi9K4cZ0KCPzoM6Cq46+wNGDVQmJ/NDxEb82Uc5HyKlVWutq/IwYRSpx1HugsbWF LlILAJXtNXLPEmwuo1s/TWgWM8JEqdD1f3pnl880iL5OkoNRMzArNDAGW6FQqQJJzts5 1r2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=eVBZVdR2wlJYrDZOh2ss3tefv/SjOKwhbvvyOD1IcWI=; b=Nz4YVbSWWBq403wu7TBBZ+Ns1py/W2YRVZoAZONYBnkitABM59VMTjM8ruaaesAT47 7rQcbepVKkW0D9SqGS5rGIwy8EHEHk608Re6ABoufL+o5p4sT9wZieJQbPVLzLvT55FX BmGItVbEJJLPeagxCIVGQ4O7OzKm1ricryhk3J4ZqjXX6ITHsvKI1EW8rKczdqDhyLTI JpuaZ7JluKdJfBvbypgj+zgpv4949vCn2oWZj2beBBz1oyHfLvO3C+h5Uh9vh54MLVKC 8KIcsGXE1P9UwsBYP3mfKH79Jd2WDAMb5yiW1Yn7GPNnGkvTN2q947uZuISrbiH+EC2j 3Emg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cVE6ro2F; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o125-v6si1442276qkf.325.2018.10.03.12.47.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 03 Oct 2018 12:47:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cVE6ro2F; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52674 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n7d-00085W-Lx for patch@linaro.org; Wed, 03 Oct 2018 15:47:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n02-0001eW-Oy for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:40:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7n00-00021A-1n for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:39:58 -0400 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]:43712) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g7mzx-0001tm-Gn for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:39:53 -0400 Received: by mail-qt1-x844.google.com with SMTP id q41-v6so7282218qtq.10 for ; Wed, 03 Oct 2018 12:39:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=eVBZVdR2wlJYrDZOh2ss3tefv/SjOKwhbvvyOD1IcWI=; b=cVE6ro2FRF0t5fJb+vQy4CAqk+eLEnqaKUFpu9FjE0S3fdd/+WazeIoaNjrnyS6idG wIKXRvvaI/BMjWxHa0dal11BF/wLfgTbsnRW48R30t90y/GkQgh9+RsQ+eeeIr/eNGog tNn7UTSKJOpfOs8OLj7JOtlewazru2nN0L0fk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=eVBZVdR2wlJYrDZOh2ss3tefv/SjOKwhbvvyOD1IcWI=; b=ZpiiCrGOwCUgnQas0eGSbMoLwQvxbxq5Y5opWz431FGv3weczsbDZgRyatTheNpREC TKrhACGOPad3EmKJPlDE6/BZ5QFoA10Ly34wsOoXfUsZ/HcvzKVz0ncUHUGDIiZAHQT5 COchqRM3+i9fA2S+c+g6WDIyxlNHfjwgSO39ePJWOFLBPz3ed2I36aKnUStYHPSm2osx BDcK0bRDXoJyxl6InvBx5z09xLxc1LWSS8ekxUjZo+qn4npCrZRf7fz2nVFR6Wa+Hq81 S8KkA+EVAwGWwRKI5iLBwSjf/Z00RfIvbVGD9dEYFR78nC6ZoX9+99o37u/h0z8g0Zep UhIw== X-Gm-Message-State: ABuFfoiF/YiN0eRn6S9rQiX/uN9Ou9BwXIOqmPKfwZOieG3M8r2zbhWT 5aDHkIcpES8t/XxMPmdBZUtf6/7vlb/UuA== X-Received: by 2002:a0c:edcd:: with SMTP id i13-v6mr2592568qvr.15.1538595583780; Wed, 03 Oct 2018 12:39:43 -0700 (PDT) Received: from cloudburst.twiddle.net ([172.56.13.153]) by smtp.gmail.com with ESMTPSA id t16-v6sm1284946qth.68.2018.10.03.12.39.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Oct 2018 12:39:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Oct 2018 14:39:23 -0500 Message-Id: <20181003193931.18096-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003193931.18096-1-richard.henderson@linaro.org> References: <20181003193931.18096-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::844 Subject: [Qemu-devel] [PATCH v3 1/9] tcg: Split CONFIG_ATOMIC128 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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. Reviewed-by: Emilio G. Cota Signed-off-by: Richard Henderson --- accel/tcg/atomic_template.h | 20 ++++- include/qemu/atomic128.h | 155 ++++++++++++++++++++++++++++++++++++ tcg/tcg.h | 16 ++-- accel/tcg/cputlb.c | 3 +- accel/tcg/user-exec.c | 5 +- configure | 19 +++++ 6 files changed, 204 insertions(+), 14 deletions(-) create mode 100644 include/qemu/atomic128.h -- 2.17.1 diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index d751bcba48..efde12fdb2 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; +#if DATA_SIZE == 16 + ret = atomic16_cmpxchg(haddr, cmpv, newv); +#else ret = atomic_cmpxchg__nocheck(haddr, cmpv, newv); +#endif ATOMIC_MMU_CLEANUP; return ret; } #if DATA_SIZE >= 16 +#if HAVE_ATOMIC128 ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr EXTRA_ARGS) { ATOMIC_MMU_DECLS; DATA_TYPE val, *haddr = ATOMIC_MMU_LOOKUP; ATOMIC_TRACE_LD; - __atomic_load(haddr, &val, __ATOMIC_RELAXED); + val = atomic16_read(haddr); ATOMIC_MMU_CLEANUP; return val; } @@ -124,9 +129,10 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr, DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; ATOMIC_TRACE_ST; - __atomic_store(haddr, &val, __ATOMIC_RELAXED); + atomic16_set(haddr, val); ATOMIC_MMU_CLEANUP; } +#endif #else ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, ABI_TYPE val EXTRA_ARGS) @@ -228,19 +234,24 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr, DATA_TYPE ret; ATOMIC_TRACE_RMW; +#if DATA_SIZE == 16 + ret = atomic16_cmpxchg(haddr, BSWAP(cmpv), BSWAP(newv)); +#else ret = atomic_cmpxchg__nocheck(haddr, BSWAP(cmpv), BSWAP(newv)); +#endif ATOMIC_MMU_CLEANUP; return BSWAP(ret); } #if DATA_SIZE >= 16 +#if HAVE_ATOMIC128 ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr EXTRA_ARGS) { ATOMIC_MMU_DECLS; DATA_TYPE val, *haddr = ATOMIC_MMU_LOOKUP; ATOMIC_TRACE_LD; - __atomic_load(haddr, &val, __ATOMIC_RELAXED); + val = atomic16_read(haddr); ATOMIC_MMU_CLEANUP; return BSWAP(val); } @@ -253,9 +264,10 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr, ATOMIC_TRACE_ST; val = BSWAP(val); - __atomic_store(haddr, &val, __ATOMIC_RELAXED); + atomic16_set(haddr, val); ATOMIC_MMU_CLEANUP; } +#endif #else ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, ABI_TYPE val EXTRA_ARGS) diff --git a/include/qemu/atomic128.h b/include/qemu/atomic128.h new file mode 100644 index 0000000000..fdea225132 --- /dev/null +++ b/include/qemu/atomic128.h @@ -0,0 +1,155 @@ +/* + * Simple interface for 128-bit atomic operations. + * + * Copyright (C) 2018 Linaro, Ltd. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + * See docs/devel/atomics.txt for discussion about the guarantees each + * atomic primitive is meant to provide. + */ + +#ifndef QEMU_ATOMIC128_H +#define QEMU_ATOMIC128_H + +/* + * GCC is a house divided about supporting large atomic operations. + * + * For hosts that only have large compare-and-swap, a legalistic reading + * of the C++ standard means that one cannot implement __atomic_read on + * read-only memory, and thus all atomic operations must synchronize + * through libatomic. + * + * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80878 + * + * This interpretation is not especially helpful for QEMU. + * For softmmu, all RAM is always read/write from the hypervisor. + * For user-only, if the guest doesn't implement such an __atomic_read + * then the host need not worry about it either. + * + * Moreover, using libatomic is not an option, because its interface is + * built for std::atomic, and requires that *all* accesses to such an + * object go through the library. In our case we do not have an object + * in the C/C++ sense, but a view of memory as seen by the guest. + * The guest may issue a large atomic operation and then access those + * pieces using word-sized accesses. From the hypervisor, we have no + * way to connect those two actions. + * + * Therefore, special case each platform. + */ + +#if defined(CONFIG_ATOMIC128) +static inline Int128 atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new) +{ + return atomic_cmpxchg__nocheck(ptr, cmp, new); +} +# define HAVE_CMPXCHG128 1 +#elif defined(CONFIG_CMPXCHG128) +static inline Int128 atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new) +{ + return __sync_val_compare_and_swap_16(ptr, cmp, new); +} +# define HAVE_CMPXCHG128 1 +#elif defined(__aarch64__) +/* Through gcc 8, aarch64 has no support for 128-bit at all. */ +static inline Int128 atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new) +{ + uint64_t cmpl = int128_getlo(cmp), cmph = int128_gethi(cmp); + uint64_t newl = int128_getlo(new), newh = int128_gethi(new); + uint64_t oldl, oldh; + uint32_t tmp; + + asm("0: ldaxp %[oldl], %[oldh], %[mem]\n\t" + "cmp %[oldl], %[cmpl]\n\t" + "ccmp %[oldh], %[cmph], #0, eq\n\t" + "b.ne 1f\n\t" + "stlxp %w[tmp], %[newl], %[newh], %[mem]\n\t" + "cbnz %w[tmp], 0b\n" + "1:" + : [mem] "+m"(*ptr), [tmp] "=&r"(tmp), + [oldl] "=&r"(oldl), [oldh] "=r"(oldh) + : [cmpl] "r"(cmpl), [cmph] "r"(cmph), + [newl] "r"(newl), [newh] "r"(newh) + : "memory", "cc"); + + return int128_make128(oldl, oldh); +} +# define HAVE_CMPXCHG128 1 +#else +/* Fallback definition that must be optimized away, or error. */ +Int128 __attribute__((error("unsupported atomic"))) + atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new); +# define HAVE_CMPXCHG128 0 +#endif /* Some definition for HAVE_CMPXCHG128 */ + + +#if defined(CONFIG_ATOMIC128) +static inline Int128 atomic16_read(Int128 *ptr) +{ + return atomic_read__nocheck(ptr); +} + +static inline void atomic16_set(Int128 *ptr, Int128 val) +{ + atomic_set__nocheck(ptr, val); +} + +# define HAVE_ATOMIC128 1 +#elif !defined(CONFIG_USER_ONLY) && defined(__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" + "cbnz %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 = int128_getlo(val), h = int128_gethi(val); + uint64_t 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" + "cbnz %w[t1], 0b" + : [mem] "+m"(*ptr), [t1] "=&r"(t1), [t2] "=&r"(t2) + : [l] "r"(l), [h] "r"(h)); +} + +# define HAVE_ATOMIC128 1 +#elif !defined(CONFIG_USER_ONLY) && HAVE_CMPXCHG128 +static inline Int128 atomic16_read(Int128 *ptr) +{ + /* Maybe replace 0 with 0, returning the old value. */ + return atomic16_cmpxchg(ptr, 0, 0); +} + +static inline void atomic16_set(Int128 *ptr, Int128 val) +{ + Int128 old = *ptr, cmp; + do { + cmp = old; + old = atomic16_cmpxchg(ptr, cmp, val); + } while (old != cmp); +} + +# define HAVE_ATOMIC128 1 +#else +/* Fallback definitions that must be optimized away, or error. */ +Int128 __attribute__((error("unsupported atomic"))) + atomic16_read(Int128 *ptr); +void __attribute__((error("unsupported atomic"))) + atomic16_set(Int128 *ptr, Int128 val); +# define HAVE_ATOMIC128 0 +#endif /* Some definition for HAVE_ATOMIC128 */ + +#endif /* QEMU_ATOMIC128_H */ diff --git a/tcg/tcg.h b/tcg/tcg.h index f9f12378e9..20803b8b64 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -32,6 +32,7 @@ #include "qemu/queue.h" #include "tcg-mo.h" #include "tcg-target.h" +#include "qemu/int128.h" /* XXX: make safe guess about sizes */ #define MAX_OP_PER_INSTR 266 @@ -1454,11 +1455,14 @@ GEN_ATOMIC_HELPER_ALL(xchg) #undef GEN_ATOMIC_HELPER #endif /* CONFIG_SOFTMMU */ -#ifdef CONFIG_ATOMIC128 -#include "qemu/int128.h" - -/* These aren't really a "proper" helpers because TCG cannot manage Int128. - However, use the same format as the others, for use by the backends. */ +/* + * These aren't really a "proper" helpers because TCG cannot manage Int128. + * However, use the same format as the others, for use by the backends. + * + * The cmpxchg functions are only defined if HAVE_CMPXCHG128; + * the ld/st functions are only defined if HAVE_ATOMIC128, + * as defined by . + */ Int128 helper_atomic_cmpxchgo_le_mmu(CPUArchState *env, target_ulong addr, Int128 cmpv, Int128 newv, TCGMemOpIdx oi, uintptr_t retaddr); @@ -1475,6 +1479,4 @@ void helper_atomic_sto_le_mmu(CPUArchState *env, target_ulong addr, Int128 val, void helper_atomic_sto_be_mmu(CPUArchState *env, target_ulong addr, Int128 val, TCGMemOpIdx oi, uintptr_t retaddr); -#endif /* CONFIG_ATOMIC128 */ - #endif /* TCG_H */ diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index f4702ce91f..0e740f5296 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -32,6 +32,7 @@ #include "exec/log.h" #include "exec/helper-proto.h" #include "qemu/atomic.h" +#include "qemu/atomic128.h" /* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU target */ /* #define DEBUG_TLB */ @@ -1101,7 +1102,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, #include "atomic_template.h" #endif -#ifdef CONFIG_ATOMIC128 +#if HAVE_CMPXCHG128 || HAVE_ATOMIC128 #define DATA_SIZE 16 #include "atomic_template.h" #endif diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 26a3ffbba1..cd75829cf2 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -25,6 +25,7 @@ #include "exec/cpu_ldst.h" #include "translate-all.h" #include "exec/helper-proto.h" +#include "qemu/atomic128.h" #undef EAX #undef ECX @@ -615,7 +616,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, /* The following is only callable from other helpers, and matches up with the softmmu version. */ -#ifdef CONFIG_ATOMIC128 +#if HAVE_ATOMIC128 || HAVE_CMPXCHG128 #undef EXTRA_ARGS #undef ATOMIC_NAME @@ -628,4 +629,4 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, #define DATA_SIZE 16 #include "atomic_template.h" -#endif /* CONFIG_ATOMIC128 */ +#endif diff --git a/configure b/configure index f3d4b799a5..f6fa341f33 100755 --- a/configure +++ b/configure @@ -5186,6 +5186,21 @@ EOF fi fi +cmpxchg128=no +if test "$int128" = yes -a "$atomic128" = no; then + cat > $TMPC << EOF +int main(void) +{ + unsigned __int128 x = 0, y = 0; + __sync_val_compare_and_swap_16(&x, y, x); + return 0; +} +EOF + if compile_prog "" "" ; then + cmpxchg128=yes + fi +fi + ######################################### # See if 64-bit atomic operations are supported. # Note that without __atomic builtins, we can only @@ -6702,6 +6717,10 @@ if test "$atomic128" = "yes" ; then echo "CONFIG_ATOMIC128=y" >> $config_host_mak fi +if test "$cmpxchg128" = "yes" ; then + echo "CONFIG_CMPXCHG128=y" >> $config_host_mak +fi + if test "$atomic64" = "yes" ; then echo "CONFIG_ATOMIC64=y" >> $config_host_mak fi From patchwork Wed Oct 3 19:39:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148077 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp59418lji; Wed, 3 Oct 2018 12:43:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV62soVEBD5Hj1jMzh6TBrYu3tADQRaZl4mF1+aFTzYCTiv2pjU493tmDLhJM93rX/3ntwv+w X-Received: by 2002:a37:4c09:: with SMTP id z9-v6mr2514292qka.302.1538595797469; Wed, 03 Oct 2018 12:43:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538595797; cv=none; d=google.com; s=arc-20160816; b=YiXVdoUWY7EBQRDlsxHb26DRYojdyAK6hPV/3BW7QPLICi4lmG/RbeX4cnDNqJv7xV Xfxm4u2Wdl6SJ1U/5rnpU0BSF2uAi4UTq+V6+NCrUfDbX3M0ole5o7LtPpoYm7oy6s2d 74Uh319xdEBDkCKepnL2AmTfaCh+H7UAXJUAz+jiSwIs0h5xx7I3QGlyg9kMUK7yW4AV 7ICoYG4xhcr00CYMbCIYmZ7HLtxQFfOCSjzupfxW+TS/EJiZiQ+RSry6HYAFd5l7xJo/ WKVGoseNcyunGpW/1nCN0DSU5iJy7b8MjJNhp/unfLsiQKsYdBCIEf4gfmHJEuD5AMqp avjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Kw70vJmJvvdMa1ZmP7qQjISsq1++nuywnW3iYLCkFuE=; b=qUamTEo8cWDKfccbmNVDQaX+92TgvXVuJz3f6F1Ot3+Oxc0Jj/qJn5OGDyPAJ/Ueeu 1dVuENau1kD36d63sO9vxKKTALiqbGIbGrYscRzlWkMScy339nsRNZJAWSddomZfSscF ZB7EIlL7eMvILHU+Kuv7zcoOkTMAEd0w1xv3jelNJ2eQKbhIe2LpisgTGwmPoQINQthU V6w6GPmxr+5ZAb+bSQLhKYYd/cgEgagvQjJVaQxsM1onBemYRaeJEVwt3i3oHNZESm4w GqoqtQGGUV96ESYtXjfEI7xPOtimYSak/v2KNfsXqlwuabqzyF4SjufSysVK8gQ726Th GfXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=K69bev5k; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x137-v6si1490915qkx.394.2018.10.03.12.43.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 03 Oct 2018 12:43:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=K69bev5k; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n3E-0004mH-Rj for patch@linaro.org; Wed, 03 Oct 2018 15:43:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n00-0001eM-SM for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:39:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7mzz-00020Y-JR for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:39:56 -0400 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]:34718) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g7mzv-0001ur-Hp for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:39:53 -0400 Received: by mail-qk1-x736.google.com with SMTP id p6-v6so4258499qkg.1 for ; Wed, 03 Oct 2018 12:39:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=Kw70vJmJvvdMa1ZmP7qQjISsq1++nuywnW3iYLCkFuE=; b=K69bev5kQp/mtF1Res3seLjvcGlImXE3GN1VXUeCLBY+nvTZjyPBeTopTmppBXXL08 0WQ2Q2mK0LvrlPQ6OmNPlzUasT/f2MWNL8uqQRKOOlipHI2KM3itpPaf/XxtEVP9kQS+ l5uvdz4JZfGOw4MJIZS+Z8cvvjP5QVgbm1oOQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Kw70vJmJvvdMa1ZmP7qQjISsq1++nuywnW3iYLCkFuE=; b=f7FemdrgIhRUF7GeIRfmwOD/kr3uC38OG0iq2DoKGr9529B2WbMODXbHlXygqvNiRO tEPfpnCrAWkzXGLKuHLZK15mSxZKm2/UOSn3aDG/7wJt3r1k52h5x6lv3F3hrzIF/u1+ 9pibMHW6zFYBCEnidg2SAJVBKkNBU3mtVYKtiUDCP2jIFAJXjJRzMs7zEfWsdXQbc6H4 O5yACk6V4Skv3fQgaex4VHEbKmozXfKxSNj/xB2ec2eXtAB1LIPpDwf/+hD8DJoUNkAz 11lkL7Evq0RlG7mpAT5HyelnGHmJEvDxWQMh4WxxsqexzWvMH668WSorJYedZ5dRwdFN 17xg== X-Gm-Message-State: ABuFfogn1HFBjqZ+5DVFT6st+v16IT/f3tI89JeAm1bvFkx+S/febnPJ Gxis2ZLYqiSkkI63gEPwHNYa3h7yyvDrvA== X-Received: by 2002:a37:ccd5:: with SMTP id n82-v6mr2383997qkl.16.1538595585788; Wed, 03 Oct 2018 12:39:45 -0700 (PDT) Received: from cloudburst.twiddle.net ([172.56.13.153]) by smtp.gmail.com with ESMTPSA id t16-v6sm1284946qth.68.2018.10.03.12.39.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Oct 2018 12:39:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Oct 2018 14:39:24 -0500 Message-Id: <20181003193931.18096-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003193931.18096-1-richard.henderson@linaro.org> References: <20181003193931.18096-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::736 Subject: [Qemu-devel] [PATCH v3 2/9] target/i386: Convert to HAVE_CMPXCHG128 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Emilio G. Cota Signed-off-by: Richard Henderson --- target/i386/mem_helper.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) -- 2.17.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/target/i386/mem_helper.c b/target/i386/mem_helper.c index 30c26b9d9c..6cc53bcb40 100644 --- a/target/i386/mem_helper.c +++ b/target/i386/mem_helper.c @@ -23,6 +23,7 @@ #include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "qemu/int128.h" +#include "qemu/atomic128.h" #include "tcg.h" void helper_cmpxchg8b_unlocked(CPUX86State *env, target_ulong a0) @@ -137,10 +138,7 @@ void helper_cmpxchg16b(CPUX86State *env, target_ulong a0) if ((a0 & 0xf) != 0) { raise_exception_ra(env, EXCP0D_GPF, ra); - } else { -#ifndef CONFIG_ATOMIC128 - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); -#else + } else if (HAVE_CMPXCHG128) { int eflags = cpu_cc_compute_all(env, CC_OP); Int128 cmpv = int128_make128(env->regs[R_EAX], env->regs[R_EDX]); @@ -159,7 +157,8 @@ void helper_cmpxchg16b(CPUX86State *env, target_ulong a0) eflags &= ~CC_Z; } CC_SRC = eflags; -#endif + } else { + cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); } } #endif From patchwork Wed Oct 3 19:39:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148083 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp63623lji; Wed, 3 Oct 2018 12:48:09 -0700 (PDT) X-Google-Smtp-Source: ACcGV60JT4vsmkuoaHNYPN5rqJzquffFLk72Pf3B4hosR0IFJE0FMPDTGpIVqVi7GImPmdsld80e X-Received: by 2002:aed:34e1:: with SMTP id x88-v6mr2646996qtd.156.1538596089463; Wed, 03 Oct 2018 12:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538596089; cv=none; d=google.com; s=arc-20160816; b=QqHTqYSDLIRXmtjxv5iFCq/imVbP5hPAT1E7/mWJtxbXNnB7C40B3c/qNsak7VYaR3 zxg3XBu4TPsjAw7PxcFSvLwruZcNir6njN6reVhGB4SflsvODbN5L/Ddh7wuDOmISBho nm0lEIUys33rHIbFc7OHD+yzkViYE4hcY9nbM2oagPQK/3KH19jfIThBUWtDJ9mgOUTZ ZI3Wh1/gZyGFyZv6xCRl0l/8aMkI8gVIzfErbCKbenSaWFBCRCh9H1rSvQEI8FUD9eor Dar0I+icOwUOrtO8MubtxeTVD17R3Gz3ZmZP8DP1vBNPxphgXRdn/1eIkJfaUX9EqRNO tYfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=QKc2lwPI6gYZ9z9pd6IUUHkpaxmzYi423q9W7Fv4D+w=; b=ruQ8vni8zZLh/MSW7sjHT5anGx2mQwA5Y7UD0Oq9QmYnJbvD/Z1B88iv1zSRnm/2Cl jrENKoXbT0L6HlgHml8iIxManWykvLElx2DcV1eL2XVZZ6wBmNQyBqOSkVKAzFT1AwKj /uy0RGF4m5PGel4H4EyxPAb/ui/cEmdCKAxDi80vPvooe0z7r9tUb9JleniheCtyFLpm 3WgEvk0Zo4Xq7in4cj6DCxEOLr2a3LH3VHuBUPaDapD+GftKuPcb+AdaDCaYnhHvSsV9 2sk20zEi/LCXG9sonl82WwCQ2UXbXZn72vd5r5Adj7Efxv7WLd6/NOq1tRHh91MfXSN1 AHqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HQboFbgL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n7-v6si1513750qkf.123.2018.10.03.12.48.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 03 Oct 2018 12:48:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HQboFbgL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n7w-00088Z-Vg for patch@linaro.org; Wed, 03 Oct 2018 15:48:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n02-0001eV-J5 for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:40:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7n00-00021K-1C for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:39:58 -0400 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:45482) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g7mzx-0001vv-Hj for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:39:55 -0400 Received: by mail-qt1-x82f.google.com with SMTP id l2-v6so7264157qtr.12 for ; Wed, 03 Oct 2018 12:39:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=QKc2lwPI6gYZ9z9pd6IUUHkpaxmzYi423q9W7Fv4D+w=; b=HQboFbgLtbXlZmjf1mDGSFIGsb5FlTO+iC6jIZVurOIn6ZnLUyqrQhVfvc0tQEMHGa /oEh/uB+UTVm6MIQF3o8LSpK32pSxa4HXV9PA12UwdJd3TUlB+YTdWvvEp7I2gzCfOle T3L55XPZFnqbmUrBsTe2jAJH5+qDuJ28HmMy4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=QKc2lwPI6gYZ9z9pd6IUUHkpaxmzYi423q9W7Fv4D+w=; b=nz+k32n5y6t9kiJ6t1+uXqcvJfud87MmUYXZ7sEfb0P64IknPRDZAqRq//1lVj7KF3 gYsYSysFDs7twjgJ2z3+bSXPzOhiidTOQxGQB4SfT+WGav+Bt7vJplZtMi+9fXCbBurw QkXdebc5OeO9Frw/5AWjixdYLz/EWNUcRoEWNU8FZJMzodmmWzIgNGAKHquX2mlPUPJJ h/W6R9V0NSg9QozBNqvGB1bMaMcvHtM0akCZIQJpuy/qHxWaZXr6evaS56xfdT4akNF2 LccGMzDNyQ4ULsXd1jEWu7Hc+uuFsZCpgT7yMfx0e8jRqoy80OHnh+8yFltuhUkn+RCT q54w== X-Gm-Message-State: ABuFfojqVNb7l9fx52qn54u5nQ/dc6Sf5oU8AlWKsboT/R9sozZ7jL0p mADW3KVvbWAjV61Z6T9o/ZW38CJ25y+BqA== X-Received: by 2002:ac8:2e11:: with SMTP id r17-v6mr2597907qta.12.1538595587848; Wed, 03 Oct 2018 12:39:47 -0700 (PDT) Received: from cloudburst.twiddle.net ([172.56.13.153]) by smtp.gmail.com with ESMTPSA id t16-v6sm1284946qth.68.2018.10.03.12.39.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Oct 2018 12:39:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Oct 2018 14:39:25 -0500 Message-Id: <20181003193931.18096-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003193931.18096-1-richard.henderson@linaro.org> References: <20181003193931.18096-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::82f Subject: [Qemu-devel] [PATCH v3 3/9] target/arm: Convert to HAVE_CMPXCHG128 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Emilio G. Cota Signed-off-by: Richard Henderson --- target/arm/helper-a64.c | 259 +++++++++++++++++++++------------------- 1 file changed, 133 insertions(+), 126 deletions(-) -- 2.17.1 diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 7f6ad3000b..6e4e1b8a19 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -30,6 +30,7 @@ #include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "qemu/int128.h" +#include "qemu/atomic128.h" #include "tcg.h" #include "fpu/softfloat.h" #include /* For crc32 */ @@ -509,189 +510,195 @@ uint64_t HELPER(crc32c_64)(uint64_t acc, uint64_t val, uint32_t bytes) return crc32c(acc, buf, bytes) ^ 0xffffffff; } -/* Returns 0 on success; 1 otherwise. */ -static uint64_t do_paired_cmpxchg64_le(CPUARMState *env, uint64_t addr, - uint64_t new_lo, uint64_t new_hi, - bool parallel, uintptr_t ra) +uint64_t HELPER(paired_cmpxchg64_le)(CPUARMState *env, uint64_t addr, + uint64_t new_lo, uint64_t new_hi) { - Int128 oldv, cmpv, newv; + Int128 cmpv = int128_make128(env->exclusive_val, env->exclusive_high); + Int128 newv = int128_make128(new_lo, new_hi); + Int128 oldv; + uintptr_t ra = GETPC(); + uint64_t o0, o1; bool success; - cmpv = int128_make128(env->exclusive_val, env->exclusive_high); - newv = int128_make128(new_lo, new_hi); - - if (parallel) { -#ifndef CONFIG_ATOMIC128 - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); -#else - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); - oldv = helper_atomic_cmpxchgo_le_mmu(env, addr, cmpv, newv, oi, ra); - success = int128_eq(oldv, cmpv); -#endif - } else { - uint64_t o0, o1; - #ifdef CONFIG_USER_ONLY - /* ??? Enforce alignment. */ - uint64_t *haddr = g2h(addr); + /* ??? Enforce alignment. */ + uint64_t *haddr = g2h(addr); - helper_retaddr = ra; - o0 = ldq_le_p(haddr + 0); - o1 = ldq_le_p(haddr + 1); - oldv = int128_make128(o0, o1); + helper_retaddr = ra; + o0 = ldq_le_p(haddr + 0); + o1 = ldq_le_p(haddr + 1); + oldv = int128_make128(o0, o1); - success = int128_eq(oldv, cmpv); - if (success) { - stq_le_p(haddr + 0, int128_getlo(newv)); - stq_le_p(haddr + 1, int128_gethi(newv)); - } - helper_retaddr = 0; -#else - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi0 = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); - TCGMemOpIdx oi1 = make_memop_idx(MO_LEQ, mem_idx); - - o0 = helper_le_ldq_mmu(env, addr + 0, oi0, ra); - o1 = helper_le_ldq_mmu(env, addr + 8, oi1, ra); - oldv = int128_make128(o0, o1); - - success = int128_eq(oldv, cmpv); - if (success) { - helper_le_stq_mmu(env, addr + 0, int128_getlo(newv), oi1, ra); - helper_le_stq_mmu(env, addr + 8, int128_gethi(newv), oi1, ra); - } -#endif + success = int128_eq(oldv, cmpv); + if (success) { + stq_le_p(haddr + 0, int128_getlo(newv)); + stq_le_p(haddr + 1, int128_gethi(newv)); } + helper_retaddr = 0; +#else + int mem_idx = cpu_mmu_index(env, false); + TCGMemOpIdx oi0 = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); + TCGMemOpIdx oi1 = make_memop_idx(MO_LEQ, mem_idx); + + o0 = helper_le_ldq_mmu(env, addr + 0, oi0, ra); + o1 = helper_le_ldq_mmu(env, addr + 8, oi1, ra); + oldv = int128_make128(o0, o1); + + success = int128_eq(oldv, cmpv); + if (success) { + helper_le_stq_mmu(env, addr + 0, int128_getlo(newv), oi1, ra); + helper_le_stq_mmu(env, addr + 8, int128_gethi(newv), oi1, ra); + } +#endif return !success; } -uint64_t HELPER(paired_cmpxchg64_le)(CPUARMState *env, uint64_t addr, - uint64_t new_lo, uint64_t new_hi) -{ - return do_paired_cmpxchg64_le(env, addr, new_lo, new_hi, false, GETPC()); -} - uint64_t HELPER(paired_cmpxchg64_le_parallel)(CPUARMState *env, uint64_t addr, uint64_t new_lo, uint64_t new_hi) -{ - return do_paired_cmpxchg64_le(env, addr, new_lo, new_hi, true, GETPC()); -} - -static uint64_t do_paired_cmpxchg64_be(CPUARMState *env, uint64_t addr, - uint64_t new_lo, uint64_t new_hi, - bool parallel, uintptr_t ra) { Int128 oldv, cmpv, newv; + uintptr_t ra = GETPC(); bool success; + int mem_idx; + TCGMemOpIdx oi; - /* high and low need to be switched here because this is not actually a - * 128bit store but two doublewords stored consecutively - */ - cmpv = int128_make128(env->exclusive_high, env->exclusive_val); - newv = int128_make128(new_hi, new_lo); - - if (parallel) { -#ifndef CONFIG_ATOMIC128 + if (!HAVE_CMPXCHG128) { cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); -#else - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx); - oldv = helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, oi, ra); - success = int128_eq(oldv, cmpv); -#endif - } else { - uint64_t o0, o1; - -#ifdef CONFIG_USER_ONLY - /* ??? Enforce alignment. */ - uint64_t *haddr = g2h(addr); - - helper_retaddr = ra; - o1 = ldq_be_p(haddr + 0); - o0 = ldq_be_p(haddr + 1); - oldv = int128_make128(o0, o1); - - success = int128_eq(oldv, cmpv); - if (success) { - stq_be_p(haddr + 0, int128_gethi(newv)); - stq_be_p(haddr + 1, int128_getlo(newv)); - } - helper_retaddr = 0; -#else - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi0 = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx); - TCGMemOpIdx oi1 = make_memop_idx(MO_BEQ, mem_idx); - - o1 = helper_be_ldq_mmu(env, addr + 0, oi0, ra); - o0 = helper_be_ldq_mmu(env, addr + 8, oi1, ra); - oldv = int128_make128(o0, o1); - - success = int128_eq(oldv, cmpv); - if (success) { - helper_be_stq_mmu(env, addr + 0, int128_gethi(newv), oi1, ra); - helper_be_stq_mmu(env, addr + 8, int128_getlo(newv), oi1, ra); - } -#endif } + mem_idx = cpu_mmu_index(env, false); + oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); + + cmpv = int128_make128(env->exclusive_val, env->exclusive_high); + newv = int128_make128(new_lo, new_hi); + oldv = helper_atomic_cmpxchgo_le_mmu(env, addr, cmpv, newv, oi, ra); + + success = int128_eq(oldv, cmpv); return !success; } uint64_t HELPER(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr, uint64_t new_lo, uint64_t new_hi) { - return do_paired_cmpxchg64_be(env, addr, new_lo, new_hi, false, GETPC()); + /* + * High and low need to be switched here because this is not actually a + * 128bit store but two doublewords stored consecutively + */ + Int128 cmpv = int128_make128(env->exclusive_val, env->exclusive_high); + Int128 newv = int128_make128(new_lo, new_hi); + Int128 oldv; + uintptr_t ra = GETPC(); + uint64_t o0, o1; + bool success; + +#ifdef CONFIG_USER_ONLY + /* ??? Enforce alignment. */ + uint64_t *haddr = g2h(addr); + + helper_retaddr = ra; + o1 = ldq_be_p(haddr + 0); + o0 = ldq_be_p(haddr + 1); + oldv = int128_make128(o0, o1); + + success = int128_eq(oldv, cmpv); + if (success) { + stq_be_p(haddr + 0, int128_gethi(newv)); + stq_be_p(haddr + 1, int128_getlo(newv)); + } + helper_retaddr = 0; +#else + int mem_idx = cpu_mmu_index(env, false); + TCGMemOpIdx oi0 = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx); + TCGMemOpIdx oi1 = make_memop_idx(MO_BEQ, mem_idx); + + o1 = helper_be_ldq_mmu(env, addr + 0, oi0, ra); + o0 = helper_be_ldq_mmu(env, addr + 8, oi1, ra); + oldv = int128_make128(o0, o1); + + success = int128_eq(oldv, cmpv); + if (success) { + helper_be_stq_mmu(env, addr + 0, int128_gethi(newv), oi1, ra); + helper_be_stq_mmu(env, addr + 8, int128_getlo(newv), oi1, ra); + } +#endif + + return !success; } uint64_t HELPER(paired_cmpxchg64_be_parallel)(CPUARMState *env, uint64_t addr, - uint64_t new_lo, uint64_t new_hi) + uint64_t new_lo, uint64_t new_hi) { - return do_paired_cmpxchg64_be(env, addr, new_lo, new_hi, true, GETPC()); + Int128 oldv, cmpv, newv; + uintptr_t ra = GETPC(); + bool success; + int mem_idx; + TCGMemOpIdx oi; + + if (!HAVE_CMPXCHG128) { + cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); + } + + mem_idx = cpu_mmu_index(env, false); + oi = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx); + + /* + * High and low need to be switched here because this is not actually a + * 128bit store but two doublewords stored consecutively + */ + cmpv = int128_make128(env->exclusive_high, env->exclusive_val); + newv = int128_make128(new_hi, new_lo); + oldv = helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, oi, ra); + + success = int128_eq(oldv, cmpv); + return !success; } /* Writes back the old data into Rs. */ void HELPER(casp_le_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr, uint64_t new_lo, uint64_t new_hi) { - uintptr_t ra = GETPC(); -#ifndef CONFIG_ATOMIC128 - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); -#else Int128 oldv, cmpv, newv; + uintptr_t ra = GETPC(); + int mem_idx; + TCGMemOpIdx oi; + + if (!HAVE_CMPXCHG128) { + cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); + } + + mem_idx = cpu_mmu_index(env, false); + oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); cmpv = int128_make128(env->xregs[rs], env->xregs[rs + 1]); newv = int128_make128(new_lo, new_hi); - - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); oldv = helper_atomic_cmpxchgo_le_mmu(env, addr, cmpv, newv, oi, ra); env->xregs[rs] = int128_getlo(oldv); env->xregs[rs + 1] = int128_gethi(oldv); -#endif } void HELPER(casp_be_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr, uint64_t new_hi, uint64_t new_lo) { - uintptr_t ra = GETPC(); -#ifndef CONFIG_ATOMIC128 - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); -#else Int128 oldv, cmpv, newv; + uintptr_t ra = GETPC(); + int mem_idx; + TCGMemOpIdx oi; + + if (!HAVE_CMPXCHG128) { + cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); + } + + mem_idx = cpu_mmu_index(env, false); + oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); cmpv = int128_make128(env->xregs[rs + 1], env->xregs[rs]); newv = int128_make128(new_lo, new_hi); - - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); oldv = helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, oi, ra); env->xregs[rs + 1] = int128_getlo(oldv); env->xregs[rs] = int128_gethi(oldv); -#endif } /* From patchwork Wed Oct 3 19:39:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148079 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp61290lji; Wed, 3 Oct 2018 12:45:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV62RNpkAhx62AAb2ETB0kWiadjF76tA5T0UEHyzalKYTc6R0adS8GSepxR60QoJ0jX3j063c X-Received: by 2002:ae9:c107:: with SMTP id z7-v6mr2466529qki.192.1538595929702; Wed, 03 Oct 2018 12:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538595929; cv=none; d=google.com; s=arc-20160816; b=MWROxgcPp4ScLwXEdyFq73gTJGFM7TdLpYk6wMavRalTDy4wIu8+N+ZX8fkmKldzPh u6N42FjPoVN0/p2uel67nMWRMkfxyZ1HLKIMFiYxtNO5LYUkHuZKBdFBlpsVTDXAQTEA eJFDfEWncCa10vQQPR2XmF1CsBmh3SWRmWLf+rWbp0LFb2hT6P/jcb+81xNwxaeMugom vbUie/G02wL3e/teUpQuKAypUab4Dwiyepj2MTFvqc3dtK4z//dcIyxUseK63WtcmXGU J3GklJl1KbEvjn0YGmHWDDfYw2FN+r/AwVgYlqFGv7nQvu6LxZ+RY/ryxNcbjzHQoYBE xwGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=xuHerAB2JXb2RBv3WZ9DmR34fnauKPogn/gGgCYi1Kg=; b=W89ToSJFaro7Pg5pflfXeLO2ZUzKc1BFa8fJ+16al4JZQvHH6UtNloLWR/8jcIiQ+0 vgOQaI5wM4+RVug7nw947aYZglC8KDtW/FB3kXCd/ioOU+hppyz2MMtZ4Bn3dh7sL9b5 FVGRjGSAGVtFcBkxh/z96XhcnoEme9s/N1cBWVUH58L3HOSZtx1+yUjJCkyUpUIqgR6n D/q1BovEpK5GhxtGw/HJw9vwuLCpT3l62WM4qxSN0fwwmF20VzL2mYTzzS0J2v5U6TPM 675my7HxB4BWsHIAb4pgMTu3739Q5jVdGPDkJ9edwI3uBNyv9HHjqO6/IzsA2W2OAIzY ptwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gKcHmB3l; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w3-v6si1456805qvw.271.2018.10.03.12.45.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 03 Oct 2018 12:45:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gKcHmB3l; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n5N-0006Qf-4F for patch@linaro.org; Wed, 03 Oct 2018 15:45:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n02-0001eX-S0 for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:40:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7n00-00022b-Tc for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:39:58 -0400 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]:42537) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g7n00-0001wt-5V for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:39:56 -0400 Received: by mail-qt1-x841.google.com with SMTP id z8-v6so7282472qto.9 for ; Wed, 03 Oct 2018 12:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=xuHerAB2JXb2RBv3WZ9DmR34fnauKPogn/gGgCYi1Kg=; b=gKcHmB3lFe6XxTMUVp0R1f1bezV3r9tEOlXcMjWgxKXKp0A/rsBFKh8/ffUePT9PUx Y+rZnKZ1TYwYw7zg6UJxcVDBo+hHeyH7rZARBxYlp8ZD/BN9sAYI0Bzcpa65/K2xDE0h vaevoRD7NRj6xx+Qq0+F/kGhB1lyr0szYJ0Iw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=xuHerAB2JXb2RBv3WZ9DmR34fnauKPogn/gGgCYi1Kg=; b=jXQZzsm7EgyXjwCSSr42G6aDJNYoYCs8TZ2jZ98ci8huMu/IB9dQQdqV+aM/64KRv+ Q9X/hyx4F0EvxBBSRBoS/7oHEr7J/I/bMxk6xqjVNAA04W/aMGAzojHODhTfwujcfHeL DxGhUTCc38rMFfkTKhBYxnmAjmk8dMqwPYYP40L1wb/y6a4cNjAGkCIdgKJEeLE1P9EY eTBxevT+IBxwWLj6LvtjIps6WufeWODKV9QCJ4wfPWraRK22MOk69Wo4Y58RkEi+5vJV ojwx+u9hKRKz9B0gxC27pilVpjKM3WsafzvWnHjgCtPoO/TrvLYHZLDhcarTHDJk7K/N 2FnQ== X-Gm-Message-State: ABuFfoh0qZEa9xpL+X4OBKa1EHZN2y6/6HNCSzmrKr8ZQI+zRRcl2dN8 MZVHxnNVtpI16cVdEFYgCGZQuzhj8ajJLg== X-Received: by 2002:a0c:8c86:: with SMTP id p6-v6mr2572026qvb.246.1538595589869; Wed, 03 Oct 2018 12:39:49 -0700 (PDT) Received: from cloudburst.twiddle.net ([172.56.13.153]) by smtp.gmail.com with ESMTPSA id t16-v6sm1284946qth.68.2018.10.03.12.39.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Oct 2018 12:39:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Oct 2018 14:39:26 -0500 Message-Id: <20181003193931.18096-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003193931.18096-1-richard.henderson@linaro.org> References: <20181003193931.18096-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::841 Subject: [Qemu-devel] [PATCH v3 4/9] target/arm: Check HAVE_CMPXCHG128 at translate time X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Emilio G. Cota Signed-off-by: Richard Henderson --- target/arm/helper-a64.c | 16 ++++------------ target/arm/translate-a64.c | 38 ++++++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 28 deletions(-) -- 2.17.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 6e4e1b8a19..61799d20e1 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -563,9 +563,7 @@ uint64_t HELPER(paired_cmpxchg64_le_parallel)(CPUARMState *env, uint64_t addr, int mem_idx; TCGMemOpIdx oi; - if (!HAVE_CMPXCHG128) { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_CMPXCHG128); mem_idx = cpu_mmu_index(env, false); oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); @@ -635,9 +633,7 @@ uint64_t HELPER(paired_cmpxchg64_be_parallel)(CPUARMState *env, uint64_t addr, int mem_idx; TCGMemOpIdx oi; - if (!HAVE_CMPXCHG128) { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_CMPXCHG128); mem_idx = cpu_mmu_index(env, false); oi = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx); @@ -663,9 +659,7 @@ void HELPER(casp_le_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr, int mem_idx; TCGMemOpIdx oi; - if (!HAVE_CMPXCHG128) { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_CMPXCHG128); mem_idx = cpu_mmu_index(env, false); oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); @@ -686,9 +680,7 @@ void HELPER(casp_be_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr, int mem_idx; TCGMemOpIdx oi; - if (!HAVE_CMPXCHG128) { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_CMPXCHG128); mem_idx = cpu_mmu_index(env, false); oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 8ca3876707..77ee8d9085 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -37,6 +37,7 @@ #include "trace-tcg.h" #include "translate-a64.h" +#include "qemu/atomic128.h" static TCGv_i64 cpu_X[32]; static TCGv_i64 cpu_pc; @@ -2082,26 +2083,27 @@ static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2, get_mem_index(s), MO_64 | MO_ALIGN | s->be_data); tcg_gen_setcond_i64(TCG_COND_NE, tmp, tmp, cpu_exclusive_val); - } else if (s->be_data == MO_LE) { - if (tb_cflags(s->base.tb) & CF_PARALLEL) { + } else if (tb_cflags(s->base.tb) & CF_PARALLEL) { + if (!HAVE_CMPXCHG128) { + gen_helper_exit_atomic(cpu_env); + s->base.is_jmp = DISAS_NORETURN; + } else if (s->be_data == MO_LE) { gen_helper_paired_cmpxchg64_le_parallel(tmp, cpu_env, cpu_exclusive_addr, cpu_reg(s, rt), cpu_reg(s, rt2)); } else { - gen_helper_paired_cmpxchg64_le(tmp, cpu_env, cpu_exclusive_addr, - cpu_reg(s, rt), cpu_reg(s, rt2)); - } - } else { - if (tb_cflags(s->base.tb) & CF_PARALLEL) { gen_helper_paired_cmpxchg64_be_parallel(tmp, cpu_env, cpu_exclusive_addr, cpu_reg(s, rt), cpu_reg(s, rt2)); - } else { - gen_helper_paired_cmpxchg64_be(tmp, cpu_env, cpu_exclusive_addr, - cpu_reg(s, rt), cpu_reg(s, rt2)); } + } else if (s->be_data == MO_LE) { + gen_helper_paired_cmpxchg64_le(tmp, cpu_env, cpu_exclusive_addr, + cpu_reg(s, rt), cpu_reg(s, rt2)); + } else { + gen_helper_paired_cmpxchg64_be(tmp, cpu_env, cpu_exclusive_addr, + cpu_reg(s, rt), cpu_reg(s, rt2)); } } else { tcg_gen_atomic_cmpxchg_i64(tmp, cpu_exclusive_addr, cpu_exclusive_val, @@ -2171,14 +2173,18 @@ static void gen_compare_and_swap_pair(DisasContext *s, int rs, int rt, } tcg_temp_free_i64(cmp); } else if (tb_cflags(s->base.tb) & CF_PARALLEL) { - TCGv_i32 tcg_rs = tcg_const_i32(rs); - - if (s->be_data == MO_LE) { - gen_helper_casp_le_parallel(cpu_env, tcg_rs, addr, t1, t2); + if (HAVE_CMPXCHG128) { + TCGv_i32 tcg_rs = tcg_const_i32(rs); + if (s->be_data == MO_LE) { + gen_helper_casp_le_parallel(cpu_env, tcg_rs, addr, t1, t2); + } else { + gen_helper_casp_be_parallel(cpu_env, tcg_rs, addr, t1, t2); + } + tcg_temp_free_i32(tcg_rs); } else { - gen_helper_casp_be_parallel(cpu_env, tcg_rs, addr, t1, t2); + gen_helper_exit_atomic(cpu_env); + s->base.is_jmp = DISAS_NORETURN; } - tcg_temp_free_i32(tcg_rs); } else { TCGv_i64 d1 = tcg_temp_new_i64(); TCGv_i64 d2 = tcg_temp_new_i64(); From patchwork Wed Oct 3 19:39:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148081 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp62057lji; Wed, 3 Oct 2018 12:46:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV62bkbvCyibcrS2zt0nL408rPHLjNl7BIQN+FY0jja1Z+PowQPM7unzCz0CDmgeNes51NeD9 X-Received: by 2002:a37:542:: with SMTP id 63-v6mr2483384qkf.281.1538595981405; Wed, 03 Oct 2018 12:46:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538595981; cv=none; d=google.com; s=arc-20160816; b=cFFg8Vo2QUSP96+6UBDxjReaZ14V3qHBZjIoh6TFNOD1ChMgBCOpR8j5vnbH57enVW /TcsKVt2Wour+3jdYOBTmgjUnY3MmpotmKSPZgFZfRSsWiBgDl+sIfz9nxmKMrR2zxeN jdae8dAfUgpAfgEDrfi4ugoTUcICVFyjCjx9Ys1qUal0ZykZmNqoq3/xxbwmOS/Sy6ix qyVJLWWG1U6m5m03Lff57WZkX9TeBEpy/1P4oetbLDbeVFhqTQVqW5AAFsURWL6I2MFN wSd4UKwz2dZz/fB3EJ5olon4DO88hOKea1nAGnnqL4089KszWxWecdkJoiRDIp9+urqk lHEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=EpMhGsV8cwvG42VFODqzzhXOEl/LignAAcwP8mXjpag=; b=XI7pDpMAt+NFjeDfl+FvNreKuNsIOpyemuTZhSxj8kv3Akeg0WE0AisaZBgJJyhCZQ I1x9xS+ZN5OX+RVcA0Z9IiqQbj/b0OZ/ZlXipF0SqLgSkqWko9NrCCjD2NgO2MIRn8p/ rdFF2DLV7TA1ytd3FsvOp7wNw/VwreuB6j7ZRsvVMlMwJ61fwoOEEHK7WF9pRYAbYWdj xeTaw6T35KAhFCDYimWfWZ0BXfb69yPDKl7P8EelGUk4E1VznDOCAx2BAqTCfPRT4fzw 10J7lkx7RV1QnH4n+N/FVBLN3bVygX7eXH01iPGNfDUlfRHwAozjKZOwhrj4sGm3jcXC Tuyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BB2F+suf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a4-v6si1473512qvq.35.2018.10.03.12.46.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 03 Oct 2018 12:46:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BB2F+suf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52671 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n6C-0006jV-RJ for patch@linaro.org; Wed, 03 Oct 2018 15:46:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n02-0001eY-SS for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:40:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7n00-000221-KK for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:39:58 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:45777) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g7mzz-0001yD-LX for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:39:56 -0400 Received: by mail-qk1-x72a.google.com with SMTP id m8-v6so4219731qka.12 for ; Wed, 03 Oct 2018 12:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=EpMhGsV8cwvG42VFODqzzhXOEl/LignAAcwP8mXjpag=; b=BB2F+sufg4SL5sBapiNncZVy1CcyF1e60B2ITmSwcFumjSuM2kHVbDlMpyp2Lub7HI uok75SPUheNvghfd9Mj8FqjUQ5eBaC7ipKyhVLmFTOf97nRknd86sz8y8tU8JKlND6xa uyxmXBv6CKXflT8bcH+LN8baYt/2+vnIH5III= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=EpMhGsV8cwvG42VFODqzzhXOEl/LignAAcwP8mXjpag=; b=eyCjvxLhvQCXVec3K7n68TeVLf75ww5MysFme4Ap8hOl3L2mCnMZfkAAqKupQOfEDZ h5RlKqEfwZa6ykBWottU2h/AfVdEjjFBEdJfNMa6ifGSMhhCu+l7OORbQTjOTx0Kg3/z rxLcCWP2kb41ojP5uuOLiIqBH0XeR3SfoQtBo08PQqwRBwUh/n8o14PzreQF/qwFCCJW 8DB9VywennHUvCB+Uh+rYkNbzSvCSk64Mq/q7A0/nSxfhrPLyG9IvvunGc2mO+b2Q1SR GERjhEEdxeE31rqC1bRi7FjoQLeInn3aUa1hLYNeFkmjgpp+52QS7OpKqJQCaSrkhkCG DE3Q== X-Gm-Message-State: ABuFfogBKMMdC3BmMvgiiDzf2LV1+Hj9WYtoy7O7kFOnPF6L3IgFTUJ1 P6aHpII7RbE7LTGpNHxuKhoe1rtLZUCPSg== X-Received: by 2002:a37:8ec1:: with SMTP id q184-v6mr2471734qkd.69.1538595591627; Wed, 03 Oct 2018 12:39:51 -0700 (PDT) Received: from cloudburst.twiddle.net ([172.56.13.153]) by smtp.gmail.com with ESMTPSA id t16-v6sm1284946qth.68.2018.10.03.12.39.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Oct 2018 12:39:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Oct 2018 14:39:27 -0500 Message-Id: <20181003193931.18096-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003193931.18096-1-richard.henderson@linaro.org> References: <20181003193931.18096-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::72a Subject: [Qemu-devel] [PATCH v3 5/9] target/ppc: Convert to HAVE_CMPXCHG128 and HAVE_ATOMIC128 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Emilio G. Cota Signed-off-by: Richard Henderson --- target/ppc/helper.h | 2 +- target/ppc/mem_helper.c | 33 ++++++++++-- target/ppc/translate.c | 115 +++++++++++++++++++++------------------- 3 files changed, 88 insertions(+), 62 deletions(-) -- 2.17.1 diff --git a/target/ppc/helper.h b/target/ppc/helper.h index ef64248bc4..7a1481fd0b 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -800,7 +800,7 @@ DEF_HELPER_4(dscliq, void, env, fprp, fprp, i32) DEF_HELPER_1(tbegin, void, env) DEF_HELPER_FLAGS_1(fixup_thrm, TCG_CALL_NO_RWG, void, env) -#if defined(TARGET_PPC64) && defined(CONFIG_ATOMIC128) +#ifdef TARGET_PPC64 DEF_HELPER_FLAGS_3(lq_le_parallel, TCG_CALL_NO_WG, i64, env, tl, i32) DEF_HELPER_FLAGS_3(lq_be_parallel, TCG_CALL_NO_WG, i64, env, tl, i32) DEF_HELPER_FLAGS_5(stq_le_parallel, TCG_CALL_NO_WG, diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c index 8f0d86d104..a1485fad9b 100644 --- a/target/ppc/mem_helper.c +++ b/target/ppc/mem_helper.c @@ -25,6 +25,7 @@ #include "exec/cpu_ldst.h" #include "tcg.h" #include "internal.h" +#include "qemu/atomic128.h" //#define DEBUG_OP @@ -215,11 +216,15 @@ target_ulong helper_lscbx(CPUPPCState *env, target_ulong addr, uint32_t reg, return i; } -#if defined(TARGET_PPC64) && defined(CONFIG_ATOMIC128) +#ifdef TARGET_PPC64 uint64_t helper_lq_le_parallel(CPUPPCState *env, target_ulong addr, uint32_t opidx) { - Int128 ret = helper_atomic_ldo_le_mmu(env, addr, opidx, GETPC()); + Int128 ret; + + /* We will have raised EXCP_ATOMIC from the translator. */ + assert(HAVE_ATOMIC128); + ret = helper_atomic_ldo_le_mmu(env, addr, opidx, GETPC()); env->retxh = int128_gethi(ret); return int128_getlo(ret); } @@ -227,7 +232,11 @@ uint64_t helper_lq_le_parallel(CPUPPCState *env, target_ulong addr, uint64_t helper_lq_be_parallel(CPUPPCState *env, target_ulong addr, uint32_t opidx) { - Int128 ret = helper_atomic_ldo_be_mmu(env, addr, opidx, GETPC()); + Int128 ret; + + /* We will have raised EXCP_ATOMIC from the translator. */ + assert(HAVE_ATOMIC128); + ret = helper_atomic_ldo_be_mmu(env, addr, opidx, GETPC()); env->retxh = int128_gethi(ret); return int128_getlo(ret); } @@ -235,14 +244,22 @@ uint64_t helper_lq_be_parallel(CPUPPCState *env, target_ulong addr, void helper_stq_le_parallel(CPUPPCState *env, target_ulong addr, uint64_t lo, uint64_t hi, uint32_t opidx) { - Int128 val = int128_make128(lo, hi); + Int128 val; + + /* We will have raised EXCP_ATOMIC from the translator. */ + assert(HAVE_ATOMIC128); + val = int128_make128(lo, hi); helper_atomic_sto_le_mmu(env, addr, val, opidx, GETPC()); } void helper_stq_be_parallel(CPUPPCState *env, target_ulong addr, uint64_t lo, uint64_t hi, uint32_t opidx) { - Int128 val = int128_make128(lo, hi); + Int128 val; + + /* We will have raised EXCP_ATOMIC from the translator. */ + assert(HAVE_ATOMIC128); + val = int128_make128(lo, hi); helper_atomic_sto_be_mmu(env, addr, val, opidx, GETPC()); } @@ -252,6 +269,9 @@ uint32_t helper_stqcx_le_parallel(CPUPPCState *env, target_ulong addr, { bool success = false; + /* We will have raised EXCP_ATOMIC from the translator. */ + assert(HAVE_CMPXCHG128); + if (likely(addr == env->reserve_addr)) { Int128 oldv, cmpv, newv; @@ -271,6 +291,9 @@ uint32_t helper_stqcx_be_parallel(CPUPPCState *env, target_ulong addr, { bool success = false; + /* We will have raised EXCP_ATOMIC from the translator. */ + assert(HAVE_CMPXCHG128); + if (likely(addr == env->reserve_addr)) { Int128 oldv, cmpv, newv; diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 881743571b..4e59dd5f42 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -33,6 +33,7 @@ #include "trace-tcg.h" #include "exec/translator.h" #include "exec/log.h" +#include "qemu/atomic128.h" #define CPU_SINGLE_STEP 0x1 @@ -2654,22 +2655,22 @@ static void gen_lq(DisasContext *ctx) hi = cpu_gpr[rd]; if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { -#ifdef CONFIG_ATOMIC128 - TCGv_i32 oi = tcg_temp_new_i32(); - if (ctx->le_mode) { - tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ, ctx->mem_idx)); - gen_helper_lq_le_parallel(lo, cpu_env, EA, oi); + if (HAVE_ATOMIC128) { + TCGv_i32 oi = tcg_temp_new_i32(); + if (ctx->le_mode) { + tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ, ctx->mem_idx)); + gen_helper_lq_le_parallel(lo, cpu_env, EA, oi); + } else { + tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ, ctx->mem_idx)); + gen_helper_lq_be_parallel(lo, cpu_env, EA, oi); + } + tcg_temp_free_i32(oi); + tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUPPCState, retxh)); } else { - tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ, ctx->mem_idx)); - gen_helper_lq_be_parallel(lo, cpu_env, EA, oi); + /* Restart with exclusive lock. */ + gen_helper_exit_atomic(cpu_env); + ctx->base.is_jmp = DISAS_NORETURN; } - tcg_temp_free_i32(oi); - tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUPPCState, retxh)); -#else - /* Restart with exclusive lock. */ - gen_helper_exit_atomic(cpu_env); - ctx->base.is_jmp = DISAS_NORETURN; -#endif } else if (ctx->le_mode) { tcg_gen_qemu_ld_i64(lo, EA, ctx->mem_idx, MO_LEQ); gen_addr_add(ctx, EA, EA, 8); @@ -2805,21 +2806,21 @@ static void gen_std(DisasContext *ctx) hi = cpu_gpr[rs]; if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { -#ifdef CONFIG_ATOMIC128 - TCGv_i32 oi = tcg_temp_new_i32(); - if (ctx->le_mode) { - tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ, ctx->mem_idx)); - gen_helper_stq_le_parallel(cpu_env, EA, lo, hi, oi); + if (HAVE_ATOMIC128) { + TCGv_i32 oi = tcg_temp_new_i32(); + if (ctx->le_mode) { + tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ, ctx->mem_idx)); + gen_helper_stq_le_parallel(cpu_env, EA, lo, hi, oi); + } else { + tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ, ctx->mem_idx)); + gen_helper_stq_be_parallel(cpu_env, EA, lo, hi, oi); + } + tcg_temp_free_i32(oi); } else { - tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ, ctx->mem_idx)); - gen_helper_stq_be_parallel(cpu_env, EA, lo, hi, oi); + /* Restart with exclusive lock. */ + gen_helper_exit_atomic(cpu_env); + ctx->base.is_jmp = DISAS_NORETURN; } - tcg_temp_free_i32(oi); -#else - /* Restart with exclusive lock. */ - gen_helper_exit_atomic(cpu_env); - ctx->base.is_jmp = DISAS_NORETURN; -#endif } else if (ctx->le_mode) { tcg_gen_qemu_st_i64(lo, EA, ctx->mem_idx, MO_LEQ); gen_addr_add(ctx, EA, EA, 8); @@ -3404,26 +3405,26 @@ static void gen_lqarx(DisasContext *ctx) hi = cpu_gpr[rd]; if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { -#ifdef CONFIG_ATOMIC128 - TCGv_i32 oi = tcg_temp_new_i32(); - if (ctx->le_mode) { - tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ | MO_ALIGN_16, - ctx->mem_idx)); - gen_helper_lq_le_parallel(lo, cpu_env, EA, oi); + if (HAVE_ATOMIC128) { + TCGv_i32 oi = tcg_temp_new_i32(); + if (ctx->le_mode) { + tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ | MO_ALIGN_16, + ctx->mem_idx)); + gen_helper_lq_le_parallel(lo, cpu_env, EA, oi); + } else { + tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ | MO_ALIGN_16, + ctx->mem_idx)); + gen_helper_lq_be_parallel(lo, cpu_env, EA, oi); + } + tcg_temp_free_i32(oi); + tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUPPCState, retxh)); } else { - tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ | MO_ALIGN_16, - ctx->mem_idx)); - gen_helper_lq_be_parallel(lo, cpu_env, EA, oi); + /* Restart with exclusive lock. */ + gen_helper_exit_atomic(cpu_env); + ctx->base.is_jmp = DISAS_NORETURN; + tcg_temp_free(EA); + return; } - tcg_temp_free_i32(oi); - tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUPPCState, retxh)); -#else - /* Restart with exclusive lock. */ - gen_helper_exit_atomic(cpu_env); - ctx->base.is_jmp = DISAS_NORETURN; - tcg_temp_free(EA); - return; -#endif } else if (ctx->le_mode) { tcg_gen_qemu_ld_i64(lo, EA, ctx->mem_idx, MO_LEQ | MO_ALIGN_16); tcg_gen_mov_tl(cpu_reserve, EA); @@ -3461,20 +3462,22 @@ static void gen_stqcx_(DisasContext *ctx) hi = cpu_gpr[rs]; if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { - TCGv_i32 oi = tcg_const_i32(DEF_MEMOP(MO_Q) | MO_ALIGN_16); -#ifdef CONFIG_ATOMIC128 - if (ctx->le_mode) { - gen_helper_stqcx_le_parallel(cpu_crf[0], cpu_env, EA, lo, hi, oi); + if (HAVE_CMPXCHG128) { + TCGv_i32 oi = tcg_const_i32(DEF_MEMOP(MO_Q) | MO_ALIGN_16); + if (ctx->le_mode) { + gen_helper_stqcx_le_parallel(cpu_crf[0], cpu_env, + EA, lo, hi, oi); + } else { + gen_helper_stqcx_be_parallel(cpu_crf[0], cpu_env, + EA, lo, hi, oi); + } + tcg_temp_free_i32(oi); } else { - gen_helper_stqcx_le_parallel(cpu_crf[0], cpu_env, EA, lo, hi, oi); + /* Restart with exclusive lock. */ + gen_helper_exit_atomic(cpu_env); + ctx->base.is_jmp = DISAS_NORETURN; } -#else - /* Restart with exclusive lock. */ - gen_helper_exit_atomic(cpu_env); - ctx->base.is_jmp = DISAS_NORETURN; -#endif tcg_temp_free(EA); - tcg_temp_free_i32(oi); } else { TCGLabel *lab_fail = gen_new_label(); TCGLabel *lab_over = gen_new_label(); From patchwork Wed Oct 3 19:39:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148078 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp59533lji; Wed, 3 Oct 2018 12:43:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV61/m8dN9YB86yCendO47voKhkzbbNnmehHu+IkVigH6yo/4QH0Xg58mWv79ytoy+EDfPxlJ X-Received: by 2002:a37:9404:: with SMTP id w4-v6mr2509626qkd.50.1538595804934; Wed, 03 Oct 2018 12:43:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538595804; cv=none; d=google.com; s=arc-20160816; b=moBuFrXmo+0xVvrLEXHt/if0x8iRWMWmOl0VmRiulDo79qUdU6luyR0m50Ws3GGlum z272dMmf/OKg/ihhseLAEOsRskZXiK4hsE8iFZUaZCbB/4/uDBooMsPQJdTcmaeBFnpx m5iyJoHHN5zPz0rlbJhLdwksZmCCRIcypdRjFL3XObs11+yq8vVKGMhZGzFN7I1cSPY/ cCnGaV8zBLFPUU2fzGCHbWryZ+nSLnWXeTh6bt7OCl4Vsouc2y6oWJHVQPK1aDjCQ2H2 MrQxO9aFzw+FE0fHMq5Xq6tD9rpDQt1REq+a8EbgRb+LNPNm1oMgkEO3oaBPLsVdGQgV l1VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=KiWskst90wZGtn6AYxyVn31hN9IeZKnbPpwTeqX/e6w=; b=AfWprnajjuLDW3r10L1xTcwdXFrmHx8DJNEtfYvs1+7hcAh+KtEamT7m5SHzGbftiT uKD4WR6tc1s59luqyg6ZtJYMoaNMDMzYdF4IZm1cbXoDSrqR14LIe2oZfVTu5NCoOlIV w8ZSzXZ7cbg47lvEHZbVzZ/XdNGJWEJWdMT8SQ/PvPJyX+qxKgEvpF8dW19B02uAT/T9 zCkBO+dck4B5Nr9wvwd3EceGLHvp9TCKEM2PI8ceIYpvo5Og0EdVXOUl9o4w4ePX3Jhc M8mt74xPnLtzuNgeA9wcowVWVicmzwe78HYFe7vkcUGi+EIbF/XHRxPK6swoeFTpZ7hc iiug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Q47MkGXS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l11-v6si1547868qkh.314.2018.10.03.12.43.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 03 Oct 2018 12:43:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Q47MkGXS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n3M-0004sr-B4 for patch@linaro.org; Wed, 03 Oct 2018 15:43:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59422) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n03-0001ec-0u for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:40:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7n00-00022h-UQ for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:39:58 -0400 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]:42539) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g7n00-0001zy-AD for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:39:56 -0400 Received: by mail-qt1-x842.google.com with SMTP id z8-v6so7282713qto.9 for ; Wed, 03 Oct 2018 12:39:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KiWskst90wZGtn6AYxyVn31hN9IeZKnbPpwTeqX/e6w=; b=Q47MkGXSrceOCXOf4HTrbr7qhZgegQ/s7AYG2yGDffUjYWq82UEdH4gWFFeevMC5vb 7sRWRBaEZreDVnrCqPiAW6kQzmZkxw4EMBlBfBf89VHSfqv3+sKreQX0ILqW+XaVWWpN 2/guZzsiNf2KmKXxErud8gf1IEsP0DBXprmnw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KiWskst90wZGtn6AYxyVn31hN9IeZKnbPpwTeqX/e6w=; b=ludCQ+yoAr55MnjppllLTtNe5eJ71la2NM7GnzWnfhMa2icbq5neWZpdlA+GhI6JKY M9rObA/DjetGLYqG8LaCPiDqRDKxSaARCzMYAYTofdKaDWZLrC019kBeF3LBO2rpH6Hl /ylWZg5k2IPE9YsweiwSgcfGjaNp1UmNbElwttVMt4QH0Lj2xTAAkKVmJZ+RdGYD+pR5 ufrQ8dmyhKXFOZvc9HiLD09QVbMzcEucGoy2vu47zZoOcs22ByiBRh9XqHF81TgTJHja vpi9SVLl02xyn5BNKuDpmtIMoS5NJu4XF/mHniONlTh22ghDRyBKghfVHVbzBRiDvN2l WjYA== X-Gm-Message-State: ABuFfogXjZtdPJIOXj7cFvZt5Gwv1NmTaYIbwfR/Al/rLYcO1uxB3XPj 5hwZYGyElENXmoLd8nPEx2WmgmsRZvWKbg== X-Received: by 2002:a0c:b91b:: with SMTP id u27-v6mr2628966qvf.18.1538595593820; Wed, 03 Oct 2018 12:39:53 -0700 (PDT) Received: from cloudburst.twiddle.net ([172.56.13.153]) by smtp.gmail.com with ESMTPSA id t16-v6sm1284946qth.68.2018.10.03.12.39.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Oct 2018 12:39:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Oct 2018 14:39:28 -0500 Message-Id: <20181003193931.18096-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003193931.18096-1-richard.henderson@linaro.org> References: <20181003193931.18096-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::842 Subject: [Qemu-devel] [PATCH v3 6/9] target/s390x: Convert to HAVE_CMPXCHG128 and HAVE_ATOMIC128 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-s390x@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: qemu-s390x@nongnu.org Signed-off-by: Richard Henderson --- target/s390x/mem_helper.c | 92 +++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 51 deletions(-) -- 2.17.1 Reviewed-by: David Hildenbrand diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index bacae4f503..e106f61b4e 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -25,6 +25,7 @@ #include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "qemu/int128.h" +#include "qemu/atomic128.h" #if !defined(CONFIG_USER_ONLY) #include "hw/s390x/storage-keys.h" @@ -1389,7 +1390,7 @@ static void do_cdsg(CPUS390XState *env, uint64_t addr, bool fail; if (parallel) { -#ifndef CONFIG_ATOMIC128 +#if !HAVE_CMPXCHG128 cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); #else int mem_idx = cpu_mmu_index(env, false); @@ -1435,9 +1436,7 @@ void HELPER(cdsg_parallel)(CPUS390XState *env, uint64_t addr, static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, uint64_t a2, bool parallel) { -#if !defined(CONFIG_USER_ONLY) || defined(CONFIG_ATOMIC128) uint32_t mem_idx = cpu_mmu_index(env, false); -#endif uintptr_t ra = GETPC(); uint32_t fc = extract32(env->regs[0], 0, 8); uint32_t sc = extract32(env->regs[0], 8, 8); @@ -1465,18 +1464,20 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, probe_write(env, a2, 0, mem_idx, ra); #endif - /* Note that the compare-and-swap is atomic, and the store is atomic, but - the complete operation is not. Therefore we do not need to assert serial - context in order to implement this. That said, restart early if we can't - support either operation that is supposed to be atomic. */ + /* + * Note that the compare-and-swap is atomic, and the store is atomic, + * but the complete operation is not. Therefore we do not need to + * assert serial context in order to implement this. That said, + * restart early if we can't support either operation that is supposed + * to be atomic. + */ if (parallel) { - int mask = 0; -#if !defined(CONFIG_ATOMIC64) - mask = -8; -#elif !defined(CONFIG_ATOMIC128) - mask = -16; + uint32_t max = 2; +#ifdef CONFIG_ATOMIC64 + max = 3; #endif - if (((4 << fc) | (1 << sc)) & mask) { + if ((HAVE_CMPXCHG128 ? 0 : fc + 2 > max) || + (HAVE_ATOMIC128 ? 0 : sc > max)) { cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); } } @@ -1546,16 +1547,7 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, Int128 cv = int128_make128(env->regs[r3 + 1], env->regs[r3]); Int128 ov; - if (parallel) { -#ifdef CONFIG_ATOMIC128 - TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); - ov = helper_atomic_cmpxchgo_be_mmu(env, a1, cv, nv, oi, ra); - cc = !int128_eq(ov, cv); -#else - /* Note that we asserted !parallel above. */ - g_assert_not_reached(); -#endif - } else { + if (!parallel) { uint64_t oh = cpu_ldq_data_ra(env, a1 + 0, ra); uint64_t ol = cpu_ldq_data_ra(env, a1 + 8, ra); @@ -1567,6 +1559,13 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, cpu_stq_data_ra(env, a1 + 0, int128_gethi(nv), ra); cpu_stq_data_ra(env, a1 + 8, int128_getlo(nv), ra); + } else if (HAVE_CMPXCHG128) { + TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); + ov = helper_atomic_cmpxchgo_be_mmu(env, a1, cv, nv, oi, ra); + cc = !int128_eq(ov, cv); + } else { + /* Note that we asserted !parallel above. */ + g_assert_not_reached(); } env->regs[r3 + 0] = int128_gethi(ov); @@ -1596,18 +1595,16 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, cpu_stq_data_ra(env, a2, svh, ra); break; case 4: - if (parallel) { -#ifdef CONFIG_ATOMIC128 + if (!parallel) { + cpu_stq_data_ra(env, a2 + 0, svh, ra); + cpu_stq_data_ra(env, a2 + 8, svl, ra); + } else if (HAVE_ATOMIC128) { TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); Int128 sv = int128_make128(svl, svh); helper_atomic_sto_be_mmu(env, a2, sv, oi, ra); -#else + } else { /* Note that we asserted !parallel above. */ g_assert_not_reached(); -#endif - } else { - cpu_stq_data_ra(env, a2 + 0, svh, ra); - cpu_stq_data_ra(env, a2 + 8, svl, ra); } break; default: @@ -2105,21 +2102,18 @@ static uint64_t do_lpq(CPUS390XState *env, uint64_t addr, bool parallel) uintptr_t ra = GETPC(); uint64_t hi, lo; - if (parallel) { -#ifndef CONFIG_ATOMIC128 - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); -#else + if (!parallel) { + check_alignment(env, addr, 16, ra); + hi = cpu_ldq_data_ra(env, addr + 0, ra); + lo = cpu_ldq_data_ra(env, addr + 8, ra); + } else if (HAVE_ATOMIC128) { int mem_idx = cpu_mmu_index(env, false); TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); Int128 v = helper_atomic_ldo_be_mmu(env, addr, oi, ra); hi = int128_gethi(v); lo = int128_getlo(v); -#endif } else { - check_alignment(env, addr, 16, ra); - - hi = cpu_ldq_data_ra(env, addr + 0, ra); - lo = cpu_ldq_data_ra(env, addr + 8, ra); + cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); } env->retxl = lo; @@ -2142,21 +2136,17 @@ static void do_stpq(CPUS390XState *env, uint64_t addr, { uintptr_t ra = GETPC(); - if (parallel) { -#ifndef CONFIG_ATOMIC128 - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); -#else - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); - - Int128 v = int128_make128(low, high); - helper_atomic_sto_be_mmu(env, addr, v, oi, ra); -#endif - } else { + if (!parallel) { check_alignment(env, addr, 16, ra); - cpu_stq_data_ra(env, addr + 0, high, ra); cpu_stq_data_ra(env, addr + 8, low, ra); + } else if (HAVE_ATOMIC128) { + int mem_idx = cpu_mmu_index(env, false); + TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); + Int128 v = int128_make128(low, high); + helper_atomic_sto_be_mmu(env, addr, v, oi, ra); + } else { + cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); } } From patchwork Wed Oct 3 19:39:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148080 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp61715lji; Wed, 3 Oct 2018 12:45:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV60yFz10OUuGn+LuzlB3i9fsT3b+16c/nWkB559mOAytbUtGPUHc4IAtNybP40TISiD4/MwA X-Received: by 2002:a0c:869c:: with SMTP id 28-v6mr2589294qvf.92.1538595956639; Wed, 03 Oct 2018 12:45:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538595956; cv=none; d=google.com; s=arc-20160816; b=mMlfXvPrRKzZ9zfrfnx1afXoLD9gb4qdvNnGhiGZmmxvz4o60YWzO8grEbLSu+A6a9 kF2lQjc3FDa0+XBFyveJIMKzQhcNxV4k6U7oZBN5p+7Qc3EZ/fZQ7co5KPAl0Gi/t0iT X42E2vClbpcvQU+kjNvsxppFP09Xc5lcV7q8p1WG8EPgWs30o1CWdaJ9zczkzPrUdmY7 4gW6fxsQX2dd5F4RD+KyT8HlwBrk721ztOa1xAY9uq8gdHuXRoT/Sxsd/VXP/+iZYapu aRipyoExuKdVutmpKus4HJw1eWQKs9i5BUd8a/Xu30sioYZK8fkt9Rn43+jS0Dj/k55R FtZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=zN218yvlXmKBp21LVz1X2J8y2SIG9i2yZ8epOdLSXSU=; b=IpQuXLkFzxDk7fpPTbYJFi2ZHG/9UKeqj2JiNXiSEOF9peBVA5mudrRzIi+mcT4Jls TlzuAbC5/k0H5lngCJJUEXgh8iojq+fICT+5phRn89XMYaspiGLWCjCSVE3/FMLGpHye MXrSOjUemS8lA9zT/lU+b1R5+XX+f0b8N5dDYSAXK0briITbL75N8/mKuVVRb7Cd7xdx tQOl7Fs/XgweLPoQKAOfYo5YznkV8VG0N04iI8ZtG1pnWmLRYfMIKbw8HVCzD1xkXpSv OG1qcdvHmjaEA3dyji5k/hedp3yblb7By3II7CuefnNIyfyZLsqqTfAYS6M1YUUpfr3N ITNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="f0V/Bk8l"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z16-v6si752127qtq.23.2018.10.03.12.45.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 03 Oct 2018 12:45:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="f0V/Bk8l"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n5o-0006hO-33 for patch@linaro.org; Wed, 03 Oct 2018 15:45:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n03-0001ez-FB for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:40:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7n01-00023S-BL for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:39:59 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:44867) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g7n00-00021o-T8 for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:39:57 -0400 Received: by mail-qk1-x72a.google.com with SMTP id y8-v6so4220453qka.11 for ; Wed, 03 Oct 2018 12:39:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zN218yvlXmKBp21LVz1X2J8y2SIG9i2yZ8epOdLSXSU=; b=f0V/Bk8ldmwynQgFlJdLu0EF+/d/KCTkdfl7RMbr0Lrgi/pByERthf9K744Tzjnd3W N9xNfW7oqZyzSKZQA5yHLeBVVY3t0ew4w4ncWQc+hJc5ONGPDGi44+E0yqF21AwdP9gR /LE2ibxaYh8HxnAkDsALJUDil3ez/fnFs7YTw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zN218yvlXmKBp21LVz1X2J8y2SIG9i2yZ8epOdLSXSU=; b=R1PoEwGsSbBBfiDSrzpsKwUEZkS4uNyI6staB9b3pG65HyKbUXBRuyyCEHDzS62Y8D VJ6Y0g7FuA1nZZ3Nc5dKtWgvA+poJQvN4r0jJRqXaCc6vv/BhjTktsXrnxqcqo7eBHai lOGsU5/mvqfdhWp7KMnBsKrLqDjkhKeK+BhnrylkCWEHWOOxVTwKZeY1DkQubnofc53l plsdzzjDD09QUPaTtno/jg+M2fArpX6iab3wtB+cQd1HOqq8+AhOivqW+h3vy7ZR8HaC oVCKhIB/lLulU8LTUjHlZM3aHMjEhJb++AKfDlkUGXi6TymaxU2kgbhMngO+KlwE3mjV 8UKQ== X-Gm-Message-State: ABuFfoi1AAiFW0r93nvWM207DhT1bQL6epWK+o+Bf6OC1XdZiPy7DaMT 3GvMuU70+Byeth3AuLCniHI3WfMSqrZItA== X-Received: by 2002:a37:2a5b:: with SMTP id q88-v6mr2346565qkh.287.1538595595820; Wed, 03 Oct 2018 12:39:55 -0700 (PDT) Received: from cloudburst.twiddle.net ([172.56.13.153]) by smtp.gmail.com with ESMTPSA id t16-v6sm1284946qth.68.2018.10.03.12.39.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Oct 2018 12:39:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Oct 2018 14:39:29 -0500 Message-Id: <20181003193931.18096-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003193931.18096-1-richard.henderson@linaro.org> References: <20181003193931.18096-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::72a Subject: [Qemu-devel] [PATCH v3 7/9] target/s390x: Split do_cdsg, do_lpq, do_stpq X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-s390x@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: qemu-s390x@nongnu.org Signed-off-by: Richard Henderson --- target/s390x/mem_helper.c | 128 ++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 67 deletions(-) -- 2.17.1 Reviewed-by: David Hildenbrand diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index e106f61b4e..b5858d2fa2 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1380,57 +1380,58 @@ uint32_t HELPER(trXX)(CPUS390XState *env, uint32_t r1, uint32_t r2, return cc; } -static void do_cdsg(CPUS390XState *env, uint64_t addr, - uint32_t r1, uint32_t r3, bool parallel) +void HELPER(cdsg)(CPUS390XState *env, uint64_t addr, + uint32_t r1, uint32_t r3) { uintptr_t ra = GETPC(); Int128 cmpv = int128_make128(env->regs[r1 + 1], env->regs[r1]); Int128 newv = int128_make128(env->regs[r3 + 1], env->regs[r3]); Int128 oldv; + uint64_t oldh, oldl; bool fail; - if (parallel) { -#if !HAVE_CMPXCHG128 - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); -#else - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); - oldv = helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, oi, ra); - fail = !int128_eq(oldv, cmpv); -#endif - } else { - uint64_t oldh, oldl; + check_alignment(env, addr, 16, ra); - check_alignment(env, addr, 16, ra); + oldh = cpu_ldq_data_ra(env, addr + 0, ra); + oldl = cpu_ldq_data_ra(env, addr + 8, ra); - oldh = cpu_ldq_data_ra(env, addr + 0, ra); - oldl = cpu_ldq_data_ra(env, addr + 8, ra); - - oldv = int128_make128(oldl, oldh); - fail = !int128_eq(oldv, cmpv); - if (fail) { - newv = oldv; - } - - cpu_stq_data_ra(env, addr + 0, int128_gethi(newv), ra); - cpu_stq_data_ra(env, addr + 8, int128_getlo(newv), ra); + oldv = int128_make128(oldl, oldh); + fail = !int128_eq(oldv, cmpv); + if (fail) { + newv = oldv; } + cpu_stq_data_ra(env, addr + 0, int128_gethi(newv), ra); + cpu_stq_data_ra(env, addr + 8, int128_getlo(newv), ra); + env->cc_op = fail; env->regs[r1] = int128_gethi(oldv); env->regs[r1 + 1] = int128_getlo(oldv); } -void HELPER(cdsg)(CPUS390XState *env, uint64_t addr, - uint32_t r1, uint32_t r3) -{ - do_cdsg(env, addr, r1, r3, false); -} - void HELPER(cdsg_parallel)(CPUS390XState *env, uint64_t addr, uint32_t r1, uint32_t r3) { - do_cdsg(env, addr, r1, r3, true); + uintptr_t ra = GETPC(); + Int128 cmpv = int128_make128(env->regs[r1 + 1], env->regs[r1]); + Int128 newv = int128_make128(env->regs[r3 + 1], env->regs[r3]); + int mem_idx; + TCGMemOpIdx oi; + Int128 oldv; + bool fail; + + if (!HAVE_CMPXCHG128) { + cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); + } + + mem_idx = cpu_mmu_index(env, false); + oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); + oldv = helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, oi, ra); + fail = !int128_eq(oldv, cmpv); + + env->cc_op = fail; + env->regs[r1] = int128_gethi(oldv); + env->regs[r1 + 1] = int128_getlo(oldv); } static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, @@ -2097,16 +2098,25 @@ uint64_t HELPER(lra)(CPUS390XState *env, uint64_t addr) #endif /* load pair from quadword */ -static uint64_t do_lpq(CPUS390XState *env, uint64_t addr, bool parallel) +uint64_t HELPER(lpq)(CPUS390XState *env, uint64_t addr) { uintptr_t ra = GETPC(); uint64_t hi, lo; - if (!parallel) { - check_alignment(env, addr, 16, ra); - hi = cpu_ldq_data_ra(env, addr + 0, ra); - lo = cpu_ldq_data_ra(env, addr + 8, ra); - } else if (HAVE_ATOMIC128) { + check_alignment(env, addr, 16, ra); + hi = cpu_ldq_data_ra(env, addr + 0, ra); + lo = cpu_ldq_data_ra(env, addr + 8, ra); + + env->retxl = lo; + return hi; +} + +uint64_t HELPER(lpq_parallel)(CPUS390XState *env, uint64_t addr) +{ + uintptr_t ra = GETPC(); + uint64_t hi, lo; + + if (HAVE_ATOMIC128) { int mem_idx = cpu_mmu_index(env, false); TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); Int128 v = helper_atomic_ldo_be_mmu(env, addr, oi, ra); @@ -2120,27 +2130,23 @@ static uint64_t do_lpq(CPUS390XState *env, uint64_t addr, bool parallel) return hi; } -uint64_t HELPER(lpq)(CPUS390XState *env, uint64_t addr) -{ - return do_lpq(env, addr, false); -} - -uint64_t HELPER(lpq_parallel)(CPUS390XState *env, uint64_t addr) -{ - return do_lpq(env, addr, true); -} - /* store pair to quadword */ -static void do_stpq(CPUS390XState *env, uint64_t addr, - uint64_t low, uint64_t high, bool parallel) +void HELPER(stpq)(CPUS390XState *env, uint64_t addr, + uint64_t low, uint64_t high) { uintptr_t ra = GETPC(); - if (!parallel) { - check_alignment(env, addr, 16, ra); - cpu_stq_data_ra(env, addr + 0, high, ra); - cpu_stq_data_ra(env, addr + 8, low, ra); - } else if (HAVE_ATOMIC128) { + check_alignment(env, addr, 16, ra); + cpu_stq_data_ra(env, addr + 0, high, ra); + cpu_stq_data_ra(env, addr + 8, low, ra); +} + +void HELPER(stpq_parallel)(CPUS390XState *env, uint64_t addr, + uint64_t low, uint64_t high) +{ + uintptr_t ra = GETPC(); + + if (HAVE_ATOMIC128) { int mem_idx = cpu_mmu_index(env, false); TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); Int128 v = int128_make128(low, high); @@ -2150,18 +2156,6 @@ static void do_stpq(CPUS390XState *env, uint64_t addr, } } -void HELPER(stpq)(CPUS390XState *env, uint64_t addr, - uint64_t low, uint64_t high) -{ - do_stpq(env, addr, low, high, false); -} - -void HELPER(stpq_parallel)(CPUS390XState *env, uint64_t addr, - uint64_t low, uint64_t high) -{ - do_stpq(env, addr, low, high, true); -} - /* Execute instruction. This instruction executes an insn modified with the contents of r1. It does not change the executed instruction in memory; it does not change the program counter. From patchwork Wed Oct 3 19:39:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148075 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp58361lji; Wed, 3 Oct 2018 12:41:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV61NAGY9YQdQ1eq8yoWFmoH5YavP7i4VTBPdDJFzdT3KYIGxotDbhi3ATe5ohIAhzupntmKD X-Received: by 2002:aed:2337:: with SMTP id h52-v6mr2676044qtc.316.1538595712177; Wed, 03 Oct 2018 12:41:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538595712; cv=none; d=google.com; s=arc-20160816; b=pz7yQvyXjz6JZyP/hFKbvU/SbapdGR9luagoqgdSDkt+BjfszIH/rWGoL6TaNuUE4R hRdd6KM7FGhB9+60RexEv3hs30+v+4S6hnv08uZS0r2U4T1KkgQ3uRurT4d/BIBNTwBO FIRImsAIpyl2eWsormzNaka0tXlm3KZM1nOT2zU2I9YLe2ICH1imfuVXT3GOO4PDnbnB gBBtAypWAPZlT4excEaajgk8hoxwjX7QeCXWHztc0OmsWeyLGHuxna3AXp7gdHKxowvp c56xBjnH3JESovkF14J9PuDSv1NhMz9sHR8q7NvOIn9S689Yq9eljzduU7mtO1LVNU3u QZxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=JAldEmKZ57baz29qTLPDVIF0nqXzK08T0l7+NIorDqg=; b=yQ7h8vrWUvftIUQVQ5XSvy7VnCyGU4YIS02QNOVSD+4nLKWODQweATH/UHKfNDHlnG 5hz1Z4CHtMWoD0XYghifk8krRcquIZ/yhfB9KKXfOP7LA5Ts440+OdwoJGZlN6WvSC3m 38YfNZZKIwzmX2tYukx0SVxSW52CO/LHDnFl7i6PkkxrSDXXfEI0RzOj6K42MH24hfz8 2CsD4hwI25R+OpF9bd83XvEXZ6sYJIpgrUo6QywmtFOM7YEy2nqMGT9HeSCtzqsRwnq3 wuedcW8/8BAvzTEfkPJKo6mdQ5gW15IUguo1aO3Evw7lofS4P6GYyM3m4ubGFdslpnvC 6WQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=S9UFJdeu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x69-v6si1553926qkx.12.2018.10.03.12.41.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 03 Oct 2018 12:41:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=S9UFJdeu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52647 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n1r-0002fm-GN for patch@linaro.org; Wed, 03 Oct 2018 15:41:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n05-0001gD-00 for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:40:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7n03-00025y-A0 for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:40:00 -0400 Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]:33366) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g7n02-00024f-Tk for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:39:59 -0400 Received: by mail-qt1-x831.google.com with SMTP id q40-v6so7323292qte.0 for ; Wed, 03 Oct 2018 12:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JAldEmKZ57baz29qTLPDVIF0nqXzK08T0l7+NIorDqg=; b=S9UFJdeuPrGGeDfeyqfgLFum6sPoaLYgW0dB+xcPxZCIGbixhXB6MU+MjEsIHFePlo yF4Hc+yZQtfnpNEQeRfKvu+iWcBMoMXhKECFyyryUfonzyiFNIkbSbt/PoL8Fzb1ukmu Saxnvy4J12DLdO+xI0t9aBvZQXsSjs5yKlBok= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JAldEmKZ57baz29qTLPDVIF0nqXzK08T0l7+NIorDqg=; b=AT5/SElCU22sDATikwxZzFHo0RuMyCKazwGS/9SQZQpFUpF4dD9U6ztTZzdQZhB6Vz iONiNK8H82LsCiuOZm0ltsXS4J5XTVBC0qtgPU0fME24ugNISqpV0Wd4lqHReuZreTop U1OQcL10AwaLipXQJ76VyxqaNatnHjNGK2FzI5FxNY/qG6elyaVnZjXpM/OoIxQRS8W2 tIci8+aHk0xHlqN6AkT/+m97vyUWAsVPuJ3RO9v23Q3/pT8g+ELMI478LXvGoEO0RMn0 Oa1gy8JgOzmaWgUTxAdZ0HyaI6EQe/tsBBLmdLY9aE0fjyZWtPJ8F4rl0QIWhLL7u6aO a7/g== X-Gm-Message-State: ABuFfojXe92a4qdbLhwXGHEU+jAHEP1D5SGVbypuXiU6pN7KdAgIjPzt rWMczU3Pg5VdyQhvrdKvlyACErctOS0Bng== X-Received: by 2002:ac8:5293:: with SMTP id s19-v6mr2617731qtn.336.1538595597826; Wed, 03 Oct 2018 12:39:57 -0700 (PDT) Received: from cloudburst.twiddle.net ([172.56.13.153]) by smtp.gmail.com with ESMTPSA id t16-v6sm1284946qth.68.2018.10.03.12.39.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Oct 2018 12:39:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Oct 2018 14:39:30 -0500 Message-Id: <20181003193931.18096-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003193931.18096-1-richard.henderson@linaro.org> References: <20181003193931.18096-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::831 Subject: [Qemu-devel] [PATCH v3 8/9] target/s390x: Skip wout, cout helpers if op helper does not return X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-s390x@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When op raises an exception, it may not have initialized the output temps that would be written back by wout or cout. Cc: qemu-s390x@nongnu.org Signed-off-by: Richard Henderson --- target/s390x/translate.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 2.17.1 Reviewed-by: David Hildenbrand diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 7363aabf3a..7fad3ad8e9 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -6164,11 +6164,13 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s) if (insn->help_op) { ret = insn->help_op(s, &o); } - if (insn->help_wout) { - insn->help_wout(s, &f, &o); - } - if (insn->help_cout) { - insn->help_cout(s, &o); + if (ret != DISAS_NORETURN) { + if (insn->help_wout) { + insn->help_wout(s, &f, &o); + } + if (insn->help_cout) { + insn->help_cout(s, &o); + } } /* Free any temporaries created by the helpers. */ From patchwork Wed Oct 3 19:39:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148084 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp65404lji; Wed, 3 Oct 2018 12:50:20 -0700 (PDT) X-Google-Smtp-Source: ACcGV61K/T1mTK+Z27+3GhvTvAqohmmQUVkt7qWqhJXEzLRh34kvDlLK7WgKt8OHE128vktfvNIw X-Received: by 2002:a0c:d788:: with SMTP id z8-v6mr2645160qvi.71.1538596220768; Wed, 03 Oct 2018 12:50:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538596220; cv=none; d=google.com; s=arc-20160816; b=xXunSIRug1BiEfMNTDrH++NPWaCnRw17V9Roit/4YNl5xMUmRbLqidNzhReSad7Thz 0bz79zvpmriQLvHZXiIDCMfwXlTkDiNHFwwOHhW/svY7fZGDubNVZoTYob+kik5Hyke+ T7Wijj9+8O0xe3J131JUMh8NcF2h/grEl1eIv9UbeAZ8iEyOWI+wfNcGROFdNU39XFbX 554a7QRdmXPThDY0fpnzfex5uTZfe3svM5fqbjUbdu8UZhUnAkJewevZoxoHoS5MvUnu eX8PzzoABQweqF2rNHbwRjDKeGWZDaNRh8DBFQpGGhMrfwNtVX5HO5fldQY8dmNtLoC8 M2FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=g7N3N+A91Q9wKX2V+YBrSR0niQNnDAXh8g6joZORqms=; b=X07KiRTQZHWRsh+QmMW9LnG4DBiKMOpCjBOggx0F4XU7bxy/iINxzkjmLMqXeH8ea5 pui0drIZFujb6j7JLm283Mz1wwXQTGKPOSLjUzQXsV+Wg3rrhr1M1mu35qH7U+gbWCmt /Bv6U+y/2nK6UXswo4v+aa6jvy+qJ5rLGU2P5gY/ukxHNtBuQrtDOMEVSWwNrlcxbMNm RxsXPNABIfvJo31zi581H4stYRjSoAb+mo1JYs2i/JEvWs10NeRqIQZ1lvmIh6xHHiI4 sKCS3Z8OXlUS9QI+GXCQWtEmV+6PPwH38iS3ycHF08LsX8WolTnwXRguL6kkcvg6EAmN PrtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RX7khVBz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z4-v6si573876qvg.133.2018.10.03.12.50.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 03 Oct 2018 12:50:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RX7khVBz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52690 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7nA4-0001TS-8g for patch@linaro.org; Wed, 03 Oct 2018 15:50:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7n08-0001gT-DS for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:40:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7n05-00028I-Ha for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:40:04 -0400 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]:45488) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g7n05-000273-3o for qemu-devel@nongnu.org; Wed, 03 Oct 2018 15:40:01 -0400 Received: by mail-qt1-x834.google.com with SMTP id l2-v6so7264780qtr.12 for ; Wed, 03 Oct 2018 12:40:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=g7N3N+A91Q9wKX2V+YBrSR0niQNnDAXh8g6joZORqms=; b=RX7khVBzRJsI+sTkn3vZPwx706CpQ5btzh5UYeiIdWrUM8E+8SW2OZc7lj0oiIYHZl QwJDheE6M5CALk/213B9XAKEvOqNmoGVY7B5CXxYnsDnfOWqbm9k60mNwBnG4Ztt+dY+ 11+lRBmVVaqsJilrKf6OjTOovuuK25B26DmLc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=g7N3N+A91Q9wKX2V+YBrSR0niQNnDAXh8g6joZORqms=; b=WPkFj4vEQhf0p/L5BfMfn21gZUgMg2DeII0Nc5bXVaJdgwgZwRrO1dF020BMpE1bXU edcc2hmpda3FwD1fG3iKvV7zjtjZq108IY/RA53mSwgE/ZVGiWXBL2o3E4yDH/mVe+H6 BVG4JFuNoW4H8RGlC2EX17wkjGodKBLdSdSd47vGaa8EsurbjVnXkYg8+bMiHzYK1xIA i3AEOewjoaYIo82LoYLd/5uzcX8dVP+9gZKI4t7EKV+AzVIpKFwV10OPZpBThEhF5eCf HR0v3Wcgz1o7VG4NdUZseegh4VLJXzgcxtZY5hCiBL4LXx/ozFKzitUvgvoDXZ8pxA58 8r4A== X-Gm-Message-State: ABuFfoi5bcWJvvbqt9Y3eTKPNPcgbC/9KrdcfDFR5cb5ia/w7qcSJd/w ZnA/jpvk2nPViSKteCxhyN3GgILY6x9ywg== X-Received: by 2002:ac8:1793:: with SMTP id o19-v6mr2592068qtj.98.1538595599906; Wed, 03 Oct 2018 12:39:59 -0700 (PDT) Received: from cloudburst.twiddle.net ([172.56.13.153]) by smtp.gmail.com with ESMTPSA id t16-v6sm1284946qth.68.2018.10.03.12.39.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Oct 2018 12:39:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Oct 2018 14:39:31 -0500 Message-Id: <20181003193931.18096-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003193931.18096-1-richard.henderson@linaro.org> References: <20181003193931.18096-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::834 Subject: [Qemu-devel] [PATCH v3 9/9] target/s390x: Check HAVE_ATOMIC128 and HAVE_CMPXCHG128 at translate X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-s390x@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: qemu-s390x@nongnu.org Signed-off-by: Richard Henderson --- target/s390x/mem_helper.c | 40 +++++++++++++++++++-------------------- target/s390x/translate.c | 25 +++++++++++++++++------- 2 files changed, 38 insertions(+), 27 deletions(-) -- 2.17.1 Reviewed-by: David Hildenbrand diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index b5858d2fa2..490c43e6e6 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1420,9 +1420,7 @@ void HELPER(cdsg_parallel)(CPUS390XState *env, uint64_t addr, Int128 oldv; bool fail; - if (!HAVE_CMPXCHG128) { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_CMPXCHG128); mem_idx = cpu_mmu_index(env, false); oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); @@ -2115,16 +2113,17 @@ uint64_t HELPER(lpq_parallel)(CPUS390XState *env, uint64_t addr) { uintptr_t ra = GETPC(); uint64_t hi, lo; + int mem_idx; + TCGMemOpIdx oi; + Int128 v; - if (HAVE_ATOMIC128) { - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); - Int128 v = helper_atomic_ldo_be_mmu(env, addr, oi, ra); - hi = int128_gethi(v); - lo = int128_getlo(v); - } else { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_ATOMIC128); + + mem_idx = cpu_mmu_index(env, false); + oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); + v = helper_atomic_ldo_be_mmu(env, addr, oi, ra); + hi = int128_gethi(v); + lo = int128_getlo(v); env->retxl = lo; return hi; @@ -2145,15 +2144,16 @@ void HELPER(stpq_parallel)(CPUS390XState *env, uint64_t addr, uint64_t low, uint64_t high) { uintptr_t ra = GETPC(); + int mem_idx; + TCGMemOpIdx oi; + Int128 v; - if (HAVE_ATOMIC128) { - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); - Int128 v = int128_make128(low, high); - helper_atomic_sto_be_mmu(env, addr, v, oi, ra); - } else { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_ATOMIC128); + + mem_idx = cpu_mmu_index(env, false); + oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); + v = int128_make128(low, high); + helper_atomic_sto_be_mmu(env, addr, v, oi, ra); } /* Execute instruction. This instruction executes an insn modified with diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 7fad3ad8e9..57fe74e4a0 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -44,6 +44,7 @@ #include "trace-tcg.h" #include "exec/translator.h" #include "exec/log.h" +#include "qemu/atomic128.h" /* Information that (most) every instruction needs to manipulate. */ @@ -2032,6 +2033,7 @@ static DisasJumpType op_cdsg(DisasContext *s, DisasOps *o) int r3 = get_field(s->fields, r3); int d2 = get_field(s->fields, d2); int b2 = get_field(s->fields, b2); + DisasJumpType ret = DISAS_NEXT; TCGv_i64 addr; TCGv_i32 t_r1, t_r3; @@ -2039,17 +2041,20 @@ static DisasJumpType op_cdsg(DisasContext *s, DisasOps *o) addr = get_address(s, 0, b2, d2); t_r1 = tcg_const_i32(r1); t_r3 = tcg_const_i32(r3); - if (tb_cflags(s->base.tb) & CF_PARALLEL) { + if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { + gen_helper_cdsg(cpu_env, addr, t_r1, t_r3); + } else if (HAVE_CMPXCHG128) { gen_helper_cdsg_parallel(cpu_env, addr, t_r1, t_r3); } else { - gen_helper_cdsg(cpu_env, addr, t_r1, t_r3); + gen_helper_exit_atomic(cpu_env); + ret = DISAS_NORETURN; } tcg_temp_free_i64(addr); tcg_temp_free_i32(t_r1); tcg_temp_free_i32(t_r3); set_cc_static(s); - return DISAS_NEXT; + return ret; } static DisasJumpType op_csst(DisasContext *s, DisasOps *o) @@ -3036,10 +3041,13 @@ static DisasJumpType op_lpd(DisasContext *s, DisasOps *o) static DisasJumpType op_lpq(DisasContext *s, DisasOps *o) { - if (tb_cflags(s->base.tb) & CF_PARALLEL) { + if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { + gen_helper_lpq(o->out, cpu_env, o->in2); + } else if (HAVE_ATOMIC128) { gen_helper_lpq_parallel(o->out, cpu_env, o->in2); } else { - gen_helper_lpq(o->out, cpu_env, o->in2); + gen_helper_exit_atomic(cpu_env); + return DISAS_NORETURN; } return_low128(o->out2); return DISAS_NEXT; @@ -4462,10 +4470,13 @@ static DisasJumpType op_stmh(DisasContext *s, DisasOps *o) static DisasJumpType op_stpq(DisasContext *s, DisasOps *o) { - if (tb_cflags(s->base.tb) & CF_PARALLEL) { + if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { + gen_helper_stpq(cpu_env, o->in2, o->out2, o->out); + } else if (HAVE_ATOMIC128) { gen_helper_stpq_parallel(cpu_env, o->in2, o->out2, o->out); } else { - gen_helper_stpq(cpu_env, o->in2, o->out2, o->out); + gen_helper_exit_atomic(cpu_env); + return DISAS_NORETURN; } return DISAS_NEXT; }