From patchwork Mon Apr 3 16:01:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 669793 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp1964016wrt; Mon, 3 Apr 2023 09:02:33 -0700 (PDT) X-Google-Smtp-Source: AKy350aL2fNoMhpryUDgYSUMClApRFyPmlclCJDN51CbBqBwIDSAMTqi3GGgltNl6MTTI2GPaHAA X-Received: by 2002:a19:7404:0:b0:4e8:3fc7:9483 with SMTP id v4-20020a197404000000b004e83fc79483mr10098159lfe.23.1680537752687; Mon, 03 Apr 2023 09:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680537752; cv=none; d=google.com; s=arc-20160816; b=B1q29d+FrA1x4WJ2G0oQMWG4tXBkMF1BCv9PPLLNSI16OH6QA7Gn8YV1sPZKqylxrv vUw621UOoJx3WJ4bpLuy5qRde0r/MTfnhhuK0ScEjv1tmKRWdPvGxxY0IEbh3Y9O2d6d BnTMS73axrr+M7/Y4GQj3u2yVKDhtKK6xuj/YD2cS84qTtUZUklj+F/T33wLyzFCBopu 4yuFHOBBIES4xGPrUP1mR/fOUGEVLCQwBDQJi72JBIASuroWo8RSwUbqoINB2Fz9ZTd8 59BTKh+pcc3VWn5d+iiKYYVh5K+Ab2F95JZi+aXQfQFfEwGk/rDHdDhnjDtXRQ+5H/2B U2yA== 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:to:from :dkim-signature; bh=D0bzLBgoxKzl8wuuz0d2cPzzjDTy7V+sRD0Owr6cPGk=; b=u3ykrLBa+jC6PlNnKl/eVGP6UyfroGhyNHMtmiX9G3Nd1qU2zPdc+po5GuFqrW8GIs rVns1rqOssmbUQHQlDr/Rj5lQ0CeyM8MrB+OaqW+MWYfT33JSk1wEaNrZeT4Pq2hNdK4 46nyuF0eeQHzqRbGBfBIW/pU7heBrszVvsMeP3qMyXlTflgrCbf+cARrxq2C4frIkl58 CA3MHJsEJcf7yk5mB4ucziFyk4BUE93IKIHhsTyN1mU05qpYLzanHBTmoCMMW9TiR4nh o6SCJfamD2YNw9VmzKtJotQuj2SvuiG9kuGlwBZcud+lC8mYLrWgX08wRO8Kc6nM5KyW dURA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q5ejblw0; 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 l7-20020ac24307000000b004e812b29b78si3584385lfh.314.2023.04.03.09.02.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Apr 2023 09:02:32 -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=q5ejblw0; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pjMck-00059e-Ss; Mon, 03 Apr 2023 12:01:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pjMcX-00055S-Ua for qemu-devel@nongnu.org; Mon, 03 Apr 2023 12:01:25 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pjMcU-0002BP-Au for qemu-devel@nongnu.org; Mon, 03 Apr 2023 12:01:23 -0400 Received: by mail-wr1-x432.google.com with SMTP id i9so29899400wrp.3 for ; Mon, 03 Apr 2023 09:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680537680; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=D0bzLBgoxKzl8wuuz0d2cPzzjDTy7V+sRD0Owr6cPGk=; b=q5ejblw0dpKlrjuVEd0VYgD+yndmoA0lN+RorXjENFU6b7uwfZ+CwGUILz5oxkpqhj CQBHXKR3Dhzf5JXrkXfzP9EPl4FbAaKTMM+KrgTKlhTvsWrb+XlBuEjSLljzi3Eb46+m v53Jm070q6QaYz6rXL9ta8VPTRtGc8RWpe+X8yRll0jAlrtN1I4KmiK63KZaK6q/8zVm 6jVIO+DTJpqIcG9YiS6yxb8BINVQWwnoFX52gCCoeIaPc/vAOT6BnpVBGfQMdKmEaVwH oHrDKMZNDYk4mTs70Wa2gvzbVSZl17wdwYazPzRo7r5uCTibrAJix3nWoDvl7lxHOHTG qh0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680537680; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D0bzLBgoxKzl8wuuz0d2cPzzjDTy7V+sRD0Owr6cPGk=; b=hU8EsvLOXVSAtkt2Xqicx+if0Fbqbxc/RS+6MyT/RIy2jaiT+x4yxayt6B/yAYLAKG Bnv7iV+FeUoSRHKUWgGwPci9d27L9R/uwHgwtmacdP9j8xNqrEZyUvfaHYe4ILTh8Pal NmvbUh+2MxVP7JygNZyK+kUUfzfCyG+5n3Nf3hEX+enfo90JoCMzX2mdbqWqL+aW04Yr ggWu3ZRq69IKHUgkevRmf3xa4mYkXNu31kjKEI7N16H4nR99oqx8bC1kQM5undoQUS/C uGgvKQtol15BVUqUZTwk7vXczViR+e3mULqqOs9oz+6n9nMr9N/gnjattqGXWd/oQDX3 p4TA== X-Gm-Message-State: AAQBX9eJFKQDBnkyRU5Ln/ION5eAAGOwRBs3HanYjvbCO55NywKtIe/A e2jSjjt+sjBeGIKS9tGPmOjAVTwWDgcs3+vsSKs= X-Received: by 2002:a5d:6a4d:0:b0:2ce:a0c7:153a with SMTP id t13-20020a5d6a4d000000b002cea0c7153amr30605222wrw.14.1680537680446; Mon, 03 Apr 2023 09:01:20 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id p1-20020a5d68c1000000b002c59f18674asm10088668wrw.22.2023.04.03.09.01.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 09:01:20 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 3/4] target/arm: Fix generated code for cpreg reads when HSTR is active Date: Mon, 3 Apr 2023 17:01:16 +0100 Message-Id: <20230403160117.3034102-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403160117.3034102-1-peter.maydell@linaro.org> References: <20230403160117.3034102-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.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-bounces+patch=linaro.org@nongnu.org In commit 049edada we added some code to handle HSTR_EL2 traps, which we did as an inline "conditionally branch over a gen_exception_insn()". Unfortunately this fails to take account of the fact that gen_exception_insn() will set s->base.is_jmp to DISAS_NORETURN. That means that at the end of the TB we won't generate the necessary code to handle the "branched over the trap and continued normal execution" codepath. The result is that the TCG main loop thinks that we stopped execution of the TB due to a situation that only happens when icount is enabled, and hits an assertion. Explicitly set is_jmp back to DISAS_NEXT so we generate the correct code for when execution continues past this insn. Note that this only happens for cpreg reads; writes will call gen_lookup_tb() which generates a valid end-of-TB. Fixes: 049edada ("target/arm: Make HSTR_EL2 traps take priority over UNDEF-at-EL1") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1551 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230330101900.2320380-1-peter.maydell@linaro.org --- target/arm/tcg/translate.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index 2cb9368b1ba..3c8401e9086 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -4623,6 +4623,12 @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, tcg_gen_brcondi_i32(TCG_COND_EQ, t, 0, over.label); gen_exception_insn(s, 0, EXCP_UDEF, syndrome); + /* + * gen_exception_insn() will set is_jmp to DISAS_NORETURN, + * but since we're conditionally branching over it, we want + * to assume continue-to-next-instruction. + */ + s->base.is_jmp = DISAS_NEXT; set_disas_label(s, over); } }