From mboxrd@z Thu Jan 1 00:00:00 1970 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.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 56A3FCA9EA9 for ; Fri, 18 Oct 2019 17:55:14 +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 287B0222C2 for ; Fri, 18 Oct 2019 17:55:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="FPZScvTz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 287B0222C2 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]:44394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLWT2-0000pj-Pc for qemu-devel@archiver.kernel.org; Fri, 18 Oct 2019 13:55:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59321) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLWJ0-0006eQ-0l for qemu-devel@nongnu.org; Fri, 18 Oct 2019 13:44:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLWIy-0005Vg-Ma for qemu-devel@nongnu.org; Fri, 18 Oct 2019 13:44:49 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:40952) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iLWIy-0005V0-G2 for qemu-devel@nongnu.org; Fri, 18 Oct 2019 13:44:48 -0400 Received: by mail-pf1-x444.google.com with SMTP id x127so4316165pfb.7 for ; Fri, 18 Oct 2019 10:44:48 -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=FPZScvTzDGijzfsnuo08ASLnDHdJ5jbt9rzyrPrCCvwHqStJdW3b28sF3atJoDgM8O 2xLzYSURiSEYnOVegGcspyTFAVSYtNIi21D3A2jqh53FPWgc5bg0oUh8t2pLdG/9EU2E szPMfQqOQWIOkAMdWiIw1Ds0ggq/9yoyPkIbgC9gnXR3UcJiYTaZl0/CZ1cj6IlVaOex 37WpfsysgYtcKtMlQEgP3Gxv/5Ug95AcUFjzq1RyiNUoqVBfDsdpafRMvROvP0PZQTaD fQtat0CS4uDsj17m6YjnxIRZ/Ftn9rjNSxOxflAKXPBcnRPn1asEWw7k+GCo9t97Akxq NlNg== 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=PZX8S2lG100Wmx2ch+NG/G70CDxgpY+DLRK0Fg0ggRdwOOVsBLh+PhBn3HbWtQmi+C CmX04OepSmAr8GD1QJ49Qf94YZNV9iR8KcvL6kGFHxu9iuVMJUjj2ckQLATiAwIZSzzY xMQsd2a24QzLd70d7OWjriK3Y0Bki9ZwcLacSf1x6BrYuTy1zvagoxfGBRgnnf6kXZcP zOsR39b8IN/VyUP9n0eaXP8gTKkbr4pn46h8L6FHPZe5gVHKEzFN4Ubwod++khslSLco DKK1NPSw5eQ2nt8XjqQdiwUnqiFJ4ZNeEWHZTWCsUwL6iXW2hzaisLiCDpU0dcYZ4Ukl CR7Q== X-Gm-Message-State: APjAAAUambk4/JB12I2YYFy9JLYV3bzUOdLOsSxPoNVtmK+jFO5FLa+F mKncVirCKG2d0F8CLMdLdvrRpbPZqcQ= X-Google-Smtp-Source: APXvYqytu68A6TSchkWFuCUtRMprxxoCQHbhKlWOktVnDcrG+vmVjoDHKoL66oIlYsXMVO24j1mLNQ== X-Received: by 2002:a63:3d41:: with SMTP id k62mr11117117pga.129.1571420687048; Fri, 18 Oct 2019 10:44:47 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2019 10:44:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v8 12/22] target/arm: Add arm_rebuild_hflags Date: Fri, 18 Oct 2019 10:44:21 -0700 Message-Id: <20191018174431.1784-13-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 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: 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+qemu-devel=archiver.kernel.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(-) 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. -- 2.17.1