From patchwork Thu Oct 6 03:44:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 612879 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1207581pvb; Wed, 5 Oct 2022 21:01:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5GGYOzgMnwwJbhoAEKxuHoHrFgjelUUrx8RpZeKVYz/KcFev0r+i0/UOJsdqcyuQH1mMXt X-Received: by 2002:a37:6d7:0:b0:6e3:e03c:b61c with SMTP id 206-20020a3706d7000000b006e3e03cb61cmr1901179qkg.251.1665028897870; Wed, 05 Oct 2022 21:01:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665028897; cv=none; d=google.com; s=arc-20160816; b=af95NFqdY2zobO2Beu3pYhT49s4qklNvUPnlvnfwNwJCQsByGvTKV/l0eGNOmSVd9p teCAhi9XZ8hYn+aMsAJs2Oct+DCn82zIp+sUvH49v0zeXL6wsQBBz5ZFpSZlAkcdbQWg blFAj152msIWCXspbFNTLW5C8piUMXnGt0UXcNdNqLjvmN3q6g8kT7s2qRdp4OfZECL+ ymrTZNJvrzHvYQDLdfzlUKg/3tll2BUVK62+nPQS5/dCf9N/rD9zK2Kqb5MlwEeunnGO 0678wNhCW1gGgXWyjBiCtBgrYLoP31dXvGTnRWk7jqz+gP6przPF4vQi4lEXUnauV6iB +3oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cdk+wqhXrtt2egBbh65dqBvCP5p2fyN7igj25PdmOsY=; b=dHftqLS9F+CiqKFZbnPbpANW2Z/7n0hIYAMk6RIUSXRfIq/L2aozb+LzimO4+22gbE mZeVAW++50bP0XzkFhJsGvjf2OOEiMpZIH0MfadldIqPWnjd25JXt6UoCntDEsqblVBS l+GYniTJ2rOGpHqqbiNXeH9desLH5BboZE4XJDCdSwp01NUef0zdyawxBAnaeXPI5Qb5 GcKrlZZ2thGTzrK+5YwHqVQuM10DkjFBQ1+kTQ1Kl6S49WlQv4EWXKsgVl0HV46+ErcI DP/9LhZzngPAgEy3QpeH2lGeFgEZzMCz/b/SrSww8WpU5SyRC2P3R8hzoimhiAQK8F5c 462w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YJbQNcKf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d8-20020ac84e28000000b0035cee1ad5b2si6191046qtw.384.2022.10.05.21.01.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Oct 2022 21:01:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YJbQNcKf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogI4n-00065l-5t for patch@linaro.org; Thu, 06 Oct 2022 00:01:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogHoK-0004BA-CP for qemu-devel@nongnu.org; Wed, 05 Oct 2022 23:44:36 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:35832) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogHoI-0003u0-AM for qemu-devel@nongnu.org; Wed, 05 Oct 2022 23:44:35 -0400 Received: by mail-pf1-x429.google.com with SMTP id i6so936980pfb.2 for ; Wed, 05 Oct 2022 20:44:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=cdk+wqhXrtt2egBbh65dqBvCP5p2fyN7igj25PdmOsY=; b=YJbQNcKfU2EaOAXioXTiSWKd9zjsuzXy0q9kTPrVfLeL/qfnBi72PXkk6tLSoKh51f VQosDBl4RcgrmEPjlp5he/BQO+qxqe+cDl1dYBuileCQADnMGAuR8u9R1X0N/7FzmNMD M14fBGp5gXa0rT6M2CL73vctuY3/ATC/6BaPlwtSDIPDfVq/UKZ62DsWB7zCzkvSkwUf ioICgNrrVsgl0dvNX/wj12bDSnHgsXbgiiOt+8vweiqD53mNj5SLGpppY7y0qxShBNvR S4umJ/jpcbzEkwWfX2AJ2EhXmefYKLateO8nAsdQ+fd87b7Y6Njrea4FJDF3KSZRzHzu vq/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=cdk+wqhXrtt2egBbh65dqBvCP5p2fyN7igj25PdmOsY=; b=EF2KeL3Oy+PZ33psOpEV2DrSXOWTpchHVYy/wP7jWxhWlGSzMFg5lIuSrIm3S4R9CU ZNFXTKYXUAzL17kI76ot+kFAmBjggxL8ToY0k/XJycU+DYL9r42sPF1ScjAvMBq9Iz8u CB1jwS71ZaI6AvKoV8l2wBWJR2s/VREecv7koTlO6KSlULpHpDKWtgW8606rFaJLGRsQ xOD/m3QIWgdBB0AjSyK2BYI0dybkgoTRmp6eSGUFOLYb/U+B+Z+xjTHpvKFdkyrX+0Qx 4BBYykrwkEQ/oGmFlPtfVuzmu7fJ6lPp8gqLCpAmOeQAimO1iTTxCsnfkuXi3orkVsdb PClw== X-Gm-Message-State: ACrzQf1ya5+H77SJE/kepnBOZiA3FtQvh/xh+mzJMaUN6NBfMYFyS238 mHvAAyDFnGugPUmO8yLhemY1DYYX0htNdw== X-Received: by 2002:a63:eb43:0:b0:447:f457:fa83 with SMTP id b3-20020a63eb43000000b00447f457fa83mr2671086pgk.573.1665027872741; Wed, 05 Oct 2022 20:44:32 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:9ad0:4307:7d39:bb61]) by smtp.gmail.com with ESMTPSA id y6-20020a17090ad0c600b00205f4f7a3b3sm1905086pjw.21.2022.10.05.20.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 20:44:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org Subject: [PATCH 10/26] target/s390x: Use gen_psw_addr_disp in op_sam Date: Wed, 5 Oct 2022 20:44:05 -0700 Message-Id: <20221006034421.1179141-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006034421.1179141-1-richard.henderson@linaro.org> References: <20221006034421.1179141-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Complicated because we may now require a runtime jump. Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich --- target/s390x/tcg/translate.c | 40 +++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index ad73a64b05..2ea3feb803 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -3922,7 +3922,7 @@ static DisasJumpType op_sacf(DisasContext *s, DisasOps *o) static DisasJumpType op_sam(DisasContext *s, DisasOps *o) { int sam = s->insn->data; - TCGv_i64 tsam; + TCGLabel *fault = NULL; uint64_t mask; switch (sam) { @@ -3937,20 +3937,36 @@ static DisasJumpType op_sam(DisasContext *s, DisasOps *o) break; } - /* Bizarre but true, we check the address of the current insn for the - specification exception, not the next to be executed. Thus the PoO - documents that Bad Things Happen two bytes before the end. */ - if (s->base.pc_next & ~mask) { - gen_program_exception(s, PGM_SPECIFICATION); - return DISAS_NORETURN; - } - s->pc_tmp &= mask; + /* + * Bizarre but true, we check the address of the current insn for the + * specification exception, not the next to be executed. Thus the PoO + * documents that Bad Things Happen two bytes before the end. + */ + if (mask != -1) { + TCGv_i64 t = tcg_temp_new_i64(); + fault = gen_new_label(); - tsam = tcg_constant_i64(sam); - tcg_gen_deposit_i64(psw_mask, psw_mask, tsam, 31, 2); + gen_psw_addr_disp(s, t, 0); + tcg_gen_andi_i64(t, t, ~mask); + tcg_gen_brcondi_i64(TCG_COND_NE, t, 0, fault); + tcg_temp_free_i64(t); + } + + update_cc_op(s); + + tcg_gen_deposit_i64(psw_mask, psw_mask, tcg_constant_i64(sam), 31, 2); + + gen_psw_addr_disp(s, psw_addr, s->ilen); + tcg_gen_andi_i64(psw_addr, psw_addr, mask); /* Always exit the TB, since we (may have) changed execution mode. */ - return DISAS_TOO_MANY; + tcg_gen_lookup_and_goto_ptr(); + + if (mask != -1) { + gen_set_label(fault); + gen_program_exception(s, PGM_SPECIFICATION); + } + return DISAS_NORETURN; } static DisasJumpType op_sar(DisasContext *s, DisasOps *o)