From patchwork Sat Jul 1 20:25:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9820983 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 650D4603F2 for ; Sat, 1 Jul 2017 20:27:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58517283CA for ; Sat, 1 Jul 2017 20:27:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CED028418; Sat, 1 Jul 2017 20:27:44 +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 D2F1E28405 for ; Sat, 1 Jul 2017 20:27:43 +0000 (UTC) Received: from localhost ([::1]:55787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dROzX-0001gh-2s for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Jul 2017 16:27:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dROyI-0001fH-DO for qemu-devel@nongnu.org; Sat, 01 Jul 2017 16:26:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dROyH-0006my-9A for qemu-devel@nongnu.org; Sat, 01 Jul 2017 16:26:26 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:36262) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dROyH-0006mq-4B for qemu-devel@nongnu.org; Sat, 01 Jul 2017 16:26:25 -0400 Received: by mail-qk0-x241.google.com with SMTP id v143so6825723qkb.3 for ; Sat, 01 Jul 2017 13:26:25 -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=H/+RFalamWctHXNr6WGUUFSK/8yfAlf20t+J06+nEb4=; b=I/Cx3VisB6zoe4+X+U9apjd6tm83trrzJiymygzG6hqQ6uIKXlV6YMxgvnzqXJ88Xz lCGRVGArNUNpvb5hj5+oIg/ypG6j1VE/kx8moLdU+v1XeTsqIS9pPTlRj1nZAiFR0di+ +/valnxllhyjBlav0EJ7Dz/XZGsYVvRzRyszKIwo+qunCo0MiGLAqu0nf+XmwA3J0tsT Rql7wKE7Oqwn7O+UpR6zobALUKuBZga3VqsjGSr30kFa9ndNoej2yHbdq4Li9c0pGDmP AhVMeEfHHezb+vKtGGW9hxxfWzFzShNsC2w0LCCebRvnuTj/VY104V29j+EuTGTBP4+B 3eMQ== 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=H/+RFalamWctHXNr6WGUUFSK/8yfAlf20t+J06+nEb4=; b=Pd1k679s656iurM8hHwOzb+5RJp191fietPWcfDpp+F/RDQ+u4bRRkPkkYKpamhhSy VdHDaDi/dDI2rgh+WXRcMNDSS75/pTt7c5Y7VTz8X/HmvKXHGPIK+iEypvb9Rk13H29R VSPgoeDJ8BsTVws6vbaZik2/NAhEHkWAz7dkj3qpeSBOzcY2A5ynS7qEPDlDkTfc6EQi awSeT1yO4S9rTiQsRN+OryUopYpWnOmNgRcB6ZDixiv+o8X3r9BwRr3Two4IIC54VFNV FJKUgdKaScNg5sPvlHTLdwgVYjq7N114ZGAB54YJLuKZsE/oHaNJCGP1beUfhfSHRvWY dJlw== X-Gm-Message-State: AKS2vOwJ9TAXwTTGdOydxbAOw133gln5+CHZ0oJgr+IkD4XF+Z8bAUpE CkSErq5D7rIH/yfINbU= X-Received: by 10.55.116.70 with SMTP id p67mr25360647qkc.250.1498940784275; Sat, 01 Jul 2017 13:26:24 -0700 (PDT) Received: from bigtime.twiddle.net.com (97-113-165-157.tukw.qwest.net. [97.113.165.157]) by smtp.gmail.com with ESMTPSA id f128sm8559985qkc.13.2017.07.01.13.26.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Jul 2017 13:26:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 1 Jul 2017 13:25:56 -0700 Message-Id: <20170701202600.14057-5-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170701202600.14057-1-rth@twiddle.net> References: <20170701202600.14057-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::241 Subject: [Qemu-devel] [PATCH v2 4/8] 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: aurelien@aurel32.net, david@redhat.com 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 Reviewed-by: Aurelien Jarno --- target/s390x/helper.h | 1 + target/s390x/mem_helper.c | 41 +++++++++++++++++++++++++++++++++++++++++ target/s390x/translate.c | 13 +++++++++++++ target/s390x/insn-data.def | 2 ++ 4 files changed, 57 insertions(+) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index a2e5b9b..32314e0 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, void, env, i32, i32) +DEF_HELPER_3(srstu, void, env, i32, i32) 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/mem_helper.c b/target/s390x/mem_helper.c index 74b48aa..e3db68d 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -576,6 +576,47 @@ void HELPER(srst)(CPUS390XState *env, uint32_t r1, uint32_t r2) set_address(env, r2, str + len); } +void HELPER(srstu)(CPUS390XState *env, uint32_t r1, uint32_t r2) +{ + uintptr_t ra = GETPC(); + uint32_t len; + uint16_t v, c = env->regs[0]; + uint64_t end, str, 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 = get_address(env, r2); + end = get_address(env, r1); + + /* If the LSB of the two addresses differ, use one extra byte. */ + adj_end = end + ((str ^ end) & 1); + + /* 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; + } + 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; + set_address(env, r1, str + len); + return; + } + } + + /* CPU-determined bytes processed. Advance R2 to next byte to process. */ + env->cc_op = 3; + set_address(env, r2, str + len); +} + /* 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 b887843..09b77ea 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -4291,6 +4291,19 @@ static ExitStatus op_srst(DisasContext *s, DisasOps *o) return NO_EXIT; } +static ExitStatus op_srstu(DisasContext *s, DisasOps *o) +{ + TCGv_i32 r1 = tcg_const_i32(get_field(s->fields, r1)); + TCGv_i32 r2 = tcg_const_i32(get_field(s->fields, r2)); + + gen_helper_srstu(cpu_env, r1, r2); + + tcg_temp_free_i32(r1); + tcg_temp_free_i32(r2); + set_cc_static(s); + return NO_EXIT; +} + static ExitStatus op_sub(DisasContext *s, DisasOps *o) { tcg_gen_sub_i64(o->out, o->in1, o->in2); diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index bc6ff01..1d34df03 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -737,6 +737,8 @@ /* SEARCH STRING */ C(0xb25e, SRST, RRE, Z, 0, 0, 0, 0, srst, 0) +/* SEARCH STRING UNICODE */ + C(0xb9be, SRSTU, RRE, ETF3, 0, 0, 0, 0, srstu, 0) /* SET ACCESS */ C(0xb24e, SAR, RRE, Z, 0, r2_o, 0, 0, sar, 0)