From patchwork Sat Jul 15 17:30:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9842445 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 6777260392 for ; Sat, 15 Jul 2017 17:35:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50E5628645 for ; Sat, 15 Jul 2017 17:35:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 449CB28655; Sat, 15 Jul 2017 17:35:18 +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 B11B928645 for ; Sat, 15 Jul 2017 17:35:17 +0000 (UTC) Received: from localhost ([::1]:42801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWQyK-0000Bd-T1 for patchwork-qemu-devel@patchwork.kernel.org; Sat, 15 Jul 2017 13:35:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWQuF-0006QC-SN for qemu-devel@nongnu.org; Sat, 15 Jul 2017 13:31:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dWQuE-0000ow-Rg for qemu-devel@nongnu.org; Sat, 15 Jul 2017 13:31:03 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:33385) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dWQuE-0000oa-LR for qemu-devel@nongnu.org; Sat, 15 Jul 2017 13:31:02 -0400 Received: by mail-pf0-x242.google.com with SMTP id e199so14641046pfh.0 for ; Sat, 15 Jul 2017 10:31:02 -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=R6Ka2NWcSF6hwbWAEC/WD4vNcDfuRj6vA5Ja4rYsBcw=; b=QsDi7DccM3IMHzObRQLjd9n/FlcrFfueIt9x+voFaGpKubjwjVTyR0Ca91gRIT/nCF nlHdCKVIlcN8gDBWvEZPy8EZrkaUm+btnq2A+kHY1lkxK/q+axFxHMEMA0QxZfq4a7mY jHLvnQ/hOUHJisDnhkAYZTDzBZ5n8UjKnqwJEfDIIgZqsmObq4WrvgYntYJmMEALhvKT PiOfCxiBzib113DZ/XydxSYwNq4os/JEvjRHIqDYpWR6uQWvXgXeQ57lOXUO7tgnTUH5 SlfT4PXftpZ70rHuw8mRXPcgfq/xZ2CPbQpcoMbxU8wmYZsVKXqbXdkVO5hTpsVCLi2p blrQ== 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=R6Ka2NWcSF6hwbWAEC/WD4vNcDfuRj6vA5Ja4rYsBcw=; b=VtkfizYplCMRCyRGtGdMnUQeqT+r/SdkBssJvTpkg+UQAu44S+TXZiqzgU24lnp/pH FMavf2+ZLnnu41wo/plI9Lqo1hg/n2E/oz6FXj044bpcrQ2ISk2WUwbPs7Yst2zt66yI gXQ7zCGzb/v64fvYi9QtcPhrsnWBMjEEwpY4v4by28HDgB4haOIcL3kQyOeb1R+Zc/cj 77pMFeCSsR6NSZF1xdL1NrLzVpN95pUFEU/LLwvSZKPT8eEHs5RuAVBGivjy0cqagrcB V7B4qCKeB4iNkWZdh1AmMzxzrdlqKoKtlVM4A6nNjgC6cv3sf+3BGUfQ8cWlT8VLblhV w3RQ== X-Gm-Message-State: AIVw111h5CDR8lHSJosZZ7Xghkyztj314iTCXdWyZrbFuDGD02Td2Ih2 wdXHfZdMm4YDGhLGKmQ= X-Received: by 10.99.125.28 with SMTP id y28mr3605944pgc.142.1500139861406; Sat, 15 Jul 2017 10:31:01 -0700 (PDT) Received: from bigtime.twiddle.net (rrcs-173-197-98-123.west.biz.rr.com. [173.197.98.123]) by smtp.gmail.com with ESMTPSA id w66sm27366075pfi.63.2017.07.15.10.30.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Jul 2017 10:31:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 15 Jul 2017 07:30:45 -1000 Message-Id: <20170715173050.31018-4-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170715173050.31018-1-rth@twiddle.net> References: <20170715173050.31018-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PULL 3/8] target/s390x: Tidy SRST 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since we require all registers saved on input, read R0 from ENV instead of passing it manually. Recognize the specification exception when R0 contains incorrect data. Keep high bits of result registers unmodified when in 31 or 24-bit mode. Reviewed-by: Aurelien Jarno Signed-off-by: Richard Henderson --- target/s390x/helper.h | 2 +- target/s390x/mem_helper.c | 25 ++++++++++++++----------- target/s390x/translate.c | 9 +++++++-- target/s390x/insn-data.def | 2 +- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 2793cf3..a2e5b9b 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -12,7 +12,7 @@ DEF_HELPER_FLAGS_3(divs32, TCG_CALL_NO_WG, s64, env, s64, s64) 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_4(srst, i64, env, i64, i64, i64) +DEF_HELPER_3(srst, 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 b9c7391..8ab3f42 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -538,18 +538,21 @@ static inline void set_length(CPUS390XState *env, int reg, uint64_t length) } /* search string (c is byte to search, r2 is string, r1 end of string) */ -uint64_t HELPER(srst)(CPUS390XState *env, uint64_t r0, uint64_t end, - uint64_t str) +void HELPER(srst)(CPUS390XState *env, uint32_t r1, uint32_t r2) { uintptr_t ra = GETPC(); + uint64_t end, str; uint32_t len; - uint8_t v, c = r0; + uint8_t v, c = env->regs[0]; - str = wrap_address(env, str); - end = wrap_address(env, end); + /* Bits 32-55 must contain all 0. */ + if (env->regs[0] & 0xffffff00u) { + cpu_restore_state(ENV_GET_CPU(env), ra); + program_interrupt(env, PGM_SPECIFICATION, 6); + } - /* Assume for now that R2 is unmodified. */ - env->retxl = str; + str = get_address(env, r2); + end = get_address(env, r1); /* 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. */ @@ -557,20 +560,20 @@ uint64_t HELPER(srst)(CPUS390XState *env, uint64_t r0, uint64_t end, if (str + len == end) { /* Character not found. R1 & R2 are unmodified. */ env->cc_op = 2; - return end; + return; } v = cpu_ldub_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; + set_address(env, r1, str + len); + return; } } /* CPU-determined bytes processed. Advance R2 to next byte to process. */ - env->retxl = str + len; env->cc_op = 3; - return end; + set_address(env, r2, str + len); } /* unsigned string compare (c is string terminator) */ diff --git a/target/s390x/translate.c b/target/s390x/translate.c index edfdaf40..e37a56f 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -4287,9 +4287,14 @@ static ExitStatus op_stpq(DisasContext *s, DisasOps *o) static ExitStatus op_srst(DisasContext *s, DisasOps *o) { - gen_helper_srst(o->in1, cpu_env, regs[0], o->in1, o->in2); + TCGv_i32 r1 = tcg_const_i32(get_field(s->fields, r1)); + TCGv_i32 r2 = tcg_const_i32(get_field(s->fields, r2)); + + gen_helper_srst(cpu_env, r1, r2); + + tcg_temp_free_i32(r1); + tcg_temp_free_i32(r2); set_cc_static(s); - return_low128(o->in2); return NO_EXIT; } diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index 323a301..bc6ff01 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -736,7 +736,7 @@ C(0xec57, RXSBG, RIE_f, GIE, 0, r2, r1, 0, rosbg, 0) /* SEARCH STRING */ - C(0xb25e, SRST, RRE, Z, r1_o, r2_o, 0, 0, srst, 0) + C(0xb25e, SRST, RRE, Z, 0, 0, 0, 0, srst, 0) /* SET ACCESS */ C(0xb24e, SAR, RRE, Z, 0, r2_o, 0, 0, sar, 0)