All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PULL 06/33] target/arm: Convert barrier insns to decodetree
Date: Mon, 19 Jun 2023 15:28:47 +0100	[thread overview]
Message-ID: <20230619142914.963184-7-peter.maydell@linaro.org> (raw)
In-Reply-To: <20230619142914.963184-1-peter.maydell@linaro.org>

Convert the insns in the "Barriers" instruction class to
decodetree: CLREX, DSB, DMB, ISB and SB.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20230602155223.2040685-4-peter.maydell@linaro.org
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/tcg/a64.decode      |  7 +++
 target/arm/tcg/translate-a64.c | 92 ++++++++++++++--------------------
 2 files changed, 46 insertions(+), 53 deletions(-)

diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode
index 1efd436e175..b3608d38dc9 100644
--- a/target/arm/tcg/a64.decode
+++ b/target/arm/tcg/a64.decode
@@ -181,3 +181,10 @@ ERETA           1101011 0100 11111 00001 m:1 11111 11111 &reta  # ERETAA, ERETAB
   # that isn't specifically allocated to an instruction must NOP
   NOP           1101 0101 0000 0011 0010 ---- --- 11111
 }
+
+# Barriers
+
+CLREX           1101 0101 0000 0011 0011 ---- 010 11111
+DSB_DMB         1101 0101 0000 0011 0011 domain:2 types:2 10- 11111
+ISB             1101 0101 0000 0011 0011 ---- 110 11111
+SB              1101 0101 0000 0011 0011 0000 111 11111
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
index eb8addac1b3..088dfd8b1fd 100644
--- a/target/arm/tcg/translate-a64.c
+++ b/target/arm/tcg/translate-a64.c
@@ -1812,67 +1812,56 @@ static bool trans_AUTIBSP(DisasContext *s, arg_AUTIBSP *a)
     return true;
 }
 
-static void gen_clrex(DisasContext *s, uint32_t insn)
+static bool trans_CLREX(DisasContext *s, arg_CLREX *a)
 {
     tcg_gen_movi_i64(cpu_exclusive_addr, -1);
+    return true;
 }
 
-/* CLREX, DSB, DMB, ISB */
-static void handle_sync(DisasContext *s, uint32_t insn,
-                        unsigned int op1, unsigned int op2, unsigned int crm)
+static bool trans_DSB_DMB(DisasContext *s, arg_DSB_DMB *a)
 {
+    /* We handle DSB and DMB the same way */
     TCGBar bar;
 
-    if (op1 != 3) {
-        unallocated_encoding(s);
-        return;
+    switch (a->types) {
+    case 1: /* MBReqTypes_Reads */
+        bar = TCG_BAR_SC | TCG_MO_LD_LD | TCG_MO_LD_ST;
+        break;
+    case 2: /* MBReqTypes_Writes */
+        bar = TCG_BAR_SC | TCG_MO_ST_ST;
+        break;
+    default: /* MBReqTypes_All */
+        bar = TCG_BAR_SC | TCG_MO_ALL;
+        break;
     }
+    tcg_gen_mb(bar);
+    return true;
+}
 
-    switch (op2) {
-    case 2: /* CLREX */
-        gen_clrex(s, insn);
-        return;
-    case 4: /* DSB */
-    case 5: /* DMB */
-        switch (crm & 3) {
-        case 1: /* MBReqTypes_Reads */
-            bar = TCG_BAR_SC | TCG_MO_LD_LD | TCG_MO_LD_ST;
-            break;
-        case 2: /* MBReqTypes_Writes */
-            bar = TCG_BAR_SC | TCG_MO_ST_ST;
-            break;
-        default: /* MBReqTypes_All */
-            bar = TCG_BAR_SC | TCG_MO_ALL;
-            break;
-        }
-        tcg_gen_mb(bar);
-        return;
-    case 6: /* ISB */
-        /* We need to break the TB after this insn to execute
-         * a self-modified code correctly and also to take
-         * any pending interrupts immediately.
-         */
-        reset_btype(s);
-        gen_goto_tb(s, 0, 4);
-        return;
+static bool trans_ISB(DisasContext *s, arg_ISB *a)
+{
+    /*
+     * We need to break the TB after this insn to execute
+     * self-modifying code correctly and also to take
+     * any pending interrupts immediately.
+     */
+    reset_btype(s);
+    gen_goto_tb(s, 0, 4);
+    return true;
+}
 
-    case 7: /* SB */
-        if (crm != 0 || !dc_isar_feature(aa64_sb, s)) {
-            goto do_unallocated;
-        }
-        /*
-         * TODO: There is no speculation barrier opcode for TCG;
-         * MB and end the TB instead.
-         */
-        tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
-        gen_goto_tb(s, 0, 4);
-        return;
-
-    default:
-    do_unallocated:
-        unallocated_encoding(s);
-        return;
+static bool trans_SB(DisasContext *s, arg_SB *a)
+{
+    if (!dc_isar_feature(aa64_sb, s)) {
+        return false;
     }
+    /*
+     * TODO: There is no speculation barrier opcode for TCG;
+     * MB and end the TB instead.
+     */
+    tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
+    gen_goto_tb(s, 0, 4);
+    return true;
 }
 
 static void gen_xaflag(void)
@@ -2336,9 +2325,6 @@ static void disas_system(DisasContext *s, uint32_t insn)
             return;
         }
         switch (crn) {
-        case 3: /* CLREX, DSB, DMB, ISB */
-            handle_sync(s, insn, op1, op2, crm);
-            break;
         case 4: /* MSR (immediate) */
             handle_msr_i(s, insn, op1, op2, crm);
             break;
-- 
2.34.1



  parent reply	other threads:[~2023-06-19 14:36 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-19 14:28 [PULL 00/33] target-arm queue Peter Maydell
2023-06-19 14:28 ` [PULL 01/33] target/arm: Fix return value from LDSMIN/LDSMAX 8/16 bit atomics Peter Maydell
2023-06-19 14:28 ` [PULL 02/33] target/arm: Return correct result for LDG when ATA=0 Peter Maydell
2023-06-19 14:28 ` [PULL 03/33] target/arm: Pass memop to gen_mte_check1_mmuidx() in reg_imm9 decode Peter Maydell
2023-06-19 14:28 ` [PULL 04/33] target/arm: Consistently use finalize_memop_asimd() for ASIMD loads/stores Peter Maydell
2023-06-19 14:28 ` [PULL 05/33] target/arm: Convert hint instruction space to decodetree Peter Maydell
2023-06-19 14:28 ` Peter Maydell [this message]
2023-06-19 14:28 ` [PULL 07/33] target/arm: Convert CFINV, XAFLAG and AXFLAG " Peter Maydell
2023-06-19 14:28 ` [PULL 08/33] target/arm: Convert MSR (immediate) " Peter Maydell
2023-06-19 14:28 ` [PULL 09/33] target/arm: Convert MSR (reg), MRS, SYS, SYSL " Peter Maydell
2023-06-19 14:28 ` [PULL 10/33] target/arm: Convert exception generation instructions " Peter Maydell
2023-06-19 14:28 ` [PULL 11/33] target/arm: Convert load/store exclusive and ordered " Peter Maydell
2023-06-19 14:28 ` [PULL 12/33] target/arm: Convert LDXP, STXP, CASP, CAS " Peter Maydell
2023-06-19 14:28 ` [PULL 13/33] target/arm: Convert load reg (literal) group " Peter Maydell
2023-06-19 14:28 ` [PULL 14/33] target/arm: Convert load/store-pair " Peter Maydell
2023-06-19 14:28 ` [PULL 15/33] target/arm: Convert ld/st reg+imm9 insns " Peter Maydell
2023-06-19 14:28 ` [PULL 16/33] target/arm: Convert LDR/STR with 12-bit immediate " Peter Maydell
2023-06-19 14:28 ` [PULL 17/33] target/arm: Convert LDR/STR reg+reg " Peter Maydell
2023-06-19 14:28 ` [PULL 18/33] target/arm: Convert atomic memory ops " Peter Maydell
2023-06-19 14:29 ` [PULL 19/33] target/arm: Convert load (pointer auth) insns " Peter Maydell
2023-06-19 14:29 ` [PULL 20/33] target/arm: Convert LDAPR/STLR (imm) " Peter Maydell
2023-06-19 14:29 ` [PULL 21/33] target/arm: Convert load/store (multiple structures) " Peter Maydell
2023-06-19 14:29 ` [PULL 22/33] target/arm: Convert load/store single structure " Peter Maydell
2023-06-19 14:29 ` [PULL 23/33] target/arm: Convert load/store tags insns " Peter Maydell
2023-06-19 14:29 ` [PULL 24/33] hw/intc/allwinner-a10-pic: Handle IRQ levels other than 0 or 1 Peter Maydell
2023-06-19 14:29 ` [PULL 25/33] hw/sd/allwinner-sdhost: Don't send non-boolean IRQ line levels Peter Maydell
2023-06-19 14:29 ` [PULL 26/33] hw/timer/nrf51_timer: Don't lose time when timer is queried in tight loop Peter Maydell
2023-06-19 14:29 ` [PULL 27/33] hw/arm/Kconfig: sbsa-ref uses Bochs display Peter Maydell
2023-06-19 14:29 ` [PULL 28/33] imx_serial: set wake bit when we receive a data byte Peter Maydell
2023-06-19 14:29 ` [PULL 29/33] docs: sbsa: document board to firmware interface Peter Maydell
2023-06-19 14:29 ` [PULL 30/33] hw/arm/raspi: Import Linux raspi definitions as 'raspberrypi-fw-defs.h' Peter Maydell
2023-06-19 14:29 ` [PULL 31/33] hw/misc/bcm2835_property: Use 'raspberrypi-fw-defs.h' definitions Peter Maydell
2023-06-19 14:29 ` [PULL 32/33] hw/misc/bcm2835_property: Replace magic frequency values by definitions Peter Maydell
2023-06-19 14:29 ` [PULL 33/33] hw/misc/bcm2835_property: Handle CORE_CLK_ID firmware property Peter Maydell
2023-06-19 16:58 ` [PULL 00/33] target-arm queue 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=20230619142914.963184-7-peter.maydell@linaro.org \
    --to=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 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.