All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 17/26] target/arm: Overlap VECSTRIDE and XSCALE_CPAR TB flags
Date: Tue, 16 Apr 2019 13:57:35 +0100	[thread overview]
Message-ID: <20190416125744.27770-18-peter.maydell@linaro.org> (raw)
In-Reply-To: <20190416125744.27770-1-peter.maydell@linaro.org>

We are close to running out of TB flags for AArch32; we could
start using the cs_base word, but before we do that we can
economise on our usage by sharing the same bits for the VFP
VECSTRIDE field and the XScale XSCALE_CPAR field. This
works because no XScale CPU ever had VFP.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 target/arm/cpu.h       | 10 ++++++----
 target/arm/cpu.c       |  7 +++++++
 target/arm/helper.c    |  6 +++++-
 target/arm/translate.c |  9 +++++++--
 4 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index c436f628987..a4e4d17e787 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -3139,6 +3139,12 @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1)
 FIELD(TBFLAG_A32, THUMB, 0, 1)
 FIELD(TBFLAG_A32, VECLEN, 1, 3)
 FIELD(TBFLAG_A32, VECSTRIDE, 4, 2)
+/*
+ * We store the bottom two bits of the CPAR as TB flags and handle
+ * checks on the other bits at runtime. This shares the same bits as
+ * VECSTRIDE, which is OK as no XScale CPU has VFP.
+ */
+FIELD(TBFLAG_A32, XSCALE_CPAR, 4, 2)
 /*
  * Indicates whether cp register reads and writes by guest code should access
  * the secure or nonsecure bank of banked registers; note that this is not
@@ -3148,10 +3154,6 @@ FIELD(TBFLAG_A32, NS, 6, 1)
 FIELD(TBFLAG_A32, VFPEN, 7, 1)
 FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
 FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
-/* We store the bottom two bits of the CPAR as TB flags and handle
- * checks on the other bits at runtime
- */
-FIELD(TBFLAG_A32, XSCALE_CPAR, 17, 2)
 /* For M profile only, Handler (ie not Thread) mode */
 FIELD(TBFLAG_A32, HANDLER, 21, 1)
 /* For M profile only, whether we should generate stack-limit checks */
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 3f9c81e7e9e..dd6c4f6da8d 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -1035,6 +1035,13 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
         set_feature(env, ARM_FEATURE_THUMB_DSP);
     }
 
+    /*
+     * We rely on no XScale CPU having VFP so we can use the same bits in the
+     * TB flags field for VECSTRIDE and XSCALE_CPAR.
+     */
+    assert(!(arm_feature(env, ARM_FEATURE_VFP) &&
+             arm_feature(env, ARM_FEATURE_XSCALE)));
+
     if (arm_feature(env, ARM_FEATURE_V7) &&
         !arm_feature(env, ARM_FEATURE_M) &&
         !arm_feature(env, ARM_FEATURE_PMSA)) {
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 0c5b0a73e95..d8a9620b870 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -13375,7 +13375,11 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
             || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) {
             flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1);
         }
-        flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar);
+        /* Note that XSCALE_CPAR shares bits with VECSTRIDE */
+        if (arm_feature(env, ARM_FEATURE_XSCALE)) {
+            flags = FIELD_DP32(flags, TBFLAG_A32,
+                               XSCALE_CPAR, env->cp15.c15_cpar);
+        }
     }
 
     flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, arm_to_core_mmu_idx(mmu_idx));
diff --git a/target/arm/translate.c b/target/arm/translate.c
index d280b3a9a3a..9172a382c4d 100644
--- a/target/arm/translate.c
+++ b/target/arm/translate.c
@@ -13329,8 +13329,13 @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
     dc->fp_excp_el = FIELD_EX32(tb_flags, TBFLAG_ANY, FPEXC_EL);
     dc->vfp_enabled = FIELD_EX32(tb_flags, TBFLAG_A32, VFPEN);
     dc->vec_len = FIELD_EX32(tb_flags, TBFLAG_A32, VECLEN);
-    dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE);
-    dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR);
+    if (arm_feature(env, ARM_FEATURE_XSCALE)) {
+        dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR);
+        dc->vec_stride = 0;
+    } else {
+        dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE);
+        dc->c15_cpar = 0;
+    }
     dc->v7m_handler_mode = FIELD_EX32(tb_flags, TBFLAG_A32, HANDLER);
     dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) &&
         regime_is_secure(env, dc->mmu_idx);
-- 
2.20.1

  parent reply	other threads:[~2019-04-16 12:58 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-16 12:57 [Qemu-devel] [PATCH 00/26] target/arm: Implement M profile floating point Peter Maydell
2019-04-16 12:57 ` [Qemu-devel] [PATCH 01/26] target/arm: Make sure M-profile FPSCR RES0 bits are not settable Peter Maydell
2019-04-23 17:25   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 02/26] hw/intc/armv7m_nvic: Allow reading of M-profile MVFR* registers Peter Maydell
2019-04-23 17:27   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 03/26] target/arm: Implement dummy versions of M-profile FP-related registers Peter Maydell
2019-04-23 17:55   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 04/26] target/arm: Disable most VFP sysregs for M-profile Peter Maydell
2019-04-23 18:08   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 05/26] target/arm: Honour M-profile FP enable bits Peter Maydell
2019-04-23 18:19   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 06/26] target/arm: Decode FP instructions for M profile Peter Maydell
2019-04-23 18:37   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 07/26] target/arm: Clear CONTROL_S.SFPA in SG insn if FPU present Peter Maydell
2019-04-23 20:58   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 08/26] target/arm: Handle SFPA and FPCA bits in reads and writes of CONTROL Peter Maydell
2019-04-23 21:33   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 09/26] target/arm/helper: don't return early for STKOF faults during stacking Peter Maydell
2019-04-23 21:46   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 10/26] target/arm: Handle floating point registers in exception entry Peter Maydell
2019-04-23 22:21   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 11/26] target/arm: Implement v7m_update_fpccr() Peter Maydell
2019-04-16 12:57 ` [Qemu-devel] [PATCH 12/26] target/arm: Clear CONTROL.SFPA in BXNS and BLXNS Peter Maydell
2019-04-23 22:50   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 13/26] target/arm: Clean excReturn bits when tail chaining Peter Maydell
2019-04-23 22:54   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 14/26] target/arm: Allow for floating point in callee stack integrity check Peter Maydell
2019-04-23 23:04   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 15/26] target/arm: Handle floating point registers in exception return Peter Maydell
2019-04-23 23:29   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 16/26] target/arm: Move NS TBFLAG from bit 19 to bit 6 Peter Maydell
2019-04-23 23:47   ` Richard Henderson
2019-04-16 12:57 ` Peter Maydell [this message]
2019-04-23 23:51   ` [Qemu-devel] [PATCH 17/26] target/arm: Overlap VECSTRIDE and XSCALE_CPAR TB flags Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 18/26] target/arm: Set FPCCR.S when executing M-profile floating point insns Peter Maydell
2019-04-24  0:00   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 19/26] target/arm: Activate M-profile floating point context when FPCCR.ASPEN is set Peter Maydell
2019-04-24  0:08   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 20/26] target/arm: New helper function arm_v7m_mmu_idx_all() Peter Maydell
2019-04-24  0:12   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 21/26] target/arm: New function armv7m_nvic_set_pending_lazyfp() Peter Maydell
2019-04-24  1:10   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 22/26] target/arm: Add lazy-FP-stacking support to v7m_stack_write() Peter Maydell
2019-04-24  1:27   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 23/26] target/arm: Implement M-profile lazy FP state preservation Peter Maydell
2019-04-24  2:04   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 24/26] target/arm: Implement VLSTM for v7M CPUs with an FPU Peter Maydell
2019-04-24  2:17   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 25/26] target/arm: Implement VLLDM " Peter Maydell
2019-04-24  2:21   ` Richard Henderson
2019-04-16 12:57 ` [Qemu-devel] [PATCH 26/26] target/arm: Enable FPU for Cortex-M4 and Cortex-M33 Peter Maydell
2019-04-24  2:25   ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190416125744.27770-18-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.