162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2013 - ARM Ltd 462306a36Sopenharmony_ci * Author: Marc Zyngier <marc.zyngier@arm.com> 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#ifndef __ASM_ESR_H 862306a36Sopenharmony_ci#define __ASM_ESR_H 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include <asm/memory.h> 1162306a36Sopenharmony_ci#include <asm/sysreg.h> 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#define ESR_ELx_EC_UNKNOWN (0x00) 1462306a36Sopenharmony_ci#define ESR_ELx_EC_WFx (0x01) 1562306a36Sopenharmony_ci/* Unallocated EC: 0x02 */ 1662306a36Sopenharmony_ci#define ESR_ELx_EC_CP15_32 (0x03) 1762306a36Sopenharmony_ci#define ESR_ELx_EC_CP15_64 (0x04) 1862306a36Sopenharmony_ci#define ESR_ELx_EC_CP14_MR (0x05) 1962306a36Sopenharmony_ci#define ESR_ELx_EC_CP14_LS (0x06) 2062306a36Sopenharmony_ci#define ESR_ELx_EC_FP_ASIMD (0x07) 2162306a36Sopenharmony_ci#define ESR_ELx_EC_CP10_ID (0x08) /* EL2 only */ 2262306a36Sopenharmony_ci#define ESR_ELx_EC_PAC (0x09) /* EL2 and above */ 2362306a36Sopenharmony_ci/* Unallocated EC: 0x0A - 0x0B */ 2462306a36Sopenharmony_ci#define ESR_ELx_EC_CP14_64 (0x0C) 2562306a36Sopenharmony_ci#define ESR_ELx_EC_BTI (0x0D) 2662306a36Sopenharmony_ci#define ESR_ELx_EC_ILL (0x0E) 2762306a36Sopenharmony_ci/* Unallocated EC: 0x0F - 0x10 */ 2862306a36Sopenharmony_ci#define ESR_ELx_EC_SVC32 (0x11) 2962306a36Sopenharmony_ci#define ESR_ELx_EC_HVC32 (0x12) /* EL2 only */ 3062306a36Sopenharmony_ci#define ESR_ELx_EC_SMC32 (0x13) /* EL2 and above */ 3162306a36Sopenharmony_ci/* Unallocated EC: 0x14 */ 3262306a36Sopenharmony_ci#define ESR_ELx_EC_SVC64 (0x15) 3362306a36Sopenharmony_ci#define ESR_ELx_EC_HVC64 (0x16) /* EL2 and above */ 3462306a36Sopenharmony_ci#define ESR_ELx_EC_SMC64 (0x17) /* EL2 and above */ 3562306a36Sopenharmony_ci#define ESR_ELx_EC_SYS64 (0x18) 3662306a36Sopenharmony_ci#define ESR_ELx_EC_SVE (0x19) 3762306a36Sopenharmony_ci#define ESR_ELx_EC_ERET (0x1a) /* EL2 only */ 3862306a36Sopenharmony_ci/* Unallocated EC: 0x1B */ 3962306a36Sopenharmony_ci#define ESR_ELx_EC_FPAC (0x1C) /* EL1 and above */ 4062306a36Sopenharmony_ci#define ESR_ELx_EC_SME (0x1D) 4162306a36Sopenharmony_ci/* Unallocated EC: 0x1E */ 4262306a36Sopenharmony_ci#define ESR_ELx_EC_IMP_DEF (0x1f) /* EL3 only */ 4362306a36Sopenharmony_ci#define ESR_ELx_EC_IABT_LOW (0x20) 4462306a36Sopenharmony_ci#define ESR_ELx_EC_IABT_CUR (0x21) 4562306a36Sopenharmony_ci#define ESR_ELx_EC_PC_ALIGN (0x22) 4662306a36Sopenharmony_ci/* Unallocated EC: 0x23 */ 4762306a36Sopenharmony_ci#define ESR_ELx_EC_DABT_LOW (0x24) 4862306a36Sopenharmony_ci#define ESR_ELx_EC_DABT_CUR (0x25) 4962306a36Sopenharmony_ci#define ESR_ELx_EC_SP_ALIGN (0x26) 5062306a36Sopenharmony_ci#define ESR_ELx_EC_MOPS (0x27) 5162306a36Sopenharmony_ci#define ESR_ELx_EC_FP_EXC32 (0x28) 5262306a36Sopenharmony_ci/* Unallocated EC: 0x29 - 0x2B */ 5362306a36Sopenharmony_ci#define ESR_ELx_EC_FP_EXC64 (0x2C) 5462306a36Sopenharmony_ci/* Unallocated EC: 0x2D - 0x2E */ 5562306a36Sopenharmony_ci#define ESR_ELx_EC_SERROR (0x2F) 5662306a36Sopenharmony_ci#define ESR_ELx_EC_BREAKPT_LOW (0x30) 5762306a36Sopenharmony_ci#define ESR_ELx_EC_BREAKPT_CUR (0x31) 5862306a36Sopenharmony_ci#define ESR_ELx_EC_SOFTSTP_LOW (0x32) 5962306a36Sopenharmony_ci#define ESR_ELx_EC_SOFTSTP_CUR (0x33) 6062306a36Sopenharmony_ci#define ESR_ELx_EC_WATCHPT_LOW (0x34) 6162306a36Sopenharmony_ci#define ESR_ELx_EC_WATCHPT_CUR (0x35) 6262306a36Sopenharmony_ci/* Unallocated EC: 0x36 - 0x37 */ 6362306a36Sopenharmony_ci#define ESR_ELx_EC_BKPT32 (0x38) 6462306a36Sopenharmony_ci/* Unallocated EC: 0x39 */ 6562306a36Sopenharmony_ci#define ESR_ELx_EC_VECTOR32 (0x3A) /* EL2 only */ 6662306a36Sopenharmony_ci/* Unallocated EC: 0x3B */ 6762306a36Sopenharmony_ci#define ESR_ELx_EC_BRK64 (0x3C) 6862306a36Sopenharmony_ci/* Unallocated EC: 0x3D - 0x3F */ 6962306a36Sopenharmony_ci#define ESR_ELx_EC_MAX (0x3F) 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci#define ESR_ELx_EC_SHIFT (26) 7262306a36Sopenharmony_ci#define ESR_ELx_EC_WIDTH (6) 7362306a36Sopenharmony_ci#define ESR_ELx_EC_MASK (UL(0x3F) << ESR_ELx_EC_SHIFT) 7462306a36Sopenharmony_ci#define ESR_ELx_EC(esr) (((esr) & ESR_ELx_EC_MASK) >> ESR_ELx_EC_SHIFT) 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci#define ESR_ELx_IL_SHIFT (25) 7762306a36Sopenharmony_ci#define ESR_ELx_IL (UL(1) << ESR_ELx_IL_SHIFT) 7862306a36Sopenharmony_ci#define ESR_ELx_ISS_MASK (GENMASK(24, 0)) 7962306a36Sopenharmony_ci#define ESR_ELx_ISS(esr) ((esr) & ESR_ELx_ISS_MASK) 8062306a36Sopenharmony_ci#define ESR_ELx_ISS2_SHIFT (32) 8162306a36Sopenharmony_ci#define ESR_ELx_ISS2_MASK (GENMASK_ULL(55, 32)) 8262306a36Sopenharmony_ci#define ESR_ELx_ISS2(esr) (((esr) & ESR_ELx_ISS2_MASK) >> ESR_ELx_ISS2_SHIFT) 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci/* ISS field definitions shared by different classes */ 8562306a36Sopenharmony_ci#define ESR_ELx_WNR_SHIFT (6) 8662306a36Sopenharmony_ci#define ESR_ELx_WNR (UL(1) << ESR_ELx_WNR_SHIFT) 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci/* Asynchronous Error Type */ 8962306a36Sopenharmony_ci#define ESR_ELx_IDS_SHIFT (24) 9062306a36Sopenharmony_ci#define ESR_ELx_IDS (UL(1) << ESR_ELx_IDS_SHIFT) 9162306a36Sopenharmony_ci#define ESR_ELx_AET_SHIFT (10) 9262306a36Sopenharmony_ci#define ESR_ELx_AET (UL(0x7) << ESR_ELx_AET_SHIFT) 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci#define ESR_ELx_AET_UC (UL(0) << ESR_ELx_AET_SHIFT) 9562306a36Sopenharmony_ci#define ESR_ELx_AET_UEU (UL(1) << ESR_ELx_AET_SHIFT) 9662306a36Sopenharmony_ci#define ESR_ELx_AET_UEO (UL(2) << ESR_ELx_AET_SHIFT) 9762306a36Sopenharmony_ci#define ESR_ELx_AET_UER (UL(3) << ESR_ELx_AET_SHIFT) 9862306a36Sopenharmony_ci#define ESR_ELx_AET_CE (UL(6) << ESR_ELx_AET_SHIFT) 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci/* Shared ISS field definitions for Data/Instruction aborts */ 10162306a36Sopenharmony_ci#define ESR_ELx_SET_SHIFT (11) 10262306a36Sopenharmony_ci#define ESR_ELx_SET_MASK (UL(3) << ESR_ELx_SET_SHIFT) 10362306a36Sopenharmony_ci#define ESR_ELx_FnV_SHIFT (10) 10462306a36Sopenharmony_ci#define ESR_ELx_FnV (UL(1) << ESR_ELx_FnV_SHIFT) 10562306a36Sopenharmony_ci#define ESR_ELx_EA_SHIFT (9) 10662306a36Sopenharmony_ci#define ESR_ELx_EA (UL(1) << ESR_ELx_EA_SHIFT) 10762306a36Sopenharmony_ci#define ESR_ELx_S1PTW_SHIFT (7) 10862306a36Sopenharmony_ci#define ESR_ELx_S1PTW (UL(1) << ESR_ELx_S1PTW_SHIFT) 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci/* Shared ISS fault status code(IFSC/DFSC) for Data/Instruction aborts */ 11162306a36Sopenharmony_ci#define ESR_ELx_FSC (0x3F) 11262306a36Sopenharmony_ci#define ESR_ELx_FSC_TYPE (0x3C) 11362306a36Sopenharmony_ci#define ESR_ELx_FSC_LEVEL (0x03) 11462306a36Sopenharmony_ci#define ESR_ELx_FSC_EXTABT (0x10) 11562306a36Sopenharmony_ci#define ESR_ELx_FSC_MTE (0x11) 11662306a36Sopenharmony_ci#define ESR_ELx_FSC_SERROR (0x11) 11762306a36Sopenharmony_ci#define ESR_ELx_FSC_ACCESS (0x08) 11862306a36Sopenharmony_ci#define ESR_ELx_FSC_FAULT (0x04) 11962306a36Sopenharmony_ci#define ESR_ELx_FSC_PERM (0x0C) 12062306a36Sopenharmony_ci#define ESR_ELx_FSC_SEA_TTW0 (0x14) 12162306a36Sopenharmony_ci#define ESR_ELx_FSC_SEA_TTW1 (0x15) 12262306a36Sopenharmony_ci#define ESR_ELx_FSC_SEA_TTW2 (0x16) 12362306a36Sopenharmony_ci#define ESR_ELx_FSC_SEA_TTW3 (0x17) 12462306a36Sopenharmony_ci#define ESR_ELx_FSC_SECC (0x18) 12562306a36Sopenharmony_ci#define ESR_ELx_FSC_SECC_TTW0 (0x1c) 12662306a36Sopenharmony_ci#define ESR_ELx_FSC_SECC_TTW1 (0x1d) 12762306a36Sopenharmony_ci#define ESR_ELx_FSC_SECC_TTW2 (0x1e) 12862306a36Sopenharmony_ci#define ESR_ELx_FSC_SECC_TTW3 (0x1f) 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ci/* ISS field definitions for Data Aborts */ 13162306a36Sopenharmony_ci#define ESR_ELx_ISV_SHIFT (24) 13262306a36Sopenharmony_ci#define ESR_ELx_ISV (UL(1) << ESR_ELx_ISV_SHIFT) 13362306a36Sopenharmony_ci#define ESR_ELx_SAS_SHIFT (22) 13462306a36Sopenharmony_ci#define ESR_ELx_SAS (UL(3) << ESR_ELx_SAS_SHIFT) 13562306a36Sopenharmony_ci#define ESR_ELx_SSE_SHIFT (21) 13662306a36Sopenharmony_ci#define ESR_ELx_SSE (UL(1) << ESR_ELx_SSE_SHIFT) 13762306a36Sopenharmony_ci#define ESR_ELx_SRT_SHIFT (16) 13862306a36Sopenharmony_ci#define ESR_ELx_SRT_MASK (UL(0x1F) << ESR_ELx_SRT_SHIFT) 13962306a36Sopenharmony_ci#define ESR_ELx_SF_SHIFT (15) 14062306a36Sopenharmony_ci#define ESR_ELx_SF (UL(1) << ESR_ELx_SF_SHIFT) 14162306a36Sopenharmony_ci#define ESR_ELx_AR_SHIFT (14) 14262306a36Sopenharmony_ci#define ESR_ELx_AR (UL(1) << ESR_ELx_AR_SHIFT) 14362306a36Sopenharmony_ci#define ESR_ELx_CM_SHIFT (8) 14462306a36Sopenharmony_ci#define ESR_ELx_CM (UL(1) << ESR_ELx_CM_SHIFT) 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ci/* ISS2 field definitions for Data Aborts */ 14762306a36Sopenharmony_ci#define ESR_ELx_TnD_SHIFT (10) 14862306a36Sopenharmony_ci#define ESR_ELx_TnD (UL(1) << ESR_ELx_TnD_SHIFT) 14962306a36Sopenharmony_ci#define ESR_ELx_TagAccess_SHIFT (9) 15062306a36Sopenharmony_ci#define ESR_ELx_TagAccess (UL(1) << ESR_ELx_TagAccess_SHIFT) 15162306a36Sopenharmony_ci#define ESR_ELx_GCS_SHIFT (8) 15262306a36Sopenharmony_ci#define ESR_ELx_GCS (UL(1) << ESR_ELx_GCS_SHIFT) 15362306a36Sopenharmony_ci#define ESR_ELx_Overlay_SHIFT (6) 15462306a36Sopenharmony_ci#define ESR_ELx_Overlay (UL(1) << ESR_ELx_Overlay_SHIFT) 15562306a36Sopenharmony_ci#define ESR_ELx_DirtyBit_SHIFT (5) 15662306a36Sopenharmony_ci#define ESR_ELx_DirtyBit (UL(1) << ESR_ELx_DirtyBit_SHIFT) 15762306a36Sopenharmony_ci#define ESR_ELx_Xs_SHIFT (0) 15862306a36Sopenharmony_ci#define ESR_ELx_Xs_MASK (GENMASK_ULL(4, 0)) 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_ci/* ISS field definitions for exceptions taken in to Hyp */ 16162306a36Sopenharmony_ci#define ESR_ELx_CV (UL(1) << 24) 16262306a36Sopenharmony_ci#define ESR_ELx_COND_SHIFT (20) 16362306a36Sopenharmony_ci#define ESR_ELx_COND_MASK (UL(0xF) << ESR_ELx_COND_SHIFT) 16462306a36Sopenharmony_ci#define ESR_ELx_WFx_ISS_RN (UL(0x1F) << 5) 16562306a36Sopenharmony_ci#define ESR_ELx_WFx_ISS_RV (UL(1) << 2) 16662306a36Sopenharmony_ci#define ESR_ELx_WFx_ISS_TI (UL(3) << 0) 16762306a36Sopenharmony_ci#define ESR_ELx_WFx_ISS_WFxT (UL(2) << 0) 16862306a36Sopenharmony_ci#define ESR_ELx_WFx_ISS_WFI (UL(0) << 0) 16962306a36Sopenharmony_ci#define ESR_ELx_WFx_ISS_WFE (UL(1) << 0) 17062306a36Sopenharmony_ci#define ESR_ELx_xVC_IMM_MASK ((UL(1) << 16) - 1) 17162306a36Sopenharmony_ci 17262306a36Sopenharmony_ci#define DISR_EL1_IDS (UL(1) << 24) 17362306a36Sopenharmony_ci/* 17462306a36Sopenharmony_ci * DISR_EL1 and ESR_ELx share the bottom 13 bits, but the RES0 bits may mean 17562306a36Sopenharmony_ci * different things in the future... 17662306a36Sopenharmony_ci */ 17762306a36Sopenharmony_ci#define DISR_EL1_ESR_MASK (ESR_ELx_AET | ESR_ELx_EA | ESR_ELx_FSC) 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci/* ESR value templates for specific events */ 18062306a36Sopenharmony_ci#define ESR_ELx_WFx_MASK (ESR_ELx_EC_MASK | \ 18162306a36Sopenharmony_ci (ESR_ELx_WFx_ISS_TI & ~ESR_ELx_WFx_ISS_WFxT)) 18262306a36Sopenharmony_ci#define ESR_ELx_WFx_WFI_VAL ((ESR_ELx_EC_WFx << ESR_ELx_EC_SHIFT) | \ 18362306a36Sopenharmony_ci ESR_ELx_WFx_ISS_WFI) 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci/* BRK instruction trap from AArch64 state */ 18662306a36Sopenharmony_ci#define ESR_ELx_BRK64_ISS_COMMENT_MASK 0xffff 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci/* ISS field definitions for System instruction traps */ 18962306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_RES0_SHIFT 22 19062306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_RES0_MASK (UL(0x7) << ESR_ELx_SYS64_ISS_RES0_SHIFT) 19162306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_DIR_MASK 0x1 19262306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_DIR_READ 0x1 19362306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_DIR_WRITE 0x0 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_RT_SHIFT 5 19662306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_RT_MASK (UL(0x1f) << ESR_ELx_SYS64_ISS_RT_SHIFT) 19762306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRM_SHIFT 1 19862306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRM_MASK (UL(0xf) << ESR_ELx_SYS64_ISS_CRM_SHIFT) 19962306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRN_SHIFT 10 20062306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRN_MASK (UL(0xf) << ESR_ELx_SYS64_ISS_CRN_SHIFT) 20162306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_OP1_SHIFT 14 20262306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_OP1_MASK (UL(0x7) << ESR_ELx_SYS64_ISS_OP1_SHIFT) 20362306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_OP2_SHIFT 17 20462306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_OP2_MASK (UL(0x7) << ESR_ELx_SYS64_ISS_OP2_SHIFT) 20562306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_OP0_SHIFT 20 20662306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_OP0_MASK (UL(0x3) << ESR_ELx_SYS64_ISS_OP0_SHIFT) 20762306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_MASK (ESR_ELx_SYS64_ISS_OP0_MASK | \ 20862306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_OP1_MASK | \ 20962306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_OP2_MASK | \ 21062306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_CRN_MASK | \ 21162306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_CRM_MASK) 21262306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_VAL(op0, op1, op2, crn, crm) \ 21362306a36Sopenharmony_ci (((op0) << ESR_ELx_SYS64_ISS_OP0_SHIFT) | \ 21462306a36Sopenharmony_ci ((op1) << ESR_ELx_SYS64_ISS_OP1_SHIFT) | \ 21562306a36Sopenharmony_ci ((op2) << ESR_ELx_SYS64_ISS_OP2_SHIFT) | \ 21662306a36Sopenharmony_ci ((crn) << ESR_ELx_SYS64_ISS_CRN_SHIFT) | \ 21762306a36Sopenharmony_ci ((crm) << ESR_ELx_SYS64_ISS_CRM_SHIFT)) 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_OP_MASK (ESR_ELx_SYS64_ISS_SYS_MASK | \ 22062306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_MASK) 22162306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_RT(esr) \ 22262306a36Sopenharmony_ci (((esr) & ESR_ELx_SYS64_ISS_RT_MASK) >> ESR_ELx_SYS64_ISS_RT_SHIFT) 22362306a36Sopenharmony_ci/* 22462306a36Sopenharmony_ci * User space cache operations have the following sysreg encoding 22562306a36Sopenharmony_ci * in System instructions. 22662306a36Sopenharmony_ci * op0=1, op1=3, op2=1, crn=7, crm={ 5, 10, 11, 12, 13, 14 }, WRITE (L=0) 22762306a36Sopenharmony_ci */ 22862306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRM_DC_CIVAC 14 22962306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRM_DC_CVADP 13 23062306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRM_DC_CVAP 12 23162306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRM_DC_CVAU 11 23262306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRM_DC_CVAC 10 23362306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRM_IC_IVAU 5 23462306a36Sopenharmony_ci 23562306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_EL0_CACHE_OP_MASK (ESR_ELx_SYS64_ISS_OP0_MASK | \ 23662306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_OP1_MASK | \ 23762306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_OP2_MASK | \ 23862306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_CRN_MASK | \ 23962306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_MASK) 24062306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_EL0_CACHE_OP_VAL \ 24162306a36Sopenharmony_ci (ESR_ELx_SYS64_ISS_SYS_VAL(1, 3, 1, 7, 0) | \ 24262306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_WRITE) 24362306a36Sopenharmony_ci/* 24462306a36Sopenharmony_ci * User space MRS operations which are supported for emulation 24562306a36Sopenharmony_ci * have the following sysreg encoding in System instructions. 24662306a36Sopenharmony_ci * op0 = 3, op1= 0, crn = 0, {crm = 0, 4-7}, READ (L = 1) 24762306a36Sopenharmony_ci */ 24862306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_MRS_OP_MASK (ESR_ELx_SYS64_ISS_OP0_MASK | \ 24962306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_OP1_MASK | \ 25062306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_CRN_MASK | \ 25162306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_MASK) 25262306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_MRS_OP_VAL \ 25362306a36Sopenharmony_ci (ESR_ELx_SYS64_ISS_SYS_VAL(3, 0, 0, 0, 0) | \ 25462306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_READ) 25562306a36Sopenharmony_ci 25662306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_CTR ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 1, 0, 0) 25762306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_CTR_READ (ESR_ELx_SYS64_ISS_SYS_CTR | \ 25862306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_READ) 25962306a36Sopenharmony_ci 26062306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_CNTVCT (ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 2, 14, 0) | \ 26162306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_READ) 26262306a36Sopenharmony_ci 26362306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_CNTVCTSS (ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 6, 14, 0) | \ 26462306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_READ) 26562306a36Sopenharmony_ci 26662306a36Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_CNTFRQ (ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 0, 14, 0) | \ 26762306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_READ) 26862306a36Sopenharmony_ci 26962306a36Sopenharmony_ci#define esr_sys64_to_sysreg(e) \ 27062306a36Sopenharmony_ci sys_reg((((e) & ESR_ELx_SYS64_ISS_OP0_MASK) >> \ 27162306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_OP0_SHIFT), \ 27262306a36Sopenharmony_ci (((e) & ESR_ELx_SYS64_ISS_OP1_MASK) >> \ 27362306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_OP1_SHIFT), \ 27462306a36Sopenharmony_ci (((e) & ESR_ELx_SYS64_ISS_CRN_MASK) >> \ 27562306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_CRN_SHIFT), \ 27662306a36Sopenharmony_ci (((e) & ESR_ELx_SYS64_ISS_CRM_MASK) >> \ 27762306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_CRM_SHIFT), \ 27862306a36Sopenharmony_ci (((e) & ESR_ELx_SYS64_ISS_OP2_MASK) >> \ 27962306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_OP2_SHIFT)) 28062306a36Sopenharmony_ci 28162306a36Sopenharmony_ci#define esr_cp15_to_sysreg(e) \ 28262306a36Sopenharmony_ci sys_reg(3, \ 28362306a36Sopenharmony_ci (((e) & ESR_ELx_SYS64_ISS_OP1_MASK) >> \ 28462306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_OP1_SHIFT), \ 28562306a36Sopenharmony_ci (((e) & ESR_ELx_SYS64_ISS_CRN_MASK) >> \ 28662306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_CRN_SHIFT), \ 28762306a36Sopenharmony_ci (((e) & ESR_ELx_SYS64_ISS_CRM_MASK) >> \ 28862306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_CRM_SHIFT), \ 28962306a36Sopenharmony_ci (((e) & ESR_ELx_SYS64_ISS_OP2_MASK) >> \ 29062306a36Sopenharmony_ci ESR_ELx_SYS64_ISS_OP2_SHIFT)) 29162306a36Sopenharmony_ci 29262306a36Sopenharmony_ci/* ISS field definitions for ERET/ERETAA/ERETAB trapping */ 29362306a36Sopenharmony_ci#define ESR_ELx_ERET_ISS_ERET 0x2 29462306a36Sopenharmony_ci#define ESR_ELx_ERET_ISS_ERETA 0x1 29562306a36Sopenharmony_ci 29662306a36Sopenharmony_ci/* 29762306a36Sopenharmony_ci * ISS field definitions for floating-point exception traps 29862306a36Sopenharmony_ci * (FP_EXC_32/FP_EXC_64). 29962306a36Sopenharmony_ci * 30062306a36Sopenharmony_ci * (The FPEXC_* constants are used instead for common bits.) 30162306a36Sopenharmony_ci */ 30262306a36Sopenharmony_ci 30362306a36Sopenharmony_ci#define ESR_ELx_FP_EXC_TFV (UL(1) << 23) 30462306a36Sopenharmony_ci 30562306a36Sopenharmony_ci/* 30662306a36Sopenharmony_ci * ISS field definitions for CP15 accesses 30762306a36Sopenharmony_ci */ 30862306a36Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_DIR_MASK 0x1 30962306a36Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_DIR_READ 0x1 31062306a36Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_DIR_WRITE 0x0 31162306a36Sopenharmony_ci 31262306a36Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_RT_SHIFT 5 31362306a36Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_RT_MASK (UL(0x1f) << ESR_ELx_CP15_32_ISS_RT_SHIFT) 31462306a36Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_CRM_SHIFT 1 31562306a36Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_CRM_MASK (UL(0xf) << ESR_ELx_CP15_32_ISS_CRM_SHIFT) 31662306a36Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_CRN_SHIFT 10 31762306a36Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_CRN_MASK (UL(0xf) << ESR_ELx_CP15_32_ISS_CRN_SHIFT) 31862306a36Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_OP1_SHIFT 14 31962306a36Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_OP1_MASK (UL(0x7) << ESR_ELx_CP15_32_ISS_OP1_SHIFT) 32062306a36Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_OP2_SHIFT 17 32162306a36Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_OP2_MASK (UL(0x7) << ESR_ELx_CP15_32_ISS_OP2_SHIFT) 32262306a36Sopenharmony_ci 32362306a36Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_SYS_MASK (ESR_ELx_CP15_32_ISS_OP1_MASK | \ 32462306a36Sopenharmony_ci ESR_ELx_CP15_32_ISS_OP2_MASK | \ 32562306a36Sopenharmony_ci ESR_ELx_CP15_32_ISS_CRN_MASK | \ 32662306a36Sopenharmony_ci ESR_ELx_CP15_32_ISS_CRM_MASK | \ 32762306a36Sopenharmony_ci ESR_ELx_CP15_32_ISS_DIR_MASK) 32862306a36Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_SYS_VAL(op1, op2, crn, crm) \ 32962306a36Sopenharmony_ci (((op1) << ESR_ELx_CP15_32_ISS_OP1_SHIFT) | \ 33062306a36Sopenharmony_ci ((op2) << ESR_ELx_CP15_32_ISS_OP2_SHIFT) | \ 33162306a36Sopenharmony_ci ((crn) << ESR_ELx_CP15_32_ISS_CRN_SHIFT) | \ 33262306a36Sopenharmony_ci ((crm) << ESR_ELx_CP15_32_ISS_CRM_SHIFT)) 33362306a36Sopenharmony_ci 33462306a36Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_DIR_MASK 0x1 33562306a36Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_DIR_READ 0x1 33662306a36Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_DIR_WRITE 0x0 33762306a36Sopenharmony_ci 33862306a36Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_RT_SHIFT 5 33962306a36Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_RT_MASK (UL(0x1f) << ESR_ELx_CP15_64_ISS_RT_SHIFT) 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_RT2_SHIFT 10 34262306a36Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_RT2_MASK (UL(0x1f) << ESR_ELx_CP15_64_ISS_RT2_SHIFT) 34362306a36Sopenharmony_ci 34462306a36Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_OP1_SHIFT 16 34562306a36Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_OP1_MASK (UL(0xf) << ESR_ELx_CP15_64_ISS_OP1_SHIFT) 34662306a36Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_CRM_SHIFT 1 34762306a36Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_CRM_MASK (UL(0xf) << ESR_ELx_CP15_64_ISS_CRM_SHIFT) 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_SYS_VAL(op1, crm) \ 35062306a36Sopenharmony_ci (((op1) << ESR_ELx_CP15_64_ISS_OP1_SHIFT) | \ 35162306a36Sopenharmony_ci ((crm) << ESR_ELx_CP15_64_ISS_CRM_SHIFT)) 35262306a36Sopenharmony_ci 35362306a36Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_SYS_MASK (ESR_ELx_CP15_64_ISS_OP1_MASK | \ 35462306a36Sopenharmony_ci ESR_ELx_CP15_64_ISS_CRM_MASK | \ 35562306a36Sopenharmony_ci ESR_ELx_CP15_64_ISS_DIR_MASK) 35662306a36Sopenharmony_ci 35762306a36Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_SYS_CNTVCT (ESR_ELx_CP15_64_ISS_SYS_VAL(1, 14) | \ 35862306a36Sopenharmony_ci ESR_ELx_CP15_64_ISS_DIR_READ) 35962306a36Sopenharmony_ci 36062306a36Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_SYS_CNTVCTSS (ESR_ELx_CP15_64_ISS_SYS_VAL(9, 14) | \ 36162306a36Sopenharmony_ci ESR_ELx_CP15_64_ISS_DIR_READ) 36262306a36Sopenharmony_ci 36362306a36Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_SYS_CNTFRQ (ESR_ELx_CP15_32_ISS_SYS_VAL(0, 0, 14, 0) |\ 36462306a36Sopenharmony_ci ESR_ELx_CP15_32_ISS_DIR_READ) 36562306a36Sopenharmony_ci 36662306a36Sopenharmony_ci/* 36762306a36Sopenharmony_ci * ISS values for SME traps 36862306a36Sopenharmony_ci */ 36962306a36Sopenharmony_ci 37062306a36Sopenharmony_ci#define ESR_ELx_SME_ISS_SME_DISABLED 0 37162306a36Sopenharmony_ci#define ESR_ELx_SME_ISS_ILL 1 37262306a36Sopenharmony_ci#define ESR_ELx_SME_ISS_SM_DISABLED 2 37362306a36Sopenharmony_ci#define ESR_ELx_SME_ISS_ZA_DISABLED 3 37462306a36Sopenharmony_ci#define ESR_ELx_SME_ISS_ZT_DISABLED 4 37562306a36Sopenharmony_ci 37662306a36Sopenharmony_ci/* ISS field definitions for MOPS exceptions */ 37762306a36Sopenharmony_ci#define ESR_ELx_MOPS_ISS_MEM_INST (UL(1) << 24) 37862306a36Sopenharmony_ci#define ESR_ELx_MOPS_ISS_FROM_EPILOGUE (UL(1) << 18) 37962306a36Sopenharmony_ci#define ESR_ELx_MOPS_ISS_WRONG_OPTION (UL(1) << 17) 38062306a36Sopenharmony_ci#define ESR_ELx_MOPS_ISS_OPTION_A (UL(1) << 16) 38162306a36Sopenharmony_ci#define ESR_ELx_MOPS_ISS_DESTREG(esr) (((esr) & (UL(0x1f) << 10)) >> 10) 38262306a36Sopenharmony_ci#define ESR_ELx_MOPS_ISS_SRCREG(esr) (((esr) & (UL(0x1f) << 5)) >> 5) 38362306a36Sopenharmony_ci#define ESR_ELx_MOPS_ISS_SIZEREG(esr) (((esr) & (UL(0x1f) << 0)) >> 0) 38462306a36Sopenharmony_ci 38562306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 38662306a36Sopenharmony_ci#include <asm/types.h> 38762306a36Sopenharmony_ci 38862306a36Sopenharmony_cistatic inline bool esr_is_data_abort(unsigned long esr) 38962306a36Sopenharmony_ci{ 39062306a36Sopenharmony_ci const unsigned long ec = ESR_ELx_EC(esr); 39162306a36Sopenharmony_ci 39262306a36Sopenharmony_ci return ec == ESR_ELx_EC_DABT_LOW || ec == ESR_ELx_EC_DABT_CUR; 39362306a36Sopenharmony_ci} 39462306a36Sopenharmony_ci 39562306a36Sopenharmony_ciconst char *esr_get_class_string(unsigned long esr); 39662306a36Sopenharmony_ci#endif /* __ASSEMBLY */ 39762306a36Sopenharmony_ci 39862306a36Sopenharmony_ci#endif /* __ASM_ESR_H */ 399