From patchwork Tue Jun 20 00:04:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9798233 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DC128600C5 for ; Tue, 20 Jun 2017 00:10:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE13223E64 for ; Tue, 20 Jun 2017 00:10:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C244427A98; Tue, 20 Jun 2017 00:10:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 39C1D23E64 for ; Tue, 20 Jun 2017 00:10:54 +0000 (UTC) Received: from localhost ([::1]:44887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dN6kv-0000Hy-AD for patchwork-qemu-devel@patchwork.kernel.org; Mon, 19 Jun 2017 20:10:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dN6ef-0003a3-L7 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 20:04:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dN6ee-0001zx-KO for qemu-devel@nongnu.org; Mon, 19 Jun 2017 20:04:25 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:33202) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dN6ee-0001zg-EU for qemu-devel@nongnu.org; Mon, 19 Jun 2017 20:04:24 -0400 Received: by mail-pg0-x242.google.com with SMTP id u62so12966871pgb.0 for ; Mon, 19 Jun 2017 17:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=cC8Xc60P1ydRsDNlQ4OZ1FRpa1X3iYeaS9Yz0K9IBfc=; b=tdR3RClV3NIrnPCaF0UL95zZVc4K3sfSxsm3G6t8xg+jSktDGSXwO+Zq5Mc08qe1ZF vI3OynpVsanwaoFb1Uz0GwGuoIg40EKP3PFIWG8kZpbT8aObSeAfBEMt/pNbY3To8O/r 1QqKP5lV0sJmJ7qAUD5ENGlgJ6tdV3BDuafP4+pLu39Te6FY5n237tTbOuBkZdQcQHl4 MMXkaa5fDPJt4gflNZ3JYJVpJjmvIWQP15/XK7XrwxxWFHSqrCpg/86IUP1z7R/gAfub 2jwD7XLHvehwGotxp5KscvkHc++jT02BY7zpG2f2oBtVq59jIVq6BqBjoSiEFs6hPp25 5hXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=cC8Xc60P1ydRsDNlQ4OZ1FRpa1X3iYeaS9Yz0K9IBfc=; b=bidSqZN9bJZ9mSo8wsNjjV9p6oKnLmXfgr4wd5iK3Cg57h31amtin3mvvkl1Iy8Swb ZZ4JQR6lNZ6XSVpvRjgWd+IYmMi+GNUBIyR09OH5bisycz0Ds0mCBIm1B9lpUg/y808W fIrpShKBVYbeJijN5OzeeN2QttTx+RuytOj0+zNaxTgQXjkGG/CVw3INTIt2+ZcHkIcd IsZcZjApScYMULB3yAOZkW5lRaEmvM2sGEybOJP5F/YnSTzPp24XCo9u393wwHs1DauB eVDz88jv0XLQW+LVmETO0tkEvXKZKnjdN7vhr15k22oO5FHZLcFxIn9zGFSetcVKKdMO 4YYg== X-Gm-Message-State: AKS2vOzj2ppWrf2Q6DZb5e6V1ld3Ne7vUd/RSDpdCBYAqqGITbrKtR4i znfFYn4FJDVC0RFI4N0= X-Received: by 10.84.236.66 with SMTP id h2mr32653094pln.233.1497917063306; Mon, 19 Jun 2017 17:04:23 -0700 (PDT) Received: from bigtime.twiddle.net (97-113-165-157.tukw.qwest.net. [97.113.165.157]) by smtp.gmail.com with ESMTPSA id o8sm23064937pgn.52.2017.06.19.17.04.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 17:04:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 19 Jun 2017 17:04:02 -0700 Message-Id: <20170620000405.3391-16-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170620000405.3391-1-rth@twiddle.net> References: <20170620000405.3391-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v3 15/18] target/s390x: Implement SRSTU 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: thuth@redhat.com, aurelien@aurel32.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Richard Henderson --- target/s390x/helper.h | 1 + target/s390x/insn-data.def | 2 ++ target/s390x/mem_helper.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ target/s390x/translate.c | 8 ++++++++ 4 files changed, 55 insertions(+) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index cd51b89..58d7f5b 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -13,6 +13,7 @@ DEF_HELPER_FLAGS_3(divu32, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(divs64, TCG_CALL_NO_WG, s64, env, s64, s64) DEF_HELPER_FLAGS_4(divu64, TCG_CALL_NO_WG, i64, env, i64, i64, i64) DEF_HELPER_3(srst, i64, env, i64, i64) +DEF_HELPER_3(srstu, i64, env, i64, i64) DEF_HELPER_4(clst, i64, env, i64, i64, i64) DEF_HELPER_FLAGS_4(mvn, TCG_CALL_NO_WG, void, env, i32, i64, i64) DEF_HELPER_FLAGS_4(mvo, TCG_CALL_NO_WG, void, env, i32, i64, i64) diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index 634ef98..1bebcf2 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -736,6 +736,8 @@ /* SEARCH STRING */ C(0xb25e, SRST, RRE, Z, r1_o, r2_o, 0, 0, srst, 0) +/* SEARCH STRING UNICODE */ + C(0xb9be, SRSTU, RRE, ETF3, r1_o, r2_o, 0, 0, srstu, 0) /* SET ACCESS */ C(0xb24e, SAR, RRE, Z, 0, r2_o, 0, 0, sar, 0) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 990858e..ce288d9 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -578,6 +578,50 @@ uint64_t HELPER(srst)(CPUS390XState *env, uint64_t end, uint64_t str) return end; } +uint64_t HELPER(srstu)(CPUS390XState *env, uint64_t end, uint64_t str) +{ + uintptr_t ra = GETPC(); + uint32_t len; + uint16_t v, c = env->regs[0]; + uint64_t adj_end; + + /* Bits 32-47 of R0 must be zero. */ + if (env->regs[0] & 0xffff0000u) { + cpu_restore_state(ENV_GET_CPU(env), ra); + program_interrupt(env, PGM_SPECIFICATION, 6); + } + + str = wrap_address(env, str); + end = wrap_address(env, end); + + /* If the LSB of the two addresses differ, use one extra byte. */ + adj_end = end + ((str ^ end) & 1); + + /* Assume for now that R2 is unmodified. */ + env->retxl = str; + + /* Lest we fail to service interrupts in a timely manner, limit the + amount of work we're willing to do. For now, let's cap at 8k. */ + for (len = 0; len < 0x2000; len += 2) { + if (str + len == adj_end) { + /* End of input found. */ + env->cc_op = 2; + return end; + } + v = cpu_lduw_data_ra(env, str + len, ra); + if (v == c) { + /* Character found. Set R1 to the location; R2 is unmodified. */ + env->cc_op = 1; + return str + len; + } + } + + /* CPU-determined bytes processed. Advance R2 to next byte to process. */ + env->retxl = str + len; + env->cc_op = 3; + return end; +} + /* unsigned string compare (c is string terminator) */ uint64_t HELPER(clst)(CPUS390XState *env, uint64_t c, uint64_t s1, uint64_t s2) { diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 4a860f1..e594b91 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -4262,6 +4262,14 @@ static ExitStatus op_srst(DisasContext *s, DisasOps *o) return NO_EXIT; } +static ExitStatus op_srstu(DisasContext *s, DisasOps *o) +{ + gen_helper_srstu(o->in1, cpu_env, o->in1, o->in2); + set_cc_static(s); + return_low128(o->in2); + return NO_EXIT; +} + static ExitStatus op_sub(DisasContext *s, DisasOps *o) { tcg_gen_sub_i64(o->out, o->in1, o->in2);