From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Pedro Barbuda" <pbarbuda@microsoft.com>,
"Alexander Graf" <agraf@csgraf.de>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Mohamed Mediouni" <mohamed@unpredictable.fr>,
kvm@vger.kernel.org, qemu-arm@nongnu.org,
"Alex Bennée" <alex.bennee@linaro.org>,
"Richard Henderson" <richard.henderson@linaro.org>
Subject: [PATCH v3 02/32] target/arm: migrate system/cp trap syndromes to registerfields
Date: Wed, 22 Apr 2026 13:52:19 +0100 [thread overview]
Message-ID: <20260422125250.1303100-3-alex.bennee@linaro.org> (raw)
In-Reply-To: <20260422125250.1303100-1-alex.bennee@linaro.org>
Migrate syn_aa64_sysregtrap and co-processor register trap syndromes
to the registerfields API. The co-processor syndromes are split
between single and duel register moves.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
v2
- use !is_16bit directly
---
target/arm/syndrome.h | 124 ++++++++++++++++++++++++++++++++++--------
1 file changed, 102 insertions(+), 22 deletions(-)
diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h
index 517fb2368bc..29462aa103c 100644
--- a/target/arm/syndrome.h
+++ b/target/arm/syndrome.h
@@ -78,7 +78,7 @@ enum arm_exception_class {
/* Generic syndrome encoding layout for HSR and lower 32 bits of ESR_EL2 */
FIELD(SYNDROME, EC, 26, 6)
-FIELD(SYNDROME, IL, 25, 1)
+FIELD(SYNDROME, IL, 25, 1) /* IL=1 for 32 bit instructions */
FIELD(SYNDROME, ISS, 0, 25)
typedef enum {
@@ -172,7 +172,7 @@ static inline uint32_t syn_aa64_smc(uint32_t imm16)
static inline uint32_t syn_aa32_svc(uint32_t imm16, bool is_16bit)
{
uint32_t res = syn_set_ec(0, EC_AA32_SVC);
- res = FIELD_DP32(res, SYNDROME, IL, is_16bit ? 0 : 1);
+ res = FIELD_DP32(res, SYNDROME, IL, !is_16bit);
res = FIELD_DP32(res, ISS_IMM16, IMM16, imm16);
return res;
}
@@ -203,58 +203,138 @@ static inline uint32_t syn_aa64_bkpt(uint32_t imm16)
static inline uint32_t syn_aa32_bkpt(uint32_t imm16, bool is_16bit)
{
uint32_t res = syn_set_ec(0, EC_AA32_BKPT);
- res = FIELD_DP32(res, SYNDROME, IL, is_16bit ? 0 : 1);
+ res = FIELD_DP32(res, SYNDROME, IL, !is_16bit);
res = FIELD_DP32(res, ISS_IMM16, IMM16, imm16);
return res;
}
+/*
+ * ISS encoding for an exception from MSR, MRS, or System instruction
+ * in AArch64 state.
+ */
+FIELD(SYSREG_ISS, ISREAD, 0, 1) /* Direction, 1 is read */
+FIELD(SYSREG_ISS, CRM, 1, 4)
+FIELD(SYSREG_ISS, RT, 5, 5)
+FIELD(SYSREG_ISS, CRN, 10, 4)
+FIELD(SYSREG_ISS, OP1, 14, 3)
+FIELD(SYSREG_ISS, OP2, 17, 3)
+FIELD(SYSREG_ISS, OP0, 20, 2)
+
static inline uint32_t syn_aa64_sysregtrap(int op0, int op1, int op2,
int crn, int crm, int rt,
int isread)
{
- return (EC_SYSTEMREGISTERTRAP << ARM_EL_EC_SHIFT) | ARM_EL_IL
- | (op0 << 20) | (op2 << 17) | (op1 << 14) | (crn << 10) | (rt << 5)
- | (crm << 1) | isread;
+ uint32_t res = syn_set_ec(0, EC_SYSTEMREGISTERTRAP);
+ res = FIELD_DP32(res, SYNDROME, IL, 1);
+
+ res = FIELD_DP32(res, SYSREG_ISS, OP0, op0);
+ res = FIELD_DP32(res, SYSREG_ISS, OP2, op2);
+ res = FIELD_DP32(res, SYSREG_ISS, OP1, op1);
+ res = FIELD_DP32(res, SYSREG_ISS, CRN, crn);
+ res = FIELD_DP32(res, SYSREG_ISS, RT, rt);
+ res = FIELD_DP32(res, SYSREG_ISS, CRM, crm);
+ res = FIELD_DP32(res, SYSREG_ISS, ISREAD, isread);
+
+ return res;
}
+/*
+ * ISS encoding for an exception from an MCR or MRC access
+ * (move to/from co-processor)
+ */
+FIELD(COPROC_ISS, ISREAD, 0, 1)
+FIELD(COPROC_ISS, CRM, 1, 4)
+FIELD(COPROC_ISS, RT, 5, 5)
+FIELD(COPROC_ISS, CRN, 10, 4)
+FIELD(COPROC_ISS, OP1, 14, 3)
+FIELD(COPROC_ISS, OP2, 17, 3)
+FIELD(COPROC_ISS, COND, 20, 4)
+FIELD(COPROC_ISS, CV, 24, 1)
+
static inline uint32_t syn_cp14_rt_trap(int cv, int cond, int opc1, int opc2,
int crn, int crm, int rt, int isread,
bool is_16bit)
{
- return (EC_CP14RTTRAP << ARM_EL_EC_SHIFT)
- | (is_16bit ? 0 : ARM_EL_IL)
- | (cv << 24) | (cond << 20) | (opc2 << 17) | (opc1 << 14)
- | (crn << 10) | (rt << 5) | (crm << 1) | isread;
+ uint32_t res = syn_set_ec(0, EC_CP14RTTRAP);
+ res = FIELD_DP32(res, SYNDROME, IL, !is_16bit);
+
+ res = FIELD_DP32(res, COPROC_ISS, CV, cv);
+ res = FIELD_DP32(res, COPROC_ISS, COND, cond);
+ res = FIELD_DP32(res, COPROC_ISS, OP2, opc2);
+ res = FIELD_DP32(res, COPROC_ISS, OP1, opc1);
+ res = FIELD_DP32(res, COPROC_ISS, CRN, crn);
+ res = FIELD_DP32(res, COPROC_ISS, RT, rt);
+ res = FIELD_DP32(res, COPROC_ISS, CRM, crm);
+ res = FIELD_DP32(res, COPROC_ISS, ISREAD, isread);
+
+ return res;
}
static inline uint32_t syn_cp15_rt_trap(int cv, int cond, int opc1, int opc2,
int crn, int crm, int rt, int isread,
bool is_16bit)
{
- return (EC_CP15RTTRAP << ARM_EL_EC_SHIFT)
- | (is_16bit ? 0 : ARM_EL_IL)
- | (cv << 24) | (cond << 20) | (opc2 << 17) | (opc1 << 14)
- | (crn << 10) | (rt << 5) | (crm << 1) | isread;
+ uint32_t res = syn_set_ec(0, EC_CP15RTTRAP);
+ res = FIELD_DP32(res, SYNDROME, IL, !is_16bit);
+
+ res = FIELD_DP32(res, COPROC_ISS, CV, cv);
+ res = FIELD_DP32(res, COPROC_ISS, COND, cond);
+ res = FIELD_DP32(res, COPROC_ISS, OP2, opc2);
+ res = FIELD_DP32(res, COPROC_ISS, OP1, opc1);
+ res = FIELD_DP32(res, COPROC_ISS, CRN, crn);
+ res = FIELD_DP32(res, COPROC_ISS, RT, rt);
+ res = FIELD_DP32(res, COPROC_ISS, CRM, crm);
+ res = FIELD_DP32(res, COPROC_ISS, ISREAD, isread);
+
+ return res;
}
+/*
+ * ISS encoding for an exception from an MCRR or MRRC access
+ * (move to/from co-processor with 2 regs)
+ */
+FIELD(COPROC_R2_ISS, ISREAD, 0, 1)
+FIELD(COPROC_R2_ISS, CRM, 1, 4)
+FIELD(COPROC_R2_ISS, RT, 5, 5)
+FIELD(COPROC_R2_ISS, RT2, 10, 5)
+FIELD(COPROC_R2_ISS, OP1, 16, 4)
+FIELD(COPROC_R2_ISS, COND, 20, 4)
+FIELD(COPROC_R2_ISS, CV, 24, 1)
+
static inline uint32_t syn_cp14_rrt_trap(int cv, int cond, int opc1, int crm,
int rt, int rt2, int isread,
bool is_16bit)
{
- return (EC_CP14RRTTRAP << ARM_EL_EC_SHIFT)
- | (is_16bit ? 0 : ARM_EL_IL)
- | (cv << 24) | (cond << 20) | (opc1 << 16)
- | (rt2 << 10) | (rt << 5) | (crm << 1) | isread;
+ uint32_t res = syn_set_ec(0, EC_CP14RRTTRAP);
+ res = FIELD_DP32(res, SYNDROME, IL, !is_16bit);
+
+ res = FIELD_DP32(res, COPROC_R2_ISS, CV, cv);
+ res = FIELD_DP32(res, COPROC_R2_ISS, COND, cond);
+ res = FIELD_DP32(res, COPROC_R2_ISS, OP1, opc1);
+ res = FIELD_DP32(res, COPROC_R2_ISS, RT2, rt2);
+ res = FIELD_DP32(res, COPROC_R2_ISS, RT, rt);
+ res = FIELD_DP32(res, COPROC_R2_ISS, CRM, crm);
+ res = FIELD_DP32(res, COPROC_R2_ISS, ISREAD, isread);
+
+ return res;
}
static inline uint32_t syn_cp15_rrt_trap(int cv, int cond, int opc1, int crm,
int rt, int rt2, int isread,
bool is_16bit)
{
- return (EC_CP15RRTTRAP << ARM_EL_EC_SHIFT)
- | (is_16bit ? 0 : ARM_EL_IL)
- | (cv << 24) | (cond << 20) | (opc1 << 16)
- | (rt2 << 10) | (rt << 5) | (crm << 1) | isread;
+ uint32_t res = syn_set_ec(0, EC_CP15RRTTRAP);
+ res = FIELD_DP32(res, SYNDROME, IL, !is_16bit);
+
+ res = FIELD_DP32(res, COPROC_R2_ISS, CV, cv);
+ res = FIELD_DP32(res, COPROC_R2_ISS, COND, cond);
+ res = FIELD_DP32(res, COPROC_R2_ISS, OP1, opc1);
+ res = FIELD_DP32(res, COPROC_R2_ISS, RT2, rt2);
+ res = FIELD_DP32(res, COPROC_R2_ISS, RT, rt);
+ res = FIELD_DP32(res, COPROC_R2_ISS, CRM, crm);
+ res = FIELD_DP32(res, COPROC_R2_ISS, ISREAD, isread);
+
+ return res;
}
static inline uint32_t syn_fp_access_trap(int cv, int cond, bool is_16bit,
--
2.47.3
next prev parent reply other threads:[~2026-04-22 12:52 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-22 12:52 [PATCH v3 00/32] target/arm: fully model WFxT instructions for A-profile Alex Bennée
2026-04-22 12:52 ` [PATCH v3 01/32] target/arm: migrate basic syndrome helpers to registerfields Alex Bennée
2026-04-22 12:52 ` Alex Bennée [this message]
2026-04-22 12:52 ` [PATCH v3 03/32] target/arm: migrate FP/SIMD trap syndromes " Alex Bennée
2026-04-22 12:52 ` [PATCH v3 04/32] target/arm: migrate eret " Alex Bennée
2026-04-22 12:52 ` [PATCH v3 05/32] target/arm: migrate SME " Alex Bennée
2026-04-22 12:52 ` [PATCH v3 06/32] target/arm: migrate PAC " Alex Bennée
2026-04-22 12:52 ` [PATCH v3 07/32] target/arm: migrate BTI " Alex Bennée
2026-04-22 12:52 ` [PATCH v3 08/32] target/arm: migrate BXJ " Alex Bennée
2026-04-22 12:52 ` [PATCH v3 09/32] target/arm: migrate Granule Protection traps " Alex Bennée
2026-04-22 12:52 ` [PATCH v3 10/32] target/arm: migrate fault syndromes " Alex Bennée
2026-04-22 16:54 ` Philippe Mathieu-Daudé
2026-04-22 12:52 ` [PATCH v3 11/32] target/arm: migrate debug " Alex Bennée
2026-04-22 12:52 ` [PATCH v3 12/32] target/arm: migrate wfx " Alex Bennée
2026-04-22 12:52 ` [PATCH v3 13/32] target/arm: migrate gcs " Alex Bennée
2026-04-22 12:52 ` [PATCH v3 14/32] target/arm: migrate memory op " Alex Bennée
2026-04-22 12:52 ` [PATCH v3 15/32] target/arm: migrate check_hcr_el2_trap to use syndrome helper Alex Bennée
2026-04-22 12:52 ` [PATCH v3 16/32] target/arm: use syndrome helpers in arm_cpu_do_interrupt_aarch32_hyp Alex Bennée
2026-04-22 12:52 ` [PATCH v3 17/32] target/arm: use syndrome helpers to set SAME_EL EC bit Alex Bennée
2026-04-22 12:52 ` [PATCH v3 18/32] target/arm: make whpx use syndrome helpers for decode Alex Bennée
2026-04-22 12:52 ` [PATCH v3 19/32] target/arm: make hvf " Alex Bennée
2026-04-22 16:54 ` Philippe Mathieu-Daudé
2026-04-22 12:52 ` [PATCH v3 20/32] target/arm: use syndrome helpers in merge_syn_data_abort Alex Bennée
2026-04-22 12:52 ` [PATCH v3 21/32] target/arm: use syndrome helpers to query VNCR bit Alex Bennée
2026-04-22 12:52 ` [PATCH v3 22/32] target/arm: remove old syndrome defines Alex Bennée
2026-04-22 12:52 ` [PATCH v3 23/32] target/arm: report register in WFIT syndromes Alex Bennée
2026-04-22 12:52 ` [PATCH v3 24/32] target/arm: teach arm_cpu_has_work about halting reasons Alex Bennée
2026-04-22 12:52 ` [PATCH v3 25/32] target/arm: redefine event stream fields Alex Bennée
2026-04-22 12:52 ` [PATCH v3 26/32] target/arm: ensure aarch64 DISAS_WFE will exit Alex Bennée
2026-04-22 16:57 ` Philippe Mathieu-Daudé
2026-04-22 12:52 ` [PATCH v3 27/32] target/arm: implements SEV/SEVL for all modes Alex Bennée
2026-04-22 12:52 ` [PATCH v3 28/32] target/arm: hoist event broadcast code into a helper Alex Bennée
2026-04-22 12:52 ` [PATCH v3 29/32] target/arm: implement global monitor events Alex Bennée
2026-04-22 12:52 ` [PATCH v3 30/32] target/arm: enable event stream on WFE instructions Alex Bennée
2026-04-22 12:52 ` [PATCH v3 31/32] target/arm: handle the WFE trap case Alex Bennée
2026-04-22 12:52 ` [PATCH v3 32/32] target/arm: implement WFET Alex Bennée
2026-04-24 18:20 ` [PATCH v3 00/32] target/arm: fully model WFxT instructions for A-profile Alex Bennée
2026-04-27 10:47 ` 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=20260422125250.1303100-3-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=agraf@csgraf.de \
--cc=kvm@vger.kernel.org \
--cc=mohamed@unpredictable.fr \
--cc=pbarbuda@microsoft.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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