Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 043DBCA9EA0 for ; Tue, 22 Oct 2019 13:46:27 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C24A8206C2 for ; Tue, 22 Oct 2019 13:46:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QCSxk0TL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C24A8206C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMuUT-0002em-Ss for qemu-devel@archiver.kernel.org; Tue, 22 Oct 2019 09:46:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37060) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMuHD-0003Ex-JZ for qemu-devel@nongnu.org; Tue, 22 Oct 2019 09:32:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iMuHB-0001Su-U5 for qemu-devel@nongnu.org; Tue, 22 Oct 2019 09:32:43 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:44021) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iMuHB-0001SS-NN for qemu-devel@nongnu.org; Tue, 22 Oct 2019 09:32:41 -0400 Received: by mail-wr1-x433.google.com with SMTP id c2so12856236wrr.10 for ; Tue, 22 Oct 2019 06:32:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=SrVz8zV33u4/B/5UmvJ5uDPbu/uO8YsNIkly3MZVQcQ=; b=QCSxk0TLq3Jp5roB8gh9m+o6QyLSraW4EPIkaL6DfiYrU6Cs6Je9j3mAmXGjOxCSj/ 9cGAdzi2lYFKbAXyq0tdccqIsNl0m/2i6HiewZRGriSW50dCmwsx/+bDYYqRgpmU4z// gagFEZF5hXTFvJ0ZPJxQAp09mzsKqRMQcc9Kg7+6O1vuP4yjIxvesYY+UnM5lflPKVkY tEXP497FUpurT3ZSpYxfVnVefFI/PFr95AKgsE43vxcFENu0mMu8bITMxDc/f+ZeXbVw MGre0uXxxDl6ddFKF+EWPhXD5c01A1IN+UaBa5a7oZRqDSe6WPoT8nVXqhB4w3vjP/5l siGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SrVz8zV33u4/B/5UmvJ5uDPbu/uO8YsNIkly3MZVQcQ=; b=PDb6wPNIpfEwOKUjf+Lq8FT+AKNeLachPak00Ugz/0jqw3ks3Q5c3Xatzz6ZrHUUeH xVq28Zo2B1f6Ka1qwsaPKRlDluiTbE76cotPLlgbSagyDsG2kIi7iLb9BUx+yCYqB5fT vTTLoO4kc96lHcgMIG4/jgKnQCDIgU+BzbnxWD3vyBFehbkK689ql2Q9B2RbTu0jjHR+ lqfVq9hh5Vd61Wr+bN0mnNbyMzF1JIBQIxkpbj+cdynfQZVGNhaqbuoX7RZXtUD4RXLv V7Vf2bLuQl/nGadUgrJzyF5GUFYc4saqBupcp0TRgejYK0fIKfC/Po3aVMh8bABfOpfL gKOw== X-Gm-Message-State: APjAAAXmIJk9RdO2ASPBItBk3MHkNnHWp+YX/3oKTC6fO3o/pEgjeGWW Lhnc8f3j2eEIX6z4bLPP7ksteeRdLB8= X-Google-Smtp-Source: APXvYqyW/u+KrBefo36TV/IPdXXUXAwWeM9fpxfC5G7VlBgeJatV3s7D0/Ns7jdv4rswQtJAWDJ++A== X-Received: by 2002:adf:978a:: with SMTP id s10mr3759209wrb.264.1571751160008; Tue, 22 Oct 2019 06:32:40 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r2sm20263856wma.1.2019.10.22.06.32.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 06:32:38 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 27/41] target/arm: Rebuild hflags at MSR writes Date: Tue, 22 Oct 2019 14:31:20 +0100 Message-Id: <20191022133134.14487-28-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191022133134.14487-1-peter.maydell@linaro.org> References: <20191022133134.14487-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::433 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Continue setting, but not relying upon, env->hflags. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191018174431.1784-18-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/translate-a64.c | 13 +++++++++++-- target/arm/translate.c | 28 +++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 2d6cd09634c..d4bebbe6295 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1789,8 +1789,17 @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { /* I/O operations must end the TB here (whether read or write) */ s->base.is_jmp = DISAS_UPDATE; - } else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { - /* We default to ending the TB on a coprocessor register write, + } + if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { + /* + * A write to any coprocessor regiser that ends a TB + * must rebuild the hflags for the next TB. + */ + TCGv_i32 tcg_el = tcg_const_i32(s->current_el); + gen_helper_rebuild_hflags_a64(cpu_env, tcg_el); + tcg_temp_free_i32(tcg_el); + /* + * We default to ending the TB on a coprocessor register write, * but allow this to be suppressed by the register definition * (usually only necessary to work around guest bugs). */ diff --git a/target/arm/translate.c b/target/arm/translate.c index 96340520ee2..46a0bf51c95 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -6890,6 +6890,8 @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) ri = get_arm_cp_reginfo(s->cp_regs, ENCODE_CP_REG(cpnum, is64, s->ns, crn, crm, opc1, opc2)); if (ri) { + bool need_exit_tb; + /* Check access permissions */ if (!cp_access_ok(s->current_el, ri, isread)) { return 1; @@ -7068,14 +7070,30 @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) } } - if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { - /* I/O operations must end the TB here (whether read or write) */ - gen_lookup_tb(s); - } else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { - /* We default to ending the TB on a coprocessor register write, + /* I/O operations must end the TB here (whether read or write) */ + need_exit_tb = ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && + (ri->type & ARM_CP_IO)); + + if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { + /* + * A write to any coprocessor regiser that ends a TB + * must rebuild the hflags for the next TB. + */ + TCGv_i32 tcg_el = tcg_const_i32(s->current_el); + if (arm_dc_feature(s, ARM_FEATURE_M)) { + gen_helper_rebuild_hflags_m32(cpu_env, tcg_el); + } else { + gen_helper_rebuild_hflags_a32(cpu_env, tcg_el); + } + tcg_temp_free_i32(tcg_el); + /* + * We default to ending the TB on a coprocessor register write, * but allow this to be suppressed by the register definition * (usually only necessary to work around guest bugs). */ + need_exit_tb = true; + } + if (need_exit_tb) { gen_lookup_tb(s); } -- 2.20.1