xref: /openbmc/qemu/target/arm/syndrome.h (revision 35a60a20f0008a39af39bf39e12a1b07889b4e56)
11fe27859SRichard Henderson /*
21fe27859SRichard Henderson  * QEMU ARM CPU -- syndrome functions and types
31fe27859SRichard Henderson  *
41fe27859SRichard Henderson  * Copyright (c) 2014 Linaro Ltd
51fe27859SRichard Henderson  *
61fe27859SRichard Henderson  * This program is free software; you can redistribute it and/or
71fe27859SRichard Henderson  * modify it under the terms of the GNU General Public License
81fe27859SRichard Henderson  * as published by the Free Software Foundation; either version 2
91fe27859SRichard Henderson  * of the License, or (at your option) any later version.
101fe27859SRichard Henderson  *
111fe27859SRichard Henderson  * This program is distributed in the hope that it will be useful,
121fe27859SRichard Henderson  * but WITHOUT ANY WARRANTY; without even the implied warranty of
131fe27859SRichard Henderson  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
141fe27859SRichard Henderson  * GNU General Public License for more details.
151fe27859SRichard Henderson  *
161fe27859SRichard Henderson  * You should have received a copy of the GNU General Public License
171fe27859SRichard Henderson  * along with this program; if not, see
181fe27859SRichard Henderson  * <http://www.gnu.org/licenses/gpl-2.0.html>
191fe27859SRichard Henderson  *
201fe27859SRichard Henderson  * This header defines functions, types, etc which need to be shared
211fe27859SRichard Henderson  * between different source files within target/arm/ but which are
221fe27859SRichard Henderson  * private to it and not required by the rest of QEMU.
231fe27859SRichard Henderson  */
241fe27859SRichard Henderson 
251fe27859SRichard Henderson #ifndef TARGET_ARM_SYNDROME_H
261fe27859SRichard Henderson #define TARGET_ARM_SYNDROME_H
271fe27859SRichard Henderson 
28*35a60a20SJan Klötzke #include "qemu/bitops.h"
29*35a60a20SJan Klötzke 
301fe27859SRichard Henderson /* Valid Syndrome Register EC field values */
311fe27859SRichard Henderson enum arm_exception_class {
321fe27859SRichard Henderson     EC_UNCATEGORIZED          = 0x00,
331fe27859SRichard Henderson     EC_WFX_TRAP               = 0x01,
341fe27859SRichard Henderson     EC_CP15RTTRAP             = 0x03,
351fe27859SRichard Henderson     EC_CP15RRTTRAP            = 0x04,
361fe27859SRichard Henderson     EC_CP14RTTRAP             = 0x05,
371fe27859SRichard Henderson     EC_CP14DTTRAP             = 0x06,
381fe27859SRichard Henderson     EC_ADVSIMDFPACCESSTRAP    = 0x07,
391fe27859SRichard Henderson     EC_FPIDTRAP               = 0x08,
401fe27859SRichard Henderson     EC_PACTRAP                = 0x09,
418e228c9eSPeter Maydell     EC_BXJTRAP                = 0x0a,
421fe27859SRichard Henderson     EC_CP14RRTTRAP            = 0x0c,
431fe27859SRichard Henderson     EC_BTITRAP                = 0x0d,
441fe27859SRichard Henderson     EC_ILLEGALSTATE           = 0x0e,
451fe27859SRichard Henderson     EC_AA32_SVC               = 0x11,
461fe27859SRichard Henderson     EC_AA32_HVC               = 0x12,
471fe27859SRichard Henderson     EC_AA32_SMC               = 0x13,
481fe27859SRichard Henderson     EC_AA64_SVC               = 0x15,
491fe27859SRichard Henderson     EC_AA64_HVC               = 0x16,
501fe27859SRichard Henderson     EC_AA64_SMC               = 0x17,
511fe27859SRichard Henderson     EC_SYSTEMREGISTERTRAP     = 0x18,
521fe27859SRichard Henderson     EC_SVEACCESSTRAP          = 0x19,
535572f755SPeter Maydell     EC_ERETTRAP               = 0x1a,
548a69a423SAaron Lindsay     EC_PACFAIL                = 0x1c,
5558b2908eSRichard Henderson     EC_SMETRAP                = 0x1d,
56f65a9bc7SRichard Henderson     EC_GPC                    = 0x1e,
571fe27859SRichard Henderson     EC_INSNABORT              = 0x20,
581fe27859SRichard Henderson     EC_INSNABORT_SAME_EL      = 0x21,
591fe27859SRichard Henderson     EC_PCALIGNMENT            = 0x22,
601fe27859SRichard Henderson     EC_DATAABORT              = 0x24,
611fe27859SRichard Henderson     EC_DATAABORT_SAME_EL      = 0x25,
621fe27859SRichard Henderson     EC_SPALIGNMENT            = 0x26,
6331aaaddeSPeter Maydell     EC_MOP                    = 0x27,
641fe27859SRichard Henderson     EC_AA32_FPTRAP            = 0x28,
651fe27859SRichard Henderson     EC_AA64_FPTRAP            = 0x2c,
661fe27859SRichard Henderson     EC_SERROR                 = 0x2f,
671fe27859SRichard Henderson     EC_BREAKPOINT             = 0x30,
681fe27859SRichard Henderson     EC_BREAKPOINT_SAME_EL     = 0x31,
691fe27859SRichard Henderson     EC_SOFTWARESTEP           = 0x32,
701fe27859SRichard Henderson     EC_SOFTWARESTEP_SAME_EL   = 0x33,
711fe27859SRichard Henderson     EC_WATCHPOINT             = 0x34,
721fe27859SRichard Henderson     EC_WATCHPOINT_SAME_EL     = 0x35,
731fe27859SRichard Henderson     EC_AA32_BKPT              = 0x38,
741fe27859SRichard Henderson     EC_VECTORCATCH            = 0x3a,
751fe27859SRichard Henderson     EC_AA64_BKPT              = 0x3c,
761fe27859SRichard Henderson };
771fe27859SRichard Henderson 
7858b2908eSRichard Henderson typedef enum {
7958b2908eSRichard Henderson     SME_ET_AccessTrap,
8058b2908eSRichard Henderson     SME_ET_Streaming,
8158b2908eSRichard Henderson     SME_ET_NotStreaming,
8258b2908eSRichard Henderson     SME_ET_InactiveZA,
8358b2908eSRichard Henderson } SMEExceptionType;
8458b2908eSRichard Henderson 
85*35a60a20SJan Klötzke #define ARM_EL_EC_LENGTH 6
861fe27859SRichard Henderson #define ARM_EL_EC_SHIFT 26
871fe27859SRichard Henderson #define ARM_EL_IL_SHIFT 25
881fe27859SRichard Henderson #define ARM_EL_ISV_SHIFT 24
891fe27859SRichard Henderson #define ARM_EL_IL (1 << ARM_EL_IL_SHIFT)
901fe27859SRichard Henderson #define ARM_EL_ISV (1 << ARM_EL_ISV_SHIFT)
911fe27859SRichard Henderson 
921fe27859SRichard Henderson /* In the Data Abort syndrome */
931fe27859SRichard Henderson #define ARM_EL_VNCR (1 << 13)
941fe27859SRichard Henderson 
syn_get_ec(uint32_t syn)951fe27859SRichard Henderson static inline uint32_t syn_get_ec(uint32_t syn)
961fe27859SRichard Henderson {
97*35a60a20SJan Klötzke     return syn >> ARM_EL_EC_SHIFT;
98*35a60a20SJan Klötzke }
99*35a60a20SJan Klötzke 
syn_set_ec(uint32_t syn,uint32_t ec)100*35a60a20SJan Klötzke static inline uint32_t syn_set_ec(uint32_t syn, uint32_t ec)
101*35a60a20SJan Klötzke {
1021fe27859SRichard Henderson     return deposit32(syn, ARM_EL_EC_SHIFT, ARM_EL_EC_LENGTH, ec);
1031fe27859SRichard Henderson }
1041fe27859SRichard Henderson 
1051fe27859SRichard Henderson /*
1061fe27859SRichard Henderson  * Utility functions for constructing various kinds of syndrome value.
1071fe27859SRichard Henderson  * Note that in general we follow the AArch64 syndrome values; in a
1081fe27859SRichard Henderson  * few cases the value in HSR for exceptions taken to AArch32 Hyp
1091fe27859SRichard Henderson  * mode differs slightly, and we fix this up when populating HSR in
1101fe27859SRichard Henderson  * arm_cpu_do_interrupt_aarch32_hyp().
1111fe27859SRichard Henderson  * The exception is FP/SIMD access traps -- these report extra information
1121fe27859SRichard Henderson  * when taking an exception to AArch32. For those we include the extra coproc
1131fe27859SRichard Henderson  * and TA fields, and mask them out when taking the exception to AArch64.
1141fe27859SRichard Henderson  */
syn_uncategorized(void)1151fe27859SRichard Henderson static inline uint32_t syn_uncategorized(void)
1161fe27859SRichard Henderson {
1171fe27859SRichard Henderson     return (EC_UNCATEGORIZED << ARM_EL_EC_SHIFT) | ARM_EL_IL;
1181fe27859SRichard Henderson }
1191fe27859SRichard Henderson 
syn_aa64_svc(uint32_t imm16)1201fe27859SRichard Henderson static inline uint32_t syn_aa64_svc(uint32_t imm16)
1211fe27859SRichard Henderson {
1221fe27859SRichard Henderson     return (EC_AA64_SVC << ARM_EL_EC_SHIFT) | ARM_EL_IL | (imm16 & 0xffff);
1231fe27859SRichard Henderson }
1241fe27859SRichard Henderson 
syn_aa64_hvc(uint32_t imm16)1251fe27859SRichard Henderson static inline uint32_t syn_aa64_hvc(uint32_t imm16)
1261fe27859SRichard Henderson {
1271fe27859SRichard Henderson     return (EC_AA64_HVC << ARM_EL_EC_SHIFT) | ARM_EL_IL | (imm16 & 0xffff);
1281fe27859SRichard Henderson }
1291fe27859SRichard Henderson 
syn_aa64_smc(uint32_t imm16)1301fe27859SRichard Henderson static inline uint32_t syn_aa64_smc(uint32_t imm16)
1311fe27859SRichard Henderson {
1321fe27859SRichard Henderson     return (EC_AA64_SMC << ARM_EL_EC_SHIFT) | ARM_EL_IL | (imm16 & 0xffff);
1331fe27859SRichard Henderson }
1341fe27859SRichard Henderson 
syn_aa32_svc(uint32_t imm16,bool is_16bit)1351fe27859SRichard Henderson static inline uint32_t syn_aa32_svc(uint32_t imm16, bool is_16bit)
1361fe27859SRichard Henderson {
1371fe27859SRichard Henderson     return (EC_AA32_SVC << ARM_EL_EC_SHIFT) | (imm16 & 0xffff)
1381fe27859SRichard Henderson         | (is_16bit ? 0 : ARM_EL_IL);
1391fe27859SRichard Henderson }
1401fe27859SRichard Henderson 
syn_aa32_hvc(uint32_t imm16)1411fe27859SRichard Henderson static inline uint32_t syn_aa32_hvc(uint32_t imm16)
1421fe27859SRichard Henderson {
1431fe27859SRichard Henderson     return (EC_AA32_HVC << ARM_EL_EC_SHIFT) | ARM_EL_IL | (imm16 & 0xffff);
1441fe27859SRichard Henderson }
1451fe27859SRichard Henderson 
syn_aa32_smc(void)1461fe27859SRichard Henderson static inline uint32_t syn_aa32_smc(void)
1471fe27859SRichard Henderson {
1481fe27859SRichard Henderson     return (EC_AA32_SMC << ARM_EL_EC_SHIFT) | ARM_EL_IL;
1491fe27859SRichard Henderson }
1501fe27859SRichard Henderson 
syn_aa64_bkpt(uint32_t imm16)1511fe27859SRichard Henderson static inline uint32_t syn_aa64_bkpt(uint32_t imm16)
1521fe27859SRichard Henderson {
1531fe27859SRichard Henderson     return (EC_AA64_BKPT << ARM_EL_EC_SHIFT) | ARM_EL_IL | (imm16 & 0xffff);
1541fe27859SRichard Henderson }
1551fe27859SRichard Henderson 
syn_aa32_bkpt(uint32_t imm16,bool is_16bit)1561fe27859SRichard Henderson static inline uint32_t syn_aa32_bkpt(uint32_t imm16, bool is_16bit)
1571fe27859SRichard Henderson {
1581fe27859SRichard Henderson     return (EC_AA32_BKPT << ARM_EL_EC_SHIFT) | (imm16 & 0xffff)
1591fe27859SRichard Henderson         | (is_16bit ? 0 : ARM_EL_IL);
1601fe27859SRichard Henderson }
1611fe27859SRichard Henderson 
syn_aa64_sysregtrap(int op0,int op1,int op2,int crn,int crm,int rt,int isread)1621fe27859SRichard Henderson static inline uint32_t syn_aa64_sysregtrap(int op0, int op1, int op2,
1631fe27859SRichard Henderson                                            int crn, int crm, int rt,
1641fe27859SRichard Henderson                                            int isread)
1651fe27859SRichard Henderson {
1661fe27859SRichard Henderson     return (EC_SYSTEMREGISTERTRAP << ARM_EL_EC_SHIFT) | ARM_EL_IL
1671fe27859SRichard Henderson         | (op0 << 20) | (op2 << 17) | (op1 << 14) | (crn << 10) | (rt << 5)
1681fe27859SRichard Henderson         | (crm << 1) | isread;
1691fe27859SRichard Henderson }
1701fe27859SRichard Henderson 
syn_cp14_rt_trap(int cv,int cond,int opc1,int opc2,int crn,int crm,int rt,int isread,bool is_16bit)1711fe27859SRichard Henderson static inline uint32_t syn_cp14_rt_trap(int cv, int cond, int opc1, int opc2,
1721fe27859SRichard Henderson                                         int crn, int crm, int rt, int isread,
1731fe27859SRichard Henderson                                         bool is_16bit)
1741fe27859SRichard Henderson {
1751fe27859SRichard Henderson     return (EC_CP14RTTRAP << ARM_EL_EC_SHIFT)
1761fe27859SRichard Henderson         | (is_16bit ? 0 : ARM_EL_IL)
1771fe27859SRichard Henderson         | (cv << 24) | (cond << 20) | (opc2 << 17) | (opc1 << 14)
1781fe27859SRichard Henderson         | (crn << 10) | (rt << 5) | (crm << 1) | isread;
1791fe27859SRichard Henderson }
1801fe27859SRichard Henderson 
syn_cp15_rt_trap(int cv,int cond,int opc1,int opc2,int crn,int crm,int rt,int isread,bool is_16bit)1811fe27859SRichard Henderson static inline uint32_t syn_cp15_rt_trap(int cv, int cond, int opc1, int opc2,
1821fe27859SRichard Henderson                                         int crn, int crm, int rt, int isread,
1831fe27859SRichard Henderson                                         bool is_16bit)
1841fe27859SRichard Henderson {
1851fe27859SRichard Henderson     return (EC_CP15RTTRAP << ARM_EL_EC_SHIFT)
1861fe27859SRichard Henderson         | (is_16bit ? 0 : ARM_EL_IL)
1871fe27859SRichard Henderson         | (cv << 24) | (cond << 20) | (opc2 << 17) | (opc1 << 14)
1881fe27859SRichard Henderson         | (crn << 10) | (rt << 5) | (crm << 1) | isread;
1891fe27859SRichard Henderson }
1901fe27859SRichard Henderson 
syn_cp14_rrt_trap(int cv,int cond,int opc1,int crm,int rt,int rt2,int isread,bool is_16bit)1911fe27859SRichard Henderson static inline uint32_t syn_cp14_rrt_trap(int cv, int cond, int opc1, int crm,
1921fe27859SRichard Henderson                                          int rt, int rt2, int isread,
1931fe27859SRichard Henderson                                          bool is_16bit)
1941fe27859SRichard Henderson {
1951fe27859SRichard Henderson     return (EC_CP14RRTTRAP << ARM_EL_EC_SHIFT)
1961fe27859SRichard Henderson         | (is_16bit ? 0 : ARM_EL_IL)
1971fe27859SRichard Henderson         | (cv << 24) | (cond << 20) | (opc1 << 16)
1981fe27859SRichard Henderson         | (rt2 << 10) | (rt << 5) | (crm << 1) | isread;
1991fe27859SRichard Henderson }
2001fe27859SRichard Henderson 
syn_cp15_rrt_trap(int cv,int cond,int opc1,int crm,int rt,int rt2,int isread,bool is_16bit)2011fe27859SRichard Henderson static inline uint32_t syn_cp15_rrt_trap(int cv, int cond, int opc1, int crm,
2021fe27859SRichard Henderson                                          int rt, int rt2, int isread,
2031fe27859SRichard Henderson                                          bool is_16bit)
2041fe27859SRichard Henderson {
2051fe27859SRichard Henderson     return (EC_CP15RRTTRAP << ARM_EL_EC_SHIFT)
2061fe27859SRichard Henderson         | (is_16bit ? 0 : ARM_EL_IL)
2071fe27859SRichard Henderson         | (cv << 24) | (cond << 20) | (opc1 << 16)
208fa33eeadSRichard Henderson         | (rt2 << 10) | (rt << 5) | (crm << 1) | isread;
209fa33eeadSRichard Henderson }
2101fe27859SRichard Henderson 
syn_fp_access_trap(int cv,int cond,bool is_16bit,int coproc)211fa33eeadSRichard Henderson static inline uint32_t syn_fp_access_trap(int cv, int cond, bool is_16bit,
2121fe27859SRichard Henderson                                           int coproc)
2131fe27859SRichard Henderson {
214fa33eeadSRichard Henderson     /* AArch32 FP trap or any AArch64 FP/SIMD trap: TA == 0 */
2151fe27859SRichard Henderson     return (EC_ADVSIMDFPACCESSTRAP << ARM_EL_EC_SHIFT)
2161fe27859SRichard Henderson         | (is_16bit ? 0 : ARM_EL_IL)
2171fe27859SRichard Henderson         | (cv << 24) | (cond << 20) | coproc;
2181fe27859SRichard Henderson }
2191fe27859SRichard Henderson 
syn_simd_access_trap(int cv,int cond,bool is_16bit)2201fe27859SRichard Henderson static inline uint32_t syn_simd_access_trap(int cv, int cond, bool is_16bit)
2211fe27859SRichard Henderson {
2221fe27859SRichard Henderson     /* AArch32 SIMD trap: TA == 1 coproc == 0 */
2231fe27859SRichard Henderson     return (EC_ADVSIMDFPACCESSTRAP << ARM_EL_EC_SHIFT)
2241fe27859SRichard Henderson         | (is_16bit ? 0 : ARM_EL_IL)
2251fe27859SRichard Henderson         | (cv << 24) | (cond << 20) | (1 << 5);
2261fe27859SRichard Henderson }
22711a3c4a2SPeter Maydell 
syn_sve_access_trap(void)2281fe27859SRichard Henderson static inline uint32_t syn_sve_access_trap(void)
2291fe27859SRichard Henderson {
2305572f755SPeter Maydell     return (EC_SVEACCESSTRAP << ARM_EL_EC_SHIFT) | ARM_EL_IL;
2315572f755SPeter Maydell }
2325572f755SPeter Maydell 
2335572f755SPeter Maydell /*
2345572f755SPeter Maydell  * eret_op is bits [1:0] of the ERET instruction, so:
2355572f755SPeter Maydell  * 0 for ERET, 2 for ERETAA, 3 for ERETAB.
2365572f755SPeter Maydell  */
syn_erettrap(int eret_op)2375572f755SPeter Maydell static inline uint32_t syn_erettrap(int eret_op)
2385572f755SPeter Maydell {
23958b2908eSRichard Henderson     return (EC_ERETTRAP << ARM_EL_EC_SHIFT) | ARM_EL_IL | eret_op;
24058b2908eSRichard Henderson }
24158b2908eSRichard Henderson 
syn_smetrap(SMEExceptionType etype,bool is_16bit)24258b2908eSRichard Henderson static inline uint32_t syn_smetrap(SMEExceptionType etype, bool is_16bit)
24358b2908eSRichard Henderson {
24458b2908eSRichard Henderson     return (EC_SMETRAP << ARM_EL_EC_SHIFT)
2458a69a423SAaron Lindsay         | (is_16bit ? 0 : ARM_EL_IL) | etype;
2468a69a423SAaron Lindsay }
2478a69a423SAaron Lindsay 
syn_pacfail(bool data,int keynumber)2488a69a423SAaron Lindsay static inline uint32_t syn_pacfail(bool data, int keynumber)
2498a69a423SAaron Lindsay {
2508a69a423SAaron Lindsay     int error_code = (data << 1) | keynumber;
2511fe27859SRichard Henderson     return (EC_PACFAIL << ARM_EL_EC_SHIFT) | ARM_EL_IL | error_code;
2521fe27859SRichard Henderson }
25311a3c4a2SPeter Maydell 
syn_pactrap(void)2541fe27859SRichard Henderson static inline uint32_t syn_pactrap(void)
2551fe27859SRichard Henderson {
2561fe27859SRichard Henderson     return (EC_PACTRAP << ARM_EL_EC_SHIFT) | ARM_EL_IL;
2571fe27859SRichard Henderson }
25811a3c4a2SPeter Maydell 
syn_btitrap(int btype)2591fe27859SRichard Henderson static inline uint32_t syn_btitrap(int btype)
2601fe27859SRichard Henderson {
2618e228c9eSPeter Maydell     return (EC_BTITRAP << ARM_EL_EC_SHIFT) | ARM_EL_IL | btype;
2628e228c9eSPeter Maydell }
2638e228c9eSPeter Maydell 
syn_bxjtrap(int cv,int cond,int rm)2648e228c9eSPeter Maydell static inline uint32_t syn_bxjtrap(int cv, int cond, int rm)
2658e228c9eSPeter Maydell {
2668e228c9eSPeter Maydell     return (EC_BXJTRAP << ARM_EL_EC_SHIFT) | ARM_EL_IL |
267f65a9bc7SRichard Henderson         (cv << 24) | (cond << 20) | rm;
268f65a9bc7SRichard Henderson }
269f65a9bc7SRichard Henderson 
syn_gpc(int s2ptw,int ind,int gpcsc,int vncr,int cm,int s1ptw,int wnr,int fsc)270f65a9bc7SRichard Henderson static inline uint32_t syn_gpc(int s2ptw, int ind, int gpcsc, int vncr,
271f65a9bc7SRichard Henderson                                int cm, int s1ptw, int wnr, int fsc)
272f65a9bc7SRichard Henderson {
273f65a9bc7SRichard Henderson     return (EC_GPC << ARM_EL_EC_SHIFT) | ARM_EL_IL | (s2ptw << 21)
274f65a9bc7SRichard Henderson         | (ind << 20) | (gpcsc << 14) | (vncr << 13) | (cm << 8)
275f65a9bc7SRichard Henderson         | (s1ptw << 7) | (wnr << 6) | fsc;
2761fe27859SRichard Henderson }
2771fe27859SRichard Henderson 
syn_insn_abort(int same_el,int ea,int s1ptw,int fsc)2781fe27859SRichard Henderson static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc)
2791fe27859SRichard Henderson {
2801fe27859SRichard Henderson     return (EC_INSNABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
2811fe27859SRichard Henderson         | ARM_EL_IL | (ea << 9) | (s1ptw << 7) | fsc;
2821fe27859SRichard Henderson }
2831fe27859SRichard Henderson 
syn_data_abort_no_iss(int same_el,int fnv,int ea,int cm,int s1ptw,int wnr,int fsc)2841fe27859SRichard Henderson static inline uint32_t syn_data_abort_no_iss(int same_el, int fnv,
2851fe27859SRichard Henderson                                              int ea, int cm, int s1ptw,
2861fe27859SRichard Henderson                                              int wnr, int fsc)
2871fe27859SRichard Henderson {
2881fe27859SRichard Henderson     return (EC_DATAABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
2891fe27859SRichard Henderson            | ARM_EL_IL
2901fe27859SRichard Henderson            | (fnv << 10) | (ea << 9) | (cm << 8) | (s1ptw << 7)
2911fe27859SRichard Henderson            | (wnr << 6) | fsc;
2921fe27859SRichard Henderson }
2931fe27859SRichard Henderson 
syn_data_abort_with_iss(int same_el,int sas,int sse,int srt,int sf,int ar,int ea,int cm,int s1ptw,int wnr,int fsc,bool is_16bit)2941fe27859SRichard Henderson static inline uint32_t syn_data_abort_with_iss(int same_el,
2951fe27859SRichard Henderson                                                int sas, int sse, int srt,
2961fe27859SRichard Henderson                                                int sf, int ar,
2971fe27859SRichard Henderson                                                int ea, int cm, int s1ptw,
2981fe27859SRichard Henderson                                                int wnr, int fsc,
2991fe27859SRichard Henderson                                                bool is_16bit)
3001fe27859SRichard Henderson {
3011fe27859SRichard Henderson     return (EC_DATAABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
3021fe27859SRichard Henderson            | (is_16bit ? 0 : ARM_EL_IL)
3031fe27859SRichard Henderson            | ARM_EL_ISV | (sas << 22) | (sse << 21) | (srt << 16)
3041fe27859SRichard Henderson            | (sf << 15) | (ar << 14)
3051fe27859SRichard Henderson            | (ea << 9) | (cm << 8) | (s1ptw << 7) | (wnr << 6) | fsc;
3061fe27859SRichard Henderson }
3071fe27859SRichard Henderson 
3081fe27859SRichard Henderson /*
3091fe27859SRichard Henderson  * Faults due to FEAT_NV2 VNCR_EL2-based accesses report as same-EL
3101fe27859SRichard Henderson  * Data Aborts with the VNCR bit set.
3111fe27859SRichard Henderson  */
syn_data_abort_vncr(int ea,int wnr,int fsc)3121fe27859SRichard Henderson static inline uint32_t syn_data_abort_vncr(int ea, int wnr, int fsc)
3131fe27859SRichard Henderson {
3141fe27859SRichard Henderson     return (EC_DATAABORT << ARM_EL_EC_SHIFT) | (1 << ARM_EL_EC_SHIFT)
3151fe27859SRichard Henderson         | ARM_EL_IL | ARM_EL_VNCR | (wnr << 6) | fsc;
3161fe27859SRichard Henderson }
3171fe27859SRichard Henderson 
syn_swstep(int same_el,int isv,int ex)3181fe27859SRichard Henderson static inline uint32_t syn_swstep(int same_el, int isv, int ex)
3191fe27859SRichard Henderson {
3201fe27859SRichard Henderson     return (EC_SOFTWARESTEP << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
3211fe27859SRichard Henderson         | ARM_EL_IL | (isv << 24) | (ex << 6) | 0x22;
3221fe27859SRichard Henderson }
3231fe27859SRichard Henderson 
syn_watchpoint(int same_el,int cm,int wnr)3241fe27859SRichard Henderson static inline uint32_t syn_watchpoint(int same_el, int cm, int wnr)
3251fe27859SRichard Henderson {
3261fe27859SRichard Henderson     return (EC_WATCHPOINT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
3271fe27859SRichard Henderson         | ARM_EL_IL | (cm << 8) | (wnr << 6) | 0x22;
3281fe27859SRichard Henderson }
3291fe27859SRichard Henderson 
syn_breakpoint(int same_el)3301fe27859SRichard Henderson static inline uint32_t syn_breakpoint(int same_el)
331520d1621SPeter Maydell {
332520d1621SPeter Maydell     return (EC_BREAKPOINT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
333520d1621SPeter Maydell         | ARM_EL_IL | 0x22;
334520d1621SPeter Maydell }
335520d1621SPeter Maydell 
syn_wfx(int cv,int cond,int ti,bool is_16bit)336ee03027aSRichard Henderson static inline uint32_t syn_wfx(int cv, int cond, int ti, bool is_16bit)
337ee03027aSRichard Henderson {
338ee03027aSRichard Henderson     return (EC_WFX_TRAP << ARM_EL_EC_SHIFT) |
339ee03027aSRichard Henderson            (is_16bit ? 0 : (1 << ARM_EL_IL_SHIFT)) |
340ee03027aSRichard Henderson            (cv << 24) | (cond << 20) | ti;
3413c29632fSRichard Henderson }
3423c29632fSRichard Henderson 
syn_illegalstate(void)3433c29632fSRichard Henderson static inline uint32_t syn_illegalstate(void)
3443c29632fSRichard Henderson {
3453c29632fSRichard Henderson     return (EC_ILLEGALSTATE << ARM_EL_EC_SHIFT) | ARM_EL_IL;
34631aaaddeSPeter Maydell }
34731aaaddeSPeter Maydell 
syn_pcalignment(void)34831aaaddeSPeter Maydell static inline uint32_t syn_pcalignment(void)
34931aaaddeSPeter Maydell {
35031aaaddeSPeter Maydell     return (EC_PCALIGNMENT << ARM_EL_EC_SHIFT) | ARM_EL_IL;
35131aaaddeSPeter Maydell }
35231aaaddeSPeter Maydell 
syn_serror(uint32_t extra)35331aaaddeSPeter Maydell static inline uint32_t syn_serror(uint32_t extra)
35431aaaddeSPeter Maydell {
35531aaaddeSPeter Maydell     return (EC_SERROR << ARM_EL_EC_SHIFT) | ARM_EL_IL | extra;
35631aaaddeSPeter Maydell }
3571fe27859SRichard Henderson 
syn_mop(bool is_set,bool is_setg,int options,bool epilogue,bool wrong_option,bool option_a,int destreg,int srcreg,int sizereg)358 static inline uint32_t syn_mop(bool is_set, bool is_setg, int options,
359                                bool epilogue, bool wrong_option, bool option_a,
360                                int destreg, int srcreg, int sizereg)
361 {
362     return (EC_MOP << ARM_EL_EC_SHIFT) | ARM_EL_IL |
363         (is_set << 24) | (is_setg << 23) | (options << 19) |
364         (epilogue << 18) | (wrong_option << 17) | (option_a << 16) |
365         (destreg << 10) | (srcreg << 5) | sizereg;
366 }
367 
368 
369 #endif /* TARGET_ARM_SYNDROME_H */
370