From patchwork Thu Oct 17 18:51:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 176685 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1339260ill; Thu, 17 Oct 2019 11:53:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcfjRe4iTzROqXkKGpqAPF4t9wlqUDbQpYbM1yLg5scDKp/IRPNP6f77JKj0APL2FQPOk5 X-Received: by 2002:a50:eb42:: with SMTP id z2mr5383168edp.291.1571338405741; Thu, 17 Oct 2019 11:53:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571338405; cv=none; d=google.com; s=arc-20160816; b=Pw1wP3lXf6CIfl6OtaqNBJlh/UYI0u1xH96YCs2EggTjuS+7FAD2BQnVDxaTjDF5oa LqefxCJ8Bg7rALJloz9zQ/jPoD1nB547m9APCcDyY/TSx5oV07TTO/zgvAc2ceeHBMdv G/hfGD6kv491A4JDJizhPKH3aIofwkJDC2gU2dnOWQatVCN+GeV4D7b0HS0s72q8e9J4 hf4iumhAMsA7mzQENLvWjkq7NBkcx0Jd8z0c/D2Lf6JGNOqmJDaK4Ta2SjbQJ0dVYFCc wQaMn9zVUXCFPD7s8uPvpeVaeM8GudrBc/bM0nlrlQICUYKCCxHpT6UZR9RA1TdVfyY0 keEw== 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=LMHVMFO3ja8BoeTBJ2Ygz3ukCoF3zjaLM/bgpx5A4eBV+vKAApDyrrVOzgJrjmc9/r DvcPX8P2GJn9CKRE++MKzfymye281klQ/JVD+MMK3ZopvwqKPVnZzEuI8p7429my2vLg D4W//l5BNSR5oTKwZ090eCpKcCSB/cd9cvaoeuQUmzjT2auyMabYldvuZr5GBK0W4Rn+ Qy0kwHsEFMzizJhwUczBZQaEX9rfxc8KmuydlAOkQY8BlzrgJ/SqI5fnpYx9U93mSuRv tb3J3xPvSAy55UsA5zRE6akSsRagm2ZIrOm+PqECHwRTAgd0lXd1033iWffGtcCY/OFU K9Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IiuVEfLf; 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 29si2103216eje.235.2019.10.17.11.53.25 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 11:53:25 -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=IiuVEfLf; 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]:56962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLAtn-0003IN-Vq for patch@linaro.org; Thu, 17 Oct 2019 14:53:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35390) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLAs9-0001KN-B8 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 14:51:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLAs6-0000xB-IH for qemu-devel@nongnu.org; Thu, 17 Oct 2019 14:51:41 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:43868) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iLAs6-0000vO-Af for qemu-devel@nongnu.org; Thu, 17 Oct 2019 14:51:38 -0400 Received: by mail-pf1-x444.google.com with SMTP id a2so2205646pfo.10 for ; Thu, 17 Oct 2019 11:51:36 -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=IiuVEfLf5+TKjAGIxfM3Cl2hkN4WSbjcY4rplM0tp+pBS4sNEcM6FffTkXxmpT8DV1 u7iLsMVR0fk1nsdpjsCuDmv6cdF7jEAZxHerfu/MMXM1I9Fx034cS6YxeVYiGNx6vuj5 KEbqabNhtejIbwEObLto6LcqpAb/VGWrYWkYMngEU5RDnFmi5rFBBcw3urzEi+Tka1Ux JiR3EdUM/iqu7OzvjjhuVZt7w+JDb1qUX5qPSCHtwDbMVVmLAXRSJJXjmoknuCihTSpM Ksj+lqBa4/66Jl6ZCvjVdxghw08WsaPizSNppxzUR9paT/RnxtYwsFBfvEdZ3GxlQpDr CkBQ== 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=RvIRILy7qNEz2cweTNHGADM0Lfd68qUJf+idpxCjMU00KLqi/R4zn7omiP1+LIC38v F2GkcIp9SGFRU38oMZelMXx50BoXF0tOOPDqsbTiUjktMhl0ZZF9YzVDVaO0IMfYFRM7 tJ3GvOBNylXcw2px6fDUk49IPuuKJ3/0uhOUaj9ckwiWe41YuMVH0JcyO9Hx3AVzdPEV +G3jJJo/H7GFLAR/ZA5Rw1pjTk+G7KUqlFiaEoCYLbwMzQrlJjk++Hc1bY28vw9aRXOa loU6vfy/EtX/LyPnqdlzk6k1Sp9/Urk2SlznFF57eGCvRPEc6xtxFE0HO8O+mZHHlEJ8 fi1Q== X-Gm-Message-State: APjAAAUQIxwL599JQq8+UbJzA3CL+UtdbitXDX7aNHP7Exioj0gUI0E4 en/t+PqAzp/ITP/jq/aCjoBi/NOgjgw= X-Received: by 2002:a17:90a:c405:: with SMTP id i5mr6407369pjt.9.1571338294787; Thu, 17 Oct 2019 11:51:34 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id s97sm5009256pjc.4.2019.10.17.11.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 11:51:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 17/20] target/arm: Rebuild hflags at MSR writes Date: Thu, 17 Oct 2019 11:51:07 -0700 Message-Id: <20191017185110.539-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191017185110.539-1-richard.henderson@linaro.org> References: <20191017185110.539-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); }