From patchwork Tue Jun 20 00:04:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9798259 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 EA48E600C5 for ; Tue, 20 Jun 2017 00:16:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB04A23E64 for ; Tue, 20 Jun 2017 00:16:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDC7B26E46; Tue, 20 Jun 2017 00:16: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 4794123E64 for ; Tue, 20 Jun 2017 00:16:18 +0000 (UTC) Received: from localhost ([::1]:44923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dN6q9-00064i-6N for patchwork-qemu-devel@patchwork.kernel.org; Mon, 19 Jun 2017 20:16:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dN6ee-0003YS-9c for qemu-devel@nongnu.org; Mon, 19 Jun 2017 20:04:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dN6ed-0001zF-C9 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 20:04:24 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:33013) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dN6ed-0001yH-74 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 20:04:23 -0400 Received: by mail-pf0-x242.google.com with SMTP id w12so19894327pfk.0 for ; Mon, 19 Jun 2017 17:04:23 -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=v9Q8BnPcHL/Fzeso1UcLASjFQPy+by5QZfiqVFgI62E=; b=aG7MPOOhGIU/I+CxRhWQOu0j8pw2aZIIAi28mMb42yLKIhVqQsJBbhGhYSwMeiuMNo m03oFah76zCK287Frb8tAdou1LL1ZXemlUnKQ+ERCTB3xpPhk7d+N/6dGnWHui+jPrYE mZ4CBj62l+Y/95qk7PYhEPc44MSnRuBxztvWKPvFSzGTnYm+hy6h6vv9er311vg8NdTU HMpS8iEuigdBJ560rgqLoZB+tI+38f621XNbBbJHBnc+yCWFvjQoLFjvGqpAnSuGbs+Y q7E8k56znp0cVJSB73wlGVZuPyM7bUuVXljryJxrxZza4WN+KOH0NIyvS71/SPVZCrWs 5SPg== 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=v9Q8BnPcHL/Fzeso1UcLASjFQPy+by5QZfiqVFgI62E=; b=UNiAeCmODkFvN6je57UUlfgqoZoI4MxGbQvFo9GSr6SMqX2PZB25QppkOXS8bR3ERo Fc+MNqaKMtRX5Z79QQ5JN6+Zn79I0HF1nTkj4vGKkpPRE5+m+FBA2v/36Yh8DYXdyeYe SZ4T9EnToz8nIVwj4fbv3WV2uCKL+ycSo26NbblGy4+RzZ1kdo3lXOAIBSZASLH0cQ66 7q6MDVfhAbDCSqOlsNRPmFGFOt0vcfhNY7HOdPVK1mKnYBHxX4aQ6tbbA+4/zslQMx+7 n8ZyBnJ2cQLQWAf7pXDwjQhQtF+OhDMRows60V3mAuaD9Vo4T+EZTiVA1aXZ4T6D9enE wwJg== X-Gm-Message-State: AKS2vOxLsfKVCkMnMuuirt/aAeZVCUmTIeQJJx7Ma7Uo35/0wZ4uH0hL yUCXwd6/KAhxvcJe12c= X-Received: by 10.84.217.138 with SMTP id p10mr27370100pli.66.1497917062170; Mon, 19 Jun 2017 17:04:22 -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.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 17:04:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 19 Jun 2017 17:04:01 -0700 Message-Id: <20170620000405.3391-15-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:c00::242 Subject: [Qemu-devel] [PATCH v3 14/18] 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: 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 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. Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand Reviewed-by: Aurelien Jarno --- target/s390x/helper.h | 2 +- target/s390x/mem_helper.c | 11 ++++++++--- target/s390x/translate.c | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index c014820..cd51b89 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, 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/mem_helper.c b/target/s390x/mem_helper.c index df082f5..990858e 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -538,12 +538,17 @@ 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) +uint64_t HELPER(srst)(CPUS390XState *env, uint64_t end, uint64_t str) { uintptr_t ra = GETPC(); uint32_t len; - uint8_t v, c = r0; + uint8_t v, c = env->regs[0]; + + /* 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); + } str = wrap_address(env, str); end = wrap_address(env, end); diff --git a/target/s390x/translate.c b/target/s390x/translate.c index f8989ec..4a860f1 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -4256,7 +4256,7 @@ 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); + gen_helper_srst(o->in1, cpu_env, o->in1, o->in2); set_cc_static(s); return_low128(o->in2); return NO_EXIT;