qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: [Qemu-devel] [PATCH v2 02/12] target/arm: Add PSTATE.BTYPE
Date: Mon, 28 Jan 2019 14:31:08 -0800	[thread overview]
Message-ID: <20190128223118.5255-3-richard.henderson@linaro.org> (raw)
In-Reply-To: <20190128223118.5255-1-richard.henderson@linaro.org>

Place this in its own field within ENV, as that will
make it easier to reset from within TCG generated code.

With the change to pstate_read/write, exception entry
and return are automatically handled.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/cpu.h           | 8 ++++++--
 target/arm/translate-a64.c | 3 +++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index d7190f0712..76e2f8fd42 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -234,6 +234,7 @@ typedef struct CPUARMState {
      *    semantics as for AArch32, as described in the comments on each field)
      *  nRW (also known as M[4]) is kept, inverted, in env->aarch64
      *  DAIF (exception masks) are kept in env->daif
+     *  BTYPE is kept in env->btype
      *  all other bits are stored in their correct places in env->pstate
      */
     uint32_t pstate;
@@ -263,6 +264,7 @@ typedef struct CPUARMState {
     uint32_t GE; /* cpsr[19:16] */
     uint32_t thumb; /* cpsr[5]. 0 = arm mode, 1 = thumb mode. */
     uint32_t condexec_bits; /* IT bits.  cpsr[15:10,26:25].  */
+    uint32_t btype;  /* BTI branch type.  spsr[11:10].  */
     uint64_t daif; /* exception masks, in the bits they are in PSTATE */
 
     uint64_t elr_el[4]; /* AArch64 exception link regs  */
@@ -1197,6 +1199,7 @@ uint64_t get_pmceid(CPUARMState *env, unsigned which);
 #define PSTATE_I (1U << 7)
 #define PSTATE_A (1U << 8)
 #define PSTATE_D (1U << 9)
+#define PSTATE_BTYPE (3U << 10)
 #define PSTATE_IL (1U << 20)
 #define PSTATE_SS (1U << 21)
 #define PSTATE_V (1U << 28)
@@ -1205,7 +1208,7 @@ uint64_t get_pmceid(CPUARMState *env, unsigned which);
 #define PSTATE_N (1U << 31)
 #define PSTATE_NZCV (PSTATE_N | PSTATE_Z | PSTATE_C | PSTATE_V)
 #define PSTATE_DAIF (PSTATE_D | PSTATE_A | PSTATE_I | PSTATE_F)
-#define CACHED_PSTATE_BITS (PSTATE_NZCV | PSTATE_DAIF)
+#define CACHED_PSTATE_BITS (PSTATE_NZCV | PSTATE_DAIF | PSTATE_BTYPE)
 /* Mode values for AArch64 */
 #define PSTATE_MODE_EL3h 13
 #define PSTATE_MODE_EL3t 12
@@ -1237,7 +1240,7 @@ static inline uint32_t pstate_read(CPUARMState *env)
     ZF = (env->ZF == 0);
     return (env->NF & 0x80000000) | (ZF << 30)
         | (env->CF << 29) | ((env->VF & 0x80000000) >> 3)
-        | env->pstate | env->daif;
+        | env->pstate | env->daif | (env->btype << 10);
 }
 
 static inline void pstate_write(CPUARMState *env, uint32_t val)
@@ -1247,6 +1250,7 @@ static inline void pstate_write(CPUARMState *env, uint32_t val)
     env->CF = (val >> 29) & 1;
     env->VF = (val << 3) & 0x80000000;
     env->daif = val & PSTATE_DAIF;
+    env->btype = (val >> 10) & 3;
     env->pstate = val & ~CACHED_PSTATE_BITS;
 }
 
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
index 4d28a27c3b..611279e98e 100644
--- a/target/arm/translate-a64.c
+++ b/target/arm/translate-a64.c
@@ -163,6 +163,9 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f,
                 el,
                 psr & PSTATE_SP ? 'h' : 't');
 
+    if (cpu_isar_feature(aa64_bti, cpu)) {
+        cpu_fprintf(f, "  BTYPE=%d", (psr & PSTATE_BTYPE) >> 10);
+    }
     if (!(flags & CPU_DUMP_FPU)) {
         cpu_fprintf(f, "\n");
         return;
-- 
2.17.2

  parent reply	other threads:[~2019-01-28 22:42 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-28 22:31 [Qemu-devel] [PATCH v2 00/12] target/arm: Implement ARMv8.5-BTI Richard Henderson
2019-01-28 22:31 ` [Qemu-devel] [PATCH v2 01/12] target/arm: Introduce isar_feature_aa64_bti Richard Henderson
2019-01-28 22:31 ` Richard Henderson [this message]
2019-01-28 22:31 ` [Qemu-devel] [PATCH v2 03/12] target/arm: Add BT and BTYPE to tb->flags Richard Henderson
2019-01-28 22:31 ` [Qemu-devel] [PATCH v2 04/12] exec: Add target-specific tlb bits to MemTxAttrs Richard Henderson
2019-02-04 11:40   ` Peter Maydell
2019-01-28 22:31 ` [Qemu-devel] [PATCH v2 05/12] target/arm: Cache the GP bit for a page in MemTxAttrs Richard Henderson
2019-02-04 11:41   ` Peter Maydell
2019-02-04 11:58     ` Richard Henderson
2019-01-28 22:31 ` [Qemu-devel] [PATCH v2 06/12] target/arm: Default handling of BTYPE during translation Richard Henderson
2019-01-28 22:31 ` [Qemu-devel] [PATCH v2 07/12] target/arm: Reset btype for direct branches Richard Henderson
2019-02-04 11:43   ` Peter Maydell
2019-01-28 22:31 ` [Qemu-devel] [PATCH v2 08/12] target/arm: Set btype for indirect branches Richard Henderson
2019-01-28 22:31 ` [Qemu-devel] [PATCH v2 09/12] target/arm: Add x-guarded-pages cpu property for user-only Richard Henderson
2019-01-28 22:31 ` [Qemu-devel] [PATCH v2 10/12] target/arm: Enable BTI for -cpu max Richard Henderson
2019-01-28 22:31 ` [Qemu-devel] [PATCH v2 11/12] linux-user/aarch64: Reset btype for syscalls and signals Richard Henderson
2019-02-04 12:02   ` Peter Maydell
2019-02-04 12:06     ` Richard Henderson
2019-01-28 22:31 ` [Qemu-devel] [PATCH v2 12/12] tests/tcg/aarch64: Add bti smoke test Richard Henderson
2019-01-31 18:12 ` [Qemu-devel] [PATCH v2 00/12] target/arm: Implement ARMv8.5-BTI no-reply
2019-01-31 18:21 ` no-reply
2019-01-31 18:21 ` no-reply
2019-01-31 18:30 ` no-reply
2019-01-31 18:34 ` no-reply
2019-02-04 13:09 ` Peter Maydell

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=20190128223118.5255-3-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=peter.maydell@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).