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.