From patchwork Fri Oct 18 17:44:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 176933 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1201337ill; Fri, 18 Oct 2019 11:05:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqznjPFMigVoU5PMqERYp9tX4fh7FHc/nZNtRTOhfPk9xB/wzdTfvxEir6qDt47MAlGOZSsv X-Received: by 2002:a0c:c590:: with SMTP id a16mr11260833qvj.144.1571421933317; Fri, 18 Oct 2019 11:05:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571421933; cv=none; d=google.com; s=arc-20160816; b=xeGBUzCSuhgt8QSltraoulmA1qbsECLnZJ5VAvEI4gEA3SxHpDe8RuGYedNv76sL6E wnKjh1Jf8HVpu67YPFUC9lBWoIkwXRBnebz4sJJA2Uc+oos+YHEyaQ+m63whu2Pe9hwv KHE/ze1EjoeNtPaRYJTsOoXH9EiSEaQFgjHcSj0NHa+EYQDe8Md5QUA6aMeBth+cwwYz YuI5tn2FJdajINxTRSvHlJWH+i3NKDQ4UlHxsv16JMjuHH3FeEr7ZCg+ZxxxEs7pr/zP rLMeTezZGmDrOaRUM/oHzVAJke5M27fJ6gq5e10HE4a1ICl4nKD0by6RIP5RLkhhFn1J j84g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=0mb3YwiZncjKHxGhu+AsTIpQEFeyLEnUoSMmhup1oAE=; b=vQcMYctxubHW5YsqhBVGhps6zrftcFHLVFie7RVKzhtesRYucwcVwJsMXig+qtl77D g0aGH82vTOqHmhSn6ND+0EedztlqxW6Zk+a+kcEVk49EbGfqPo2s2QNhYGHzyj32phW+ 6qt3b0R8is0phXynqz+aAflaNWIy5FBF6E9kWC9x9BeA+UJBuOMJ9aTh4BMx7YPblDtJ 9WPVNNL4fqNkHOXuclbi0V3bwiRVPyW5RvQJZoHvK7x1W5O3yXnDvgSQ+olDan8t6tBA hqQf1ob8xAHbBXzxdvXLBzb7rEU2VRzICkqXfwjaPqXPm77IGt8jE1zZwUaVmEyUDXyS TXSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Jwr7py+b; 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=fail (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 o186si6014503qkc.206.2019.10.18.11.05.33 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Oct 2019 11:05:33 -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=fail header.i=@linaro.org header.s=google header.b=Jwr7py+b; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLWd1-0003Bx-Dc for patch@linaro.org; Fri, 18 Oct 2019 14:05:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59452) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLWJ7-0006oW-Pz for qemu-devel@nongnu.org; Fri, 18 Oct 2019 13:44:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLWJ5-0005bg-7p for qemu-devel@nongnu.org; Fri, 18 Oct 2019 13:44:57 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:46554) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iLWJ5-0005b1-2P for qemu-devel@nongnu.org; Fri, 18 Oct 2019 13:44:55 -0400 Received: by mail-pf1-x444.google.com with SMTP id q5so4301805pfg.13 for ; Fri, 18 Oct 2019 10:44:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0mb3YwiZncjKHxGhu+AsTIpQEFeyLEnUoSMmhup1oAE=; b=Jwr7py+bQBoYaWXfiCoTCjoDBKkiPGxT5+nrQPKZHeCpFuyXWBm3YPesYDJtr2rkXU H+gI1NQBAMM7nIjTCfxUkfFm/jwgwHWlJBZ4dJcjVE3BvHePh3CYYiU24hfpfr2hgLp0 uP0BP0626ht6iEtLZ8xnFhshCsvvqvc8ARS0sWbZ9q/P4pkmB69Y3om/cJnK4VLOQzTO ZPvNKxDqG7NRWrLIUnUFi7B0Pt1ogv6w5oAQsy+BPsvFPGmyQROmNt2ZGVaxFVYrQ/pv LPM5iBoJaWLxcL5WToWu/RjoAIMHfacy5hqBwXdNHRAv/AHuEKRwQFZviu9xnOmjlIEy F6xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0mb3YwiZncjKHxGhu+AsTIpQEFeyLEnUoSMmhup1oAE=; b=JUdqUP1SKWV4aeBYiTndEz53XRVILX3nLT5ipiivksj3KuvHrXYy/hTD+MeC+J+fTL 5R/CsmNPgfie0r5esvw2Bl08ZW/ryrVpM8uuQX5mujWJo/8q8F2njjQPd8E69ZBK4++K SEM1ZCvIWcOxXYLeq9wAYh15kL0kwALxQXmPjG6Vasbp3bBx2NWrWye+nRp+yckLApni FzZcH27QKiBHDpGiT97NCZb6mQgv8TQthSDU43W3Cx9zoRy2kOpCeS7uvLWDNGI3LSY6 fBMwjk0oQMdEQCuDSojnf7pQPzG27Gm3QjEARX2q9Fbj++BXahzDS025lCPBOJxEqwe9 GNMQ== X-Gm-Message-State: APjAAAUfv45dWERznl4QTR1v+/XJ2EqbP3XoA70vCSRllr1T3BUHMGp+ z4bxIA6pQlN+7biQz5N5AX7dyF7xynU= X-Received: by 2002:a63:4f12:: with SMTP id d18mr11835824pgb.52.1571420693696; Fri, 18 Oct 2019 10:44:53 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id d20sm7857534pfq.88.2019.10.18.10.44.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2019 10:44:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v8 17/22] target/arm: Rebuild hflags at MSR writes Date: Fri, 18 Oct 2019 10:44:26 -0700 Message-Id: <20191018174431.1784-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191018174431.1784-1-richard.henderson@linaro.org> References: <20191018174431.1784-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Continue setting, but not relying upon, env->hflags. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 13 +++++++++++-- target/arm/translate.c | 28 +++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 2d6cd09634..d4bebbe629 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 698c594e8c..cb47cd9744 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); }