From patchwork Thu Oct 17 18:51:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 176694 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1350549ill; Thu, 17 Oct 2019 12:03:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNB7+TIX5G8IkoJ5gClvyDNrNrdjbpUTa83//l6nXJnNWNpduXgwhTRHhXIi4ONN0C9G2A X-Received: by 2002:a17:906:1542:: with SMTP id c2mr4902384ejd.80.1571338994712; Thu, 17 Oct 2019 12:03:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571338994; cv=none; d=google.com; s=arc-20160816; b=IngbZuBCP8gRV9+0UDYlKmLsDSwAHU/x3brKnOi/7w6RuonhPWmuSwRzbAXdR9Dc/6 fXo1OBN1bzSrRdEBMQj9FkCUNvhscYi2KhAVpvDHHKrYtTqCqCxRUIqa2CwA7nKTc7U4 qntaO563EYGyMYd8x3FekYyHtslD+kqZjg0ho2egC4ZfWshZ2GzFwdgSOtKO1wT6otKL V/nbvGUrrU7A3/Yt4jamzZqpYz3tQRrq7GHisT1c7PwGUxxRfXOtDnup5FkoYzNwepcX xbCxIMYpW6SzfgpJJ9uxrTVcJl1mfSuIma46ZOMKGTKwpEkwbbnO0E29AAvWF1mXGOoD xojA== 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=PtanC1h+OlQIbLy4htGIe38tBGV1DOrNspWjSEGlJl4=; b=o16FrrmzXG5nEWdLCQjXhK00BA3BvOtHdGkZuwHSbnH5qgMEQzFU3LfWlUrHQ1Z6ek fdQsBq1o4GosbPGyTodzK2IOISNoLS2VOW1A3ZmpOWqtpGSPA+9e612I6wwhtYlg8mLQ TEt5oKZ39WVOtY0aNuMqBv5UY1c1kNWCd28vm3dkZuC21UL8N+pD39K9h3XQ1uiw5C/q nRnCQsuBAmYLTxCxCDVTvovCGrleaDYf8MHcXRHjmD53lD+yksNyzGl6gxiPkYzktkeL 9dXScIQZwNymnULlnxYhCQELwpI8Zxx4F9LteUpePuFONsyyR/BxCeXXMtC/pKwWQtSP OimQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SP47lDN9; 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 pv13si1997862ejb.79.2019.10.17.12.03.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 12:03:14 -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=SP47lDN9; 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]:57156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLB3I-0005yh-Ph for patch@linaro.org; Thu, 17 Oct 2019 15:03:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35285) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLAs7-0001Hd-TH for qemu-devel@nongnu.org; Thu, 17 Oct 2019 14:51:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLAs6-0000w9-Ab for qemu-devel@nongnu.org; Thu, 17 Oct 2019 14:51:39 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:34765) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iLAs6-0000u6-3P for qemu-devel@nongnu.org; Thu, 17 Oct 2019 14:51:38 -0400 Received: by mail-pl1-x641.google.com with SMTP id k7so1573844pll.1 for ; Thu, 17 Oct 2019 11:51:29 -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=PtanC1h+OlQIbLy4htGIe38tBGV1DOrNspWjSEGlJl4=; b=SP47lDN9vZ18I31VNt2RCv9GKvJZnOtP7D4EsSAibJZBPpQ83JQMttdGjZQmJTfPJb b4j8c7ZOcx7Z88iPlLkbkNHfN+hyv6pMcHTf+mHgmxHMdmKAVYo2tRCyLBRsjpU9FerR uueU7kECQJJInWekauxJuzrfWC/0/BZpVIVlaq/0WM5mvM/pmzXGNFiw41WCIsi5rKV3 Kv6hfS/0PHUlGz2jw5BnEvtkF7u0HpdYy9tEwVGOs/0cz+37cmVdGDDtdfWNoZHoepPn MOOUt9h9oFgFHDWOtUUyIYj1J9RYzCxyL0KyUIb7Cb0hRNTAPQya2hWE/Jzr9dWb6Fpt HFbw== 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=PtanC1h+OlQIbLy4htGIe38tBGV1DOrNspWjSEGlJl4=; b=DUuCJIq6OYnwPglb6dFGUdfgRDVak919CLmQddoPKGJDygHauVLbeUH7SJCbul9BOP v8r4SD8aoWfO+qEl0hMM/EFpZzEkDSMeCUmnuyfc22HRV/WbtCH4JUGA/iNgoqNAgmxO iUX+yXT43QUNLz77b8XCl5odU1jP2h9jGTWTOx5Usgl78Jp5zwNAzPjG7uom7LMiowRy mnAuKdnVRGlPZQKyc5SAOmZhqUa6WoI1yHV4Rd+kNOXpfthr7DQwn7rSsVE+R3AXUPJ2 HZ/WtgeDaFIOv0PfskY/uypE3/KNytqEtGZLxGFprnOySNIj8GxP73foDLOGKAMzuKUh V/Rg== X-Gm-Message-State: APjAAAW93gxlaRBrQEGgyyt9MqFdgmSoA5ox3rv4yDXHqd+qR3ZNXpL8 cUVIYY4wJe3NSXVXSHRee7zq54Hez88= X-Received: by 2002:a17:902:8343:: with SMTP id z3mr5544054pln.70.1571338288207; Thu, 17 Oct 2019 11:51:28 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 11:51:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 12/20] target/arm: Add arm_rebuild_hflags Date: Thu, 17 Oct 2019 11:51:02 -0700 Message-Id: <20191017185110.539-13-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::641 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" This function assumes nothing about the current state of the cpu, and writes the computed value to env->hflags. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/cpu.h | 6 ++++++ target/arm/helper.c | 30 ++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 9909ff89d4..d844ea21d8 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3297,6 +3297,12 @@ void arm_register_pre_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook, void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook, void *opaque); +/** + * arm_rebuild_hflags: + * Rebuild the cached TBFLAGS for arbitrary changed processor state. + */ +void arm_rebuild_hflags(CPUARMState *env); + /** * aa32_vfp_dreg: * Return a pointer to the Dn register within env in 32-bit mode. diff --git a/target/arm/helper.c b/target/arm/helper.c index 89aa6fd933..85de96d071 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11198,17 +11198,35 @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, return rebuild_hflags_common(env, fp_el, mmu_idx, flags); } +static uint32_t rebuild_hflags_internal(CPUARMState *env) +{ + int el = arm_current_el(env); + int fp_el = fp_exception_el(env, el); + ARMMMUIdx mmu_idx = arm_mmu_idx(env); + + if (is_a64(env)) { + return rebuild_hflags_a64(env, el, fp_el, mmu_idx); + } else if (arm_feature(env, ARM_FEATURE_M)) { + return rebuild_hflags_m32(env, fp_el, mmu_idx); + } else { + return rebuild_hflags_a32(env, fp_el, mmu_idx); + } +} + +void arm_rebuild_hflags(CPUARMState *env) +{ + env->hflags = rebuild_hflags_internal(env); +} + void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) { - ARMMMUIdx mmu_idx = arm_mmu_idx(env); - int current_el = arm_current_el(env); - int fp_el = fp_exception_el(env, current_el); uint32_t flags, pstate_for_ss; + flags = rebuild_hflags_internal(env); + if (is_a64(env)) { *pc = env->pc; - flags = rebuild_hflags_a64(env, current_el, fp_el, mmu_idx); if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { flags = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype); } @@ -11217,8 +11235,6 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, *pc = env->regs[15]; if (arm_feature(env, ARM_FEATURE_M)) { - flags = rebuild_hflags_m32(env, fp_el, mmu_idx); - if (arm_feature(env, ARM_FEATURE_M_SECURITY) && FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) != env->v7m.secure) { @@ -11242,8 +11258,6 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, flags = FIELD_DP32(flags, TBFLAG_A32, LSPACT, 1); } } else { - flags = rebuild_hflags_a32(env, fp_el, mmu_idx); - /* * Note that XSCALE_CPAR shares bits with VECSTRIDE. * Note that VECLEN+VECSTRIDE are RES0 for M-profile.