From patchwork Wed Oct 23 15:00:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 177306 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp885464ill; Wed, 23 Oct 2019 08:30:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqBDbGSBlhE9SWPOiYLxEp7DUQGBifzlciAOy30Jgn1JSvy7Vso7yt9PiNLIsNo3p/rDak X-Received: by 2002:a05:6402:1511:: with SMTP id f17mr38116076edw.232.1571844635483; Wed, 23 Oct 2019 08:30:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571844635; cv=none; d=google.com; s=arc-20160816; b=eiVKV5sbcCKg+yM0dzjYLMZIFPJCRkeIKtfowNHgkoMn6orI6ckwM0LX8weD2+MslN 27ViUlPLEvR4WnGDU07jVuK1PbBkhJR5GobUUQoHoJc0+7a/lColFOqU/17wh7mQ1rRA gKQRhWenW4vTNt0QyTOMei3MZeW9lw60/QNHCqOxW16gxo+D+JJQ10J5x5mM6q11tGSp +JzzFCopAcIuFzEk3fspKfiNAc43nwqkDwe8SoBoW7HXYrlo+/55Y+tecSvuYZig5EE4 o9VORMbugIQJqWoJEWBipzsM24YDezxEEuabIaMOQAauzvh/UpBqknizJKg9d128GtQ3 19uw== 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=LNnrsVkwlgJ6QoJB/sOp9/3FjmMcP/pJsCavmGVFX6A=; b=IAh4JcZNxU4Yr/tAclgcsquGvzsebD8q1UGQDc8ACbqA8PCcg+pduw+NId5V60UZQH ZisQbLJh5VghErg70PLawwZs+b+RSGesKJavFJ5LRn0dlcbH1PWbuYTNiQyUUr8Rlje5 Xc3l3o6kodOY/bGtzkNZdzLYRJGBT3YaKyHraS5rhzoPGk+F6xRoRAjs9fiX4UJNV1Cg ysA2bgLXhGLogk99s6u8eHj0FcFhfkSdRpBl+R7pXU6BfLy4iyWFsOLe6yZyVt4vg+yf x1dvIQ/0mq+LhhMMSesegAjrLQ73pWxXV93nzAwE1X1lAmPA6BgVZ7WtxR1mJIrBEDMj bnIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PI8SmEt0; 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 j26si3196441ejd.138.2019.10.23.08.30.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Oct 2019 08:30:35 -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=PI8SmEt0; 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]:39554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNIan-00083e-9D for patch@linaro.org; Wed, 23 Oct 2019 11:30:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35340) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNI8v-0008Cl-OM for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:01:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNI8r-0001HJ-Uy for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:01:45 -0400 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]:34709) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNI8r-00019T-Na for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:01:41 -0400 Received: by mail-qt1-x844.google.com with SMTP id e14so12965632qto.1 for ; Wed, 23 Oct 2019 08:01:28 -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=LNnrsVkwlgJ6QoJB/sOp9/3FjmMcP/pJsCavmGVFX6A=; b=PI8SmEt0aWF4SMPYVp+5sC2i8RM3azhNXYGSc+CvtQ8YlR5iFc2AxLG0r4mM5pCgmy c5WNM9XNMFvTP6LfK69OIwvCqLYqlVcrFaE2k2xIak8XvzOFkcnQAvNIt2KkJlj+yP7q V4SMg2kudwbrWNcnK+TQEziGrSOntG92jqw6CgWPjTfPQehw366erv8H4ZBWrWc3t+SN Is27wco728zLE0P/jaBR+MLCvnxgydHRb1NzbnzokNAx/TcZvzRd5tsqwOSWJHhH214R HQlkhNrc9eaeNuL2XoNCe1v/hEfAftaXkdRzJH06lgvWGKLDTxdBpC9WtUW0+6AKmkbW 3aLg== 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=LNnrsVkwlgJ6QoJB/sOp9/3FjmMcP/pJsCavmGVFX6A=; b=qbf6aCU++pMmirTLICLl8ZtaJMMnuDsDCygKCWiw4eWPxVZpuyoeaesukkRZQ0grOG LIunIkndEBy28jIGfIzd5hUB2hu3Wj0MHZ+llHG9P4Qu4mQEPysx2at3/ASC5E1Q/OQk IuqWDXEshtlPaNZBrurCUEUnfl7a9bpyRTqLb/3SB4kzicrVyMXkh2R0YPF09M14iqir 4Vc79JtLKmnVNi5C7yhJTvhcWi1dduiDuS6hFiAdXNV2g4r9FagB4s4lPbYf0OAaWiZk f2i5kS1KeQvIOxU9PGl6gPbxBySlr3AHtEiuXsLrUSdXAovOlK/JSnkIA8+S0RfZTivS FYhA== X-Gm-Message-State: APjAAAX1C41JkqqtzeE6ri4qxOqWxSd5FgPOB8sQNGPxsJ3nJCRoPEtD swa93mQ3fqkwJfV5C3Wt1qS/QZPu1So= X-Received: by 2002:ac8:40c5:: with SMTP id f5mr9979337qtm.344.1571842885143; Wed, 23 Oct 2019 08:01:25 -0700 (PDT) Received: from localhost.localdomain (198-4-20-64.static.cosmoweb.net. [64.20.4.198]) by smtp.gmail.com with ESMTPSA id l189sm11030168qke.69.2019.10.23.08.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 08:01:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v9 17/24] target/arm: Rebuild hflags at MSR writes Date: Wed, 23 Oct 2019 11:00:50 -0400 Message-Id: <20191023150057.25731-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023150057.25731-1-richard.henderson@linaro.org> References: <20191023150057.25731-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::844 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 96340520ee..46a0bf51c9 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); }