From patchwork Tue Oct 22 13:31:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 177183 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp4896723ill; Tue, 22 Oct 2019 06:53:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSjWVWvLsmsYzuc66ONmx40TCEhFRCPaWVL2t8D4GjMOqmNy4l4KXx8X1L+tdi2U8cgAaP X-Received: by 2002:ac8:183:: with SMTP id x3mr3389387qtf.279.1571752436388; Tue, 22 Oct 2019 06:53:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571752436; cv=none; d=google.com; s=arc-20160816; b=CLa6XdUWodQxBajUx+DSCeRyIz6Twt9cffuGJF9rPgRJYYZFI41qVnVixP7lD3Yzfa 4Mga8/CRSucF7/1N1/S2izYHFxhNb2PWf5mk5fhZkv10wMOvi+ESk7TIDluJSOTyMbSO IRIhL0FlJ1t+INK2ga9r26wW4s+VU7ozqLsW3JNg1yRosOEchcNPTJIvhpbvmtKFvMdu pSgRYlB15ixHScs+rxz0s2CjkzBRi6qzlDe4OEUSd8ZdY8XSCFxcYrBpY0guUQ0DwKqv wlDAW4VJY4k6oA/MYAuOcq2gQL0wBLHo3d1cWZFDkXFug+7FPtbyAgBdYwvlba/7eBQY nS1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=GSepKuBdExAvu93R1VSsheMCP0CVd7/15avmFDHul9k=; b=oJiMr8MNpecs9drllMsnxIQ81JtrwaBnz/RiCsKEuBpIEyGdliGVIVO1TVpOH/8BQh yEVywn0AAnfLL1ZsYl3cwsiU6InZtOpRIhl+MOh8fqSKekWacdU1mTtzlb9L8bArizsh PA3rXU7fyej/I/H4DPGuUc9n/jdPi+ZOAkLLDEZjDXy91cfxG96ezU75UYv+WFjGP9Ye I2S4yvNQ8o5ybQfHUF81Fcd4qE2o/Fr05ERs40VRYRM7bP8U/8bR66NC/KZxe898UBCa 5fwaiNnwap+U4Y9F09kcdl9Y34rLGhjdGCekY82C1bHncr6jsGTavraZ54tfExzrjd1n VpCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cu3apOc5; 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 i21si15745073qkg.155.2019.10.22.06.53.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Oct 2019 06:53:56 -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=Cu3apOc5; 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]:57790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMubj-0002UK-7P for patch@linaro.org; Tue, 22 Oct 2019 09:53:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36930) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMuH3-00031b-Rs for qemu-devel@nongnu.org; Tue, 22 Oct 2019 09:32:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iMuH2-0001OL-Ge for qemu-devel@nongnu.org; Tue, 22 Oct 2019 09:32:33 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:34432) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iMuH2-0001O8-AY for qemu-devel@nongnu.org; Tue, 22 Oct 2019 09:32:32 -0400 Received: by mail-wr1-x443.google.com with SMTP id t16so12960321wrr.1 for ; Tue, 22 Oct 2019 06:32:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=GSepKuBdExAvu93R1VSsheMCP0CVd7/15avmFDHul9k=; b=Cu3apOc5mDK9FyIqAQNVtQUXMl94slUh8V1K1GQ/fK117UuOaTKcxgPA8XYf0RUogQ CWXUac3OW+YxXgdEIJGa87LAY3+DP19Jwf9Lnt/gxz6UpdwQ8vox+qTikFWn95DAC7F+ EijFyh4S07tMhM2LhC9/zT6v93LHw5pKmhn4LWBpfX8lJwaMigAsyHL65Z1yl39N2mmW ePVrXGt9xIGg5p9gbeLh8UY0RYpXaQqxvA6LsNWDHHyEG95USYExhTn0ILJJA/3EbbB+ R5UD1zGszxoD9W0EcEF7QkXy/UrGitO5hhKQ269q5hIaLH14RiQ8j24UTI2BuxtzobrK DGWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GSepKuBdExAvu93R1VSsheMCP0CVd7/15avmFDHul9k=; b=YuWqKO313LmDYjUCDeSuVIThSEuhMI2KVzTjudSIOWKQIJ4HRw7oIpreVLRNUG1fvH u5bjkAg+drLud5TpQVBeC161k1U7Aoc8E5+ulJCy8HrR0nuE3iCjWGR6jkL5HQk6p00u y0leMlJPmFCckKrH3d83MFEyaBHEWwfz9RseqjC9NOczCvK7s2AJQj0nHJoMzjmFOVl3 fGZsoXOsCo4jWm9Md2qn0DZXIdRONsl+HNAC9REj5AwUNKUFQ3WpYtWK93+qppAetCiK tgSQwKkGTrleXzs7LlzvpUqsjNnTJI7hNLjP5Ay2wPiY7HSJBsshR6yAv9l5lcaSuB5A x94Q== X-Gm-Message-State: APjAAAVOVyeBgH5NI0/LkETcTmO5yxd3f5fh7poL/+Nf4mILMX1yTxcq D6ySYHgJ5xUXozoeqxwETiC1L5tL6FU= X-Received: by 2002:adf:d84c:: with SMTP id k12mr3781298wrl.235.1571751150694; Tue, 22 Oct 2019 06:32:30 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r2sm20263856wma.1.2019.10.22.06.32.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 06:32:29 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 22/41] target/arm: Add arm_rebuild_hflags Date: Tue, 22 Oct 2019 14:31:15 +0100 Message-Id: <20191022133134.14487-23-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191022133134.14487-1-peter.maydell@linaro.org> References: <20191022133134.14487-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson 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 Message-id: 20191018174431.1784-13-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.h | 6 ++++++ target/arm/helper.c | 30 ++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 9909ff89d4f..d844ea21d8d 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 89aa6fd9339..85de96d071a 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.