(old) htmldiff from-(new)

Shared Pseudocode Functions

This page displays common pseudocode functions shared by many pages

Pseudocode

Library pseudocode for aarch32/at/AArch32_EncodePARLD

// AArch32_EncodePARLD() // ===================== // Returns 64-bit format PAR on address translation instruction. func AArch32_EncodePARLD(addrdesc : AddressDescriptor, ss : SecurityState) begin PAR()[63:0] = Zeros{64}; if !IsFault(addrdesc) then var ns : bit; if ss == SS_NonSecure then ns = ARBITRARY : bit; elsif addrdesc.paddress.paspace == PAS_Secure then ns = '0'; else ns = '1'; end; PAR().F = '0'; PAR().F0_64.SH = PAR().SH = ReportedPARShareability(PAREncodeShareability(addrdesc.memattrs)); PAR().NS = ns; PAR()[10] = ImpDefBit("Non-Faulting PAR"); // IMPDEF PAR().LPAE = '1'; PAR().F0_64.PA = addrdesc.paddress.address[39:12]; PAR().PA = addrdesc.paddress.address[39:12]; PAR().ATTR = ReportedPARAttrs(EncodePARAttrs(addrdesc.memattrs)); else PAR().F = '1'; PAR().FST = AArch32_PARFaultStatusLD(addrdesc.fault); PAR().S2WLK = if addrdesc.fault.s2fs1walk then '1' else '0'; PAR().FSTAGE = if addrdesc.fault.secondstage then '1' else '0'; PAR().LPAE = '1'; PAR()[63:48] = ImpDefBits{16}("Faulting PAR"); // IMPDEF end; return; end;

Library pseudocode for aarch32/at/AArch32_EncodePARSD

// AArch32_EncodePARSD() // ===================== // Returns 32-bit format PAR on address translation instruction. func AArch32_EncodePARSD(addrdesc_in : AddressDescriptor, supersection : bit, ss : SecurityState) begin PAR()[31:0] = Zeros{32}; var addrdesc : AddressDescriptor = addrdesc_in; if !IsFault(addrdesc) then if (addrdesc.memattrs.memtype == MemType_Device || (addrdesc.memattrs.inner.attrs == MemAttr_NC && addrdesc.memattrs.outer.attrs == MemAttr_NC)) then addrdesc.memattrs.shareability = Shareability_OSH; end; var ns : bit; if ss == SS_NonSecure then ns = ARBITRARY : bit; elsif addrdesc.paddress.paspace == PAS_Secure then ns = '0'; else ns = '1'; end; let sh : bits(2) = let sh : bits(2) = (if addrdesc.memattrs.shareability != ReportedPARShareabilityShareability_NSH(then '01' else '00'); PAR().F = '0'; PAR().SS = supersection; PAR().Outer =PAREncodeShareability(addrdesc.memattrs)); PAR().F = '0'; PAR().SS = supersection; PAR().Outer = AArch32_ReportedOuterAttrs(AArch32_PAROuterAttrs(addrdesc.memattrs)); PAR().Inner = AArch32_ReportedInnerAttrs(AArch32_PARInnerAttrs(addrdesc.memattrs)); PAR().SH = ReportedPARShareability(sh); PAR()[8] = ImpDefBit("Non-Faulting PAR"); // IMPDEF PAR().NS = ns; PAR().NOS = if addrdesc.memattrs.shareability == Shareability_OSH(addrdesc.memattrs)); PAR().F0_32.SH = sh[1]; PAR()[8] = ImpDefBit("Non-Faulting PAR"); // IMPDEF PAR().NS = ns; PAR().NOS = sh[0]; then '0' else '1'; PAR().LPAE = '0'; PAR().F0_32.PA = addrdesc.paddress.address[31:12]; PAR().PA = addrdesc.paddress.address[39:12]; else PAR().F = '1'; PAR().FST = AArch32_PARFaultStatusSD(addrdesc.fault); PAR().LPAE = '0'; PAR()[31:16] = ImpDefBits{16}("Faulting PAR"); // IMPDEF end; return; end;

Library pseudocode for aarch32/at/GetPAR_F

// GetPAR_F() // ========== // Query the PAR.F field. func GetPAR_F() => bit begin return PAR().F; end;

Library pseudocode for aarch32/at/GetPAR_LPAE

// GetPAR_LPAE() // ============= // Query the PAR.LPAE field. func GetPAR_LPAE() => bit begin return PAR().LPAE; end;

Library pseudocode for aarch32/functions/system/BPIALL

// BPIALL() // ======== // Invalidate all entries from branch predictors. impdef func BPIALL() begin return; end;

Library pseudocode for aarch32/functions/system/BPIALLIS

// BPIALLIS() // ========== // Invalidate all entries from branch predictors, Inner Shareable. impdef func BPIALLIS() begin return; end;

Library pseudocode for aarch32/functions/system/BPIMVA

// BPIMVA() // ======== // Invalidate the virtual address from the branch predictors. impdef func BPIMVA(val : bits(32)) begin return; end;

Library pseudocode for aarch32/functions/system/CP15DMB

// CP15DMB() // ========= // Legacy AArch32 system instruction form of DMB SY. func CP15DMB() begin DataMemoryBarrier(MBReqTypes_All); return; end;

Library pseudocode for aarch32/functions/system/CP15DSB

// CP15DSB() // ========= // Legacy AArch32 system instruction form of DSB SY. func CP15DSB() begin DataSynchronizationBarrier(MBMaintenanceScope_OuterShareable, MBReqTypes_All, FALSE); return; end;

Library pseudocode for aarch32/functions/system/CP15ISB

// CP15ISB() // ========= // Legacy AArch32 system instruction form of ISB. func CP15ISB() begin InstructionSynchronizationBarrier(); return; end;

Library pseudocode for aarch32/translation/attrs/ImpDefMemoryAttributes

// ImpDefMemoryAttributes() // ======================== // Return an IMPLEMENTATION DEFINED set of memory attributes identified by the string parameter. impdef func ImpDefMemoryAttributes(x : string) => MemoryAttributes begin return ARBITRARY : MemoryAttributes; end;

Library pseudocode for aarch32/translation/translation/AArch32_EL2Enabled

// AArch32_EL2Enabled() // ==================== // When using VMSAv8-32, returns whether EL2 is enabled for the given Security State. // Returns whether EL2 is enabled for the given Security State func AArch32_EL2Enabled(ss : SecurityState) => boolean begin assert if ss == ELUsingAArch32(EL1); if ss == SS_Secure then if !(HaveEL(EL2) && IsFeatureImplemented(FEAT_SEL2)) then return FALSE; elsif HaveEL(EL3) then return SCR_EL3().EEL2 == '1'; else return SecureOnlyImplementation(); ) then return SCR_EL3().EEL2 == '1'; else return ImpDefBool("Secure-only implementation"); end; else return HaveEL(EL2); end; end;

Library pseudocode for aarch32/translation/translation/AArch32_S1DisabledOutput

// AArch32_S1DisabledOutput() // ========================== // Flat map the VA to IPA/PA, depending on the regime, assigning default memory attributes func AArch32_S1DisabledOutput(fault_in : FaultRecord, regime : Regime, va : bits(32), aligned : boolean, accdesc : AccessDescriptor) => (FaultRecord, AddressDescriptor) begin var fault : FaultRecord = fault_in; // No memory page is guarded when stage 1 address translation is disabled SetInGuardedPage(FALSE); var memattrs : MemoryAttributes; var default_cacheable : bit; if regime == Regime_EL10 && AArch32_EL2Enabled(accdesc.ss) then if ELStateUsingAArch32(EL2, accdesc.ss == SS_Secure) then default_cacheable = HCR().DC; else default_cacheable = if IsFeatureImplemented(FEAT_HCRMAC) then HCR_EL2().DC else '0'; default_cacheable = HCR_EL2().DC; end; else default_cacheable = '0'; end; if default_cacheable == '1' then // Use default cacheable settings memattrs.memtype = MemType_Normal; memattrs.inner.attrs = MemAttr_WB; memattrs.inner.hints = MemHint_RWA; memattrs.outer.attrs = MemAttr_WB; memattrs.outer.hints = MemHint_RWA; memattrs.shareability = Shareability_NSH; memattrs.tags = MemTag_Untagged; memattrs.xs = '0'; elsif accdesc.acctype == AccessType_IFETCH then memattrs.memtype = MemType_Normal; memattrs.shareability = Shareability_OSH; memattrs.tags = MemTag_Untagged; if AArch32_S1ICacheEnabled(regime) then memattrs.inner.attrs = MemAttr_WT; memattrs.inner.hints = MemHint_RA; memattrs.outer.attrs = MemAttr_WT; memattrs.outer.hints = MemHint_RA; else memattrs.inner.attrs = MemAttr_NC; memattrs.outer.attrs = MemAttr_NC; end; memattrs.xs = '1'; else // Treat memory region as Device memattrs.memtype = MemType_Device; memattrs.device = DeviceType_nGnRnE; memattrs.shareability = Shareability_OSH; memattrs.tags = MemTag_Untagged; memattrs.xs = '1'; end; var ntlsmd : bit; if IsFeatureImplemented(FEAT_LSMAOC) then case regime of when Regime_EL30 => ntlsmd = SCTLR_S().nTLSMD; when Regime_EL2 => ntlsmd = HSCTLR().nTLSMD; when Regime_EL10 => if HaveEL(EL3) && ELUsingAArch32(EL3) then ntlsmd = SCTLR_NS().nTLSMD; else ntlsmd = SCTLR().nTLSMD; end; end; else ntlsmd = '1'; end; if AArch32_S1HasAlignmentFaultDueToMemType(accdesc, aligned, ntlsmd, memattrs) then fault.statuscode = Fault_Alignment; return (fault, ARBITRARY : AddressDescriptor); elsif (accdesc.exclusive && !(regime == Regime_EL10 && EL2Enabled() && ((!ELUsingAArch32(EL2) && IsFeatureImplemented(FEAT_HCRMAC) && HCR_EL2().DC == '1') || ) && HCR_EL2().DC == '1') || (ELUsingAArch32(EL2) && HCR().DC == '1'))) && ConstrainUnpredictableBool(Unpredictable_Atomic_MMU_IMPDEF_FAULT)) then fault.statuscode = Fault_Exclusive; end; var oa : FullAddress; oa.address = ZeroExtend{NUM_PABITS}(va); oa.paspace = if accdesc.ss == SS_Secure then PAS_Secure else PAS_NonSecure; let ipa : AddressDescriptor = CreateAddressDescriptor(ZeroExtend{64}(va), oa, memattrs, accdesc); return (fault, ipa); end;

Library pseudocode for aarch64/debug/brbe/BRBEException

// BRBEException() // =============== // Called to write exception branch record when BRBE is active. func BRBEException(erec : ExceptionRecord, source_valid : boolean, source_address_in : bits(64), target_address_in : bits(64), target_el : bits(2), trappedsyscallinst : boolean) begin var target_address : bits(64) = target_address_in; let except : Exception = erec.exceptype; let iss : bits(25) = erec.syndrome.iss; case target_el of when EL3 => if !IsFeatureImplemented(FEAT_BRBEv1p1) || (MDCR_EL3().E3BREC == MDCR_EL3().E3BREW) then return; end; when EL2 => if BRBCR_EL2().EXCEPTION == '0' then return; end; when EL1 => if BRBCR_EL1().EXCEPTION == '0' then return; end; end; let target_valid : boolean = BranchRecordAllowed(target_el); if source_valid || target_valid then var branch_type : bits(6); case except of when Exception_Uncategorized => branch_type = '100011'; // Trap when Exception_WFxTrap => branch_type = '100011'; // Trap when Exception_CP15RTTrap => branch_type = '100011'; // Trap when Exception_CP15RRTTrap => branch_type = '100011'; // Trap when Exception_CP14RTTrap => branch_type = '100011'; // Trap when Exception_CP14DTTrap => branch_type = '100011'; // Trap when Exception_AdvSIMDFPAccessTrap => branch_type = '100011'; // Trap when Exception_FPIDTrap => branch_type = '100011'; // Trap when Exception_PACTrap => branch_type = '100011'; // Trap when Exception_CP14RRTTrap => branch_type = '100011'; // Trap when Exception_OtherTrap => branch_type = '100011'; // Trap when Exception_BranchTarget => branch_type = '101011'; // Inst Fault when Exception_IllegalState => branch_type = '100011'; // Trap when Exception_SupervisorCall => if !trappedsyscallinst then branch_type = '100010'; // Call else branch_type = '100011'; // Trap end; when Exception_HypervisorCall => branch_type = '100010'; // Call when Exception_MonitorCall => if !trappedsyscallinst then branch_type = '100010'; // Call else branch_type = '100011'; // Trap end; when Exception_SystemRegisterTrap => branch_type = '100011'; // Trap when Exception_SystemRegister128Trap => branch_type = '100011'; // Trap when Exception_SVEAccessTrap => branch_type = '100011'; // Trap when Exception_SMEAccessTrap => branch_type = '100011'; // Trap when Exception_ERetTrap => branch_type = '100011'; // Trap when Exception_PACFail => branch_type = '101100'; // Data Fault when Exception_InstructionAbort => branch_type = '101011'; // Inst Fault when Exception_PCAlignment => branch_type = '101010'; // Alignment when Exception_DataAbort => branch_type = '101100'; // Data Fault when Exception_NV2DataAbort => branch_type = '101100'; // Data Fault when Exception_SPAlignment => branch_type = '101010'; // Alignment when Exception_FPTrappedException => branch_type = '100011'; // Trap when Exception_SError => branch_type = '100100'; // System Error when Exception_Breakpoint => branch_type = '100110'; // Inst debug when Exception_SoftwareStep => branch_type = '100110'; // Inst debug when Exception_Watchpoint => branch_type = '100111'; // Data debug when Exception_NV2Watchpoint => branch_type = '100111'; // Data debug when Exception_SoftwareBreakpoint => branch_type = '100110'; // Inst debug when Exception_IRQ => branch_type = '101110'; // IRQ when Exception_FIQ => branch_type = '101111'; // FIQ when Exception_MemCpyMemSet => branch_type = '100011'; // Trap when Exception_GCSFail => if iss[23:20] == '0000' then branch_type = '101100'; // Data Fault elsif iss[23:20] == '0001' then branch_type = '101011'; // Inst Fault elsif iss[23:20] == '0010' then branch_type = '100011'; // Trap else unreachable; end; when Exception_Profiling => branch_type = '100110'; // Inst debug when Exception_GPC => if iss[20] == '1' then branch_type = '101011'; // Inst fault else branch_type = '101100'; // Data fault end; when otherwise => unreachable; end; var ccu : bit; var cc : bits(14); (ccu, cc) = Exception_ConditionalFault => branch_type = '100110'; // Inst debug otherwise => unreachable; end; var ccu : bit; var cc : bits(14); (ccu, cc) = BranchEncCycleCount(); let el : bits(2) = if target_valid then target_el else '00'; let mispredict : bit = '0'; let sv : bit = if source_valid then '1' else '0'; let tv : bit = if target_valid then '1' else '0'; let source_address : bits(64) = if source_valid then source_address_in else Zeros{64}; if !target_valid then target_address = Zeros{64}; else target_address = AArch64_BranchAddr(target_address, target_el); end; UpdateBranchRecordBuffer(ccu, cc, branch_type, el, mispredict, sv::tv, source_address, target_address); PMUEvent(PMU_EVENT_BRB_FILTRATE); end; return; end;

Library pseudocode for aarch64/debug/statisticalprofiling/SPEAddressEnabled

// SPEAddressEnabled() // =================== // Checks if an address packet is enabled and its data can be recorded. func SPEAddressEnabled(address_index : integer) => boolean begin var address_packet_enabled: boolean; let have_pbtfilt : boolean = IsFeatureImplemented(FEAT_SPE_PBTFILT); case address_index of when SPEAddrPosPrevBranchTarget => address_packet_enabled = !have_pbtfilt || PMSFCR_EL1().nPBT == '0'; otherwise => address_packet_enabled = TRUE; end; return address_packet_enabled; end;

Library pseudocode for aarch64/debug/statisticalprofiling/SPEConstructRecord

// SPEConstructRecord() // ==================== // Create new record and populate it with packets using sample storage data. // This is an example implementation, packets may appear in // any order as long as the record ends with an End or Timestamp packet. func SPEConstructRecord() begin // Empty the record. SPEEmptyRecord(); var op_class : bits(2); var op_subclass : bits(8); // Add operation details (op_class, op_subclass) = SPEConstructClass(); SPEAddPacketToRecord{8}('01', '10'::op_class, op_subclass); // Add contextEL1 if available if SPESampleContextEL1Valid then SPEAddPacketToRecord{32}('01', '0100', SPESampleContextEL1); end; // Add contextEL2 if available if SPESampleContextEL2Valid then SPEAddPacketToRecord{32}('01', '0101', SPESampleContextEL2); end; // Add valid counters for counter_index = 0 to (SPEMaxCounters - 1) do if SPESampleCounterValid[[counter_index]] then if counter_index >= 8 then // Need extended format SPEAddByteToRecord('001000'::counter_index[4:3]); end; // Check for overflow let large_counters : boolean = ImpDefBool("SPE 16bit counters"); if large_counters then if SPESampleCounter[[counter_index]] > 0xFFFF then SPESampleCounter[[counter_index]] = 0xFFFF; end; else if SPESampleCounter[[counter_index]] > 0xFFF then SPESampleCounter[[counter_index]] = 0xFFF; end; end; // Add byte0 for short format (byte1 for extended format) SPEAddPacketToRecord{16}('10', '1'::counter_index[2:0], SPESampleCounter[[counter_index]][15:0]); end; end; // Add valid addresses if IsFeatureImplemented(FEAT_SPE_PBT) then // Under some conditions, it is IMPLEMENTATION_DEFINED whether the // previous branch packet is present. let include_prev_br : boolean = ImpDefBool("SPE get prev br if not br"); if SPESampleOpAttr.op_type != SPEOpType_Branch && !include_prev_br then SPESampleAddressValid[[SPEAddrPosPrevBranchTarget]] = FALSE; end; end; // Data Virtual address should not be collected if this was an NV2 access and Statistical // Profiling is disabled at EL2. if !StatisticalProfilingEnabled(EL2) && SPESampleOpAttr.ldst_type == SPELDSTType_NV2 then SPESampleAddressValid[[SPEAddrPosDataVirtual]] = FALSE; end; for address_index = 0 to (SPEMaxAddrs - 1) do if SPESampleAddressValid[[address_index]] &&[[address_index]] then if address_index >= 8 then // Need extended format SPEAddressEnabled(address_index) then if address_index >= 8 then // Need extended format SPEAddByteToRecord('001000'::address_index[4:3]); end; SPEAddPacketToRecord{64}('10', '0'::address_index[2:0], SPESampleAddress[[address_index]]); end; end; // Add Data Source if SPESampleDataSourceValid then let ds_payload_size : integer{} = SPEGetDataSourcePayloadSize(); SPEAddPacketToRecord{8 * ds_payload_size}('01', '0011', SPESampleDataSource[8*ds_payload_size-1:0]); end; // Add events // Get size of payload in bytes. let payload_size : integer{} = SPEGetEventsPayloadSize(); SPEAddPacketToRecord{8 * payload_size}('01', '0010', SPESampleEvents[8*payload_size-1:0]); // Add Timestamp to end the record if one is available. // Otherwise end with an End packet. if SPESampleTimestampValid then SPEAddPacketToRecord{64}('01', '0001', SPESampleTimestamp); else SPEAddByteToRecord('00000001'); end; // Add padding while SPERecordSize MOD (1<<UInt(PMBIDR_EL1().Align)) != 0 looplimit 2048 do SPEAddByteToRecord(Zeros{8}); end; SPEWriteToBuffer(); CTI_SignalEvent(CrossTriggerIn_SPESample); end;

Library pseudocode for aarch64/debug/statisticalprofiling/SPEMultiAccessSample

// SPEMultiAccessSample() // ====================== // Called by instructions which make at least one store and one load access, where the configuration // of the operation type filter affects which access is sampled. func SPEMultiAccessSample() => boolean begin // If loads or stores are filtered out, the other should be recorded. // If neither or both are filtered out, pick one in an unbiased way. // Bit positions in the PMSFCR_EL1().[TYPE, TYPEm] fields. let LD : integer = 1; let ST : integer = 2; // Are loads allowed by filter? let loads_pass_filter : boolean = PMSFCR_EL1().FT == '1' && PMSFCR_EL1().TYPE.LD == '1'; let loads_pass_filter : boolean = PMSFCR_EL1().FT == '1' && PMSFCR_EL1().TYPE[LD] == '1'; // Are stores allowed by filter? let stores_pass_filter : boolean = PMSFCR_EL1().FT == '1' && PMSFCR_EL1().TYPE.ST == '1'; let stores_pass_filter : boolean = PMSFCR_EL1().FT == '1' && PMSFCR_EL1().TYPE[ST] == '1'; var record_load : boolean; if loads_pass_filter && !stores_pass_filter then // Only loads pass filter record_load = TRUE; elsif !loads_pass_filter && stores_pass_filter then // Only stores pass filter record_load = FALSE; else // Both loads and stores pass the filter or neither pass the filter. // Pick between the load or the store access (pseudo-)randomly. record_load = SPEGetRandomBoolean(); end; return record_load; end;

Library pseudocode for aarch64/exceptions/aborts/AArch64_AbortSyndrome

// AArch64_AbortSyndrome() // ======================= // Creates an exception syndrome record for Abort and Watchpoint exceptions // from an AArch64 translation regime. func AArch64_AbortSyndrome(exceptype : Exception, fault : FaultRecord, target_el : bits(2)) => ExceptionRecord begin var except : ExceptionRecord = ExceptionSyndrome(exceptype); except.syndrome = AArch64_FaultSyndrome(exceptype, fault, target_el); if exceptype IN {Exception_NV2Watchpoint, Exception_Watchpoint} then except.vaddress = fault.watchptinfo.vaddress; elsif fault.statuscode == Fault_TagCheck then if IsFeatureImplemented(FEAT_MTE_TAGGED_FAR) then except.vaddress = ZeroExtend{64}(fault.vaddress); else except.vaddress = ARBITRARY : bits(4) :: fault.vaddress[59:0]; end; else except.vaddress = ZeroExtend{64}(fault.vaddress); end; if IPAValid(fault) then except.ipavalid = TRUE; except.NS = if fault.ipaddress.paspace == PAS_NonSecure then '1' else '0'; except.ipaddress = fault.ipaddress.address; else except.ipavalid = FALSE; end; if except.syndrome.iss[24,14] == '01' then if except.syndrome.iss[14] == '1' then except.pavalid = TRUE; except.paddress = fault.paddress; else except.pavalid = FALSE; except.paddress = ARBITRARY : FullAddress; end; return except; end;

Library pseudocode for aarch64/exceptions/aborts/BranchTargetException

// BranchTargetException() // ======================= // Generate branch target exception. // Raise branch target exception. func AArch64_BranchTargetException(vaddress : bits(52)) begin let preferred_exception_return : bits(64) = ThisInstrAddr{}(); let vect_offset : integer = 0x0; var except : ExceptionRecord = ExceptionSyndrome(Exception_BranchTarget); except.syndrome.iss[1:0] = PSTATE.BTYPE; except.syndrome.iss[24:2] = Zeros{23}; // RES0 var target_el : bits(2) = EL1; if UInt(PSTATE.EL) > UInt(EL1) then target_el = PSTATE.EL; elsif PSTATE.EL == EL0 && EL2Enabled() && HCR_EL2().TGE == '1' then target_el = EL2; end; AArch64_TakeException(target_el, except, preferred_exception_return, vect_offset); end;

Library pseudocode for aarch64/exceptions/exceptions/AArch64_ExceptionClass

// AArch64_ExceptionClass() // ======================== // Returns the Exception Class and Instruction Length fields to be reported in ESR func AArch64_ExceptionClass(exceptype : Exception, target_el : bits(2)) => (integer,bit) begin var il_is_valid : boolean = TRUE; let from_32 : boolean = UsingAArch32(); var ec : integer; case exceptype of when Exception_Uncategorized => ec = 0x00; il_is_valid = FALSE; when Exception_WFxTrap => ec = 0x01; when Exception_CP15RTTrap => ec = 0x03; assert from_32; when Exception_CP15RRTTrap => ec = 0x04; assert from_32; when Exception_CP14RTTrap => ec = 0x05; assert from_32; when Exception_CP14DTTrap => ec = 0x06; assert from_32; when Exception_AdvSIMDFPAccessTrap => ec = 0x07; when Exception_FPIDTrap => ec = 0x08; when Exception_PACTrap => ec = 0x09; when Exception_OtherTrap => ec = 0x0A; when Exception_GPC => ec = 0x1E; when Exception_ConditionalFault => ec = 0x0B; when Exception_CP14RRTTrap => ec = 0x0C; assert from_32; when Exception_BranchTarget => ec = 0x0D; when Exception_IllegalState => ec = 0x0E; il_is_valid = FALSE; when Exception_SupervisorCall => ec = if from_32 then 0x11 else 0x15; when Exception_HypervisorCall => ec = if from_32 then 0x12 else 0x16; when Exception_MonitorCall => ec = if from_32 then 0x13 else 0x17; when Exception_SystemRegisterTrap => ec = 0x18; assert !from_32; when Exception_SystemRegister128Trap => ec = 0x14; assert !from_32; when Exception_SVEAccessTrap => ec = 0x19; assert !from_32; when Exception_ERetTrap => ec = 0x1A; assert !from_32; when Exception_PACFail => ec = 0x1C; assert !from_32; when Exception_SMEAccessTrap => ec = 0x1D; assert !from_32; when Exception_InstructionAbort => ec = if target_el == PSTATE.EL then 0x21 else 0x20; il_is_valid = FALSE; when Exception_PCAlignment => ec = 0x22; il_is_valid = FALSE; when Exception_DataAbort => ec = if target_el == PSTATE.EL then 0x25 else 0x24; when Exception_NV2DataAbort => ec = 0x25; when Exception_SPAlignment => ec = 0x26; il_is_valid = FALSE; assert !from_32; when Exception_MemCpyMemSet => ec = 0x27; when Exception_GCSFail => ec = 0x2D; assert !from_32; when Exception_FPTrappedException => ec = if from_32 then 0x28 else 0x2C; when Exception_SError => ec = 0x2F; il_is_valid = FALSE; when Exception_Breakpoint => ec = if target_el == PSTATE.EL then 0x31 else 0x30; il_is_valid = FALSE; when Exception_SoftwareStep => ec = if target_el == PSTATE.EL then 0x33 else 0x32; il_is_valid = FALSE; when Exception_Watchpoint => ec = if target_el == PSTATE.EL then 0x35 else 0x34; il_is_valid = FALSE; when Exception_NV2Watchpoint => ec = 0x35; il_is_valid = FALSE; when Exception_SoftwareBreakpoint => ec = if from_32 then 0x38 else 0x3C; when Exception_VectorCatch => ec = 0x3A; il_is_valid = FALSE; assert from_32; when Exception_Profiling => ec = 0x3D; otherwise => unreachable; end; var il : bit; if il_is_valid then il = if ThisInstrLength() == 32 then '1' else '0'; else il = '1'; end; assert from_32 || il == '1'; // AArch64 instructions always 32-bit return (ec,il); end;

Library pseudocode for aarch64/exceptions/takeexception/AArch64_TakeException

// AArch64_TakeException() // ======================= // Take an exception to an Exception level using AArch64. noreturn func AArch64_TakeException(target_el : bits(2), exception_in : ExceptionRecord, preferred_exception_return : bits(64), vect_offset_in : integer) begin assert HaveEL(target_el) && !ELUsingAArch32(target_el) && UInt(target_el) >= UInt(PSTATE.EL); if Halted() then AArch64_TakeExceptionInDebugState(target_el, exception_in); end; var except : ExceptionRecord = exception_in; var sync_errors : boolean; var iesb_req : boolean; if IsFeatureImplemented(FEAT_IESB) then sync_errors = EffectiveIESBSCTLR_EL(target_el) == '1' && except.exceptype !=(target_el).IESB == '1'; if IsFeatureImplemented(FEAT_DoubleFault) then sync_errors = sync_errors || (SCR_EL3().[EA,NMEA] == '11' && target_el == Exception_SErrorEL3; ); end; if sync_errors && InsertIESBBeforeException(target_el) then SynchronizeErrors(); if except.exceptype != Exception_SError(except.exceptype, target_el) then SynchronizeErrors(); iesb_req = FALSE; sync_errors = FALSE; TakeUnmaskedPhysicalSErrorInterrupts(iesb_req); then iesb_req = FALSE; sync_errors = FALSE; TakeUnmaskedPhysicalSErrorInterrupts(iesb_req); end; end; else sync_errors = FALSE; end; var brbe_source_allowed : boolean = FALSE; var brbe_source_address : bits(64) = Zeros{}; if IsFeatureImplemented(FEAT_BRBE) then brbe_source_allowed = BranchRecordAllowed(PSTATE.EL); brbe_source_address = preferred_exception_return; end; if !IsFeatureImplemented(FEAT_ExS) || SCTLR_EL(target_el).EIS == '1' then // Synchronize the context, including Instruction Fetch Barrier effect SynchronizeContext(); elsif !(except.exceptype == Exception_SoftwareBreakpoint || (except.exceptype IN {Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall} && !except.trappedsyscallinst)) then InstructionFetchBarrier(); end; // If coming from AArch32 state, the top parts of the X() registers might be set to zero let from_32 : boolean = UsingAArch32(); if from_32 then AArch64_MaybeZeroRegisterUppers(); end; if from_32 && IsFeatureImplemented(FEAT_SME) && PSTATE.SM == '1' then ResetSVEState(); else MaybeZeroSVEUppers(target_el); end; var vect_offset : integer = vect_offset_in; if UInt(target_el) > UInt(PSTATE.EL) then var lower_32 : boolean; if target_el == EL3 then if EL2Enabled() then lower_32 = ELUsingAArch32(EL2); else lower_32 = ELUsingAArch32(EL1); end; elsif IsInHost() && PSTATE.EL == EL0 && target_el == EL2 then lower_32 = ELUsingAArch32(EL0); else lower_32 = ELUsingAArch32(target_el - 1); end; vect_offset = vect_offset + (if lower_32 then 0x600 else 0x400); elsif PSTATE.SP == '1' then vect_offset = vect_offset + 0x200; end; assert vect_offset < 2048; let vect_base : bits(64) = VBAR_EL(target_el)[63:11]::Zeros{11}; let target_vector : bits(64) = vect_base + vect_offset; var spsr : bits(64) = GetPSRFromPSTATE{}(AArch64_NonDebugState); if PSTATE.EL == EL1 && target_el == EL1 && EL2Enabled() then if EffectiveHCR_EL2_NVx() IN {'x01', '111'} then spsr[3:2] = '10'; end; end; if IsFeatureImplemented(FEAT_BTI) && !UsingAArch32() then var zero_btype : boolean; // SPSR_ELx[].BTYPE is only guaranteed valid for these exception types if except.exceptype IN {Exception_SError, Exception_IRQ, Exception_FIQ, Exception_SoftwareStep, Exception_PCAlignment, Exception_InstructionAbort, Exception_Breakpoint, Exception_VectorCatch, Exception_SoftwareBreakpoint, Exception_IllegalState, Exception_BranchTarget} then zero_btype = FALSE; else zero_btype = ConstrainUnpredictableBool(Unpredictable_ZEROBTYPE); end; if zero_btype then spsr[11:10] = '00'; end; end; if (IsFeatureImplemented(FEAT_NV2) && except.exceptype == Exception_NV2DataAbort && target_el == EL3) then // External aborts are configured to be taken to EL3 except.exceptype = Exception_DataAbort; end; if ! except.exceptype IN {Exception_IRQ, Exception_FIQ} then AArch64_ReportException(except, target_el); end; if IsFeatureImplemented(FEAT_BRBE) then BRBEException(except, brbe_source_allowed, brbe_source_address, target_vector, target_el, except.trappedsyscallinst); end; if IsFeatureImplemented(FEAT_GCS) then if PSTATE.EL == target_el then if GetCurrentEXLOCKEN() then PSTATE.EXLOCK = '1'; else PSTATE.EXLOCK = '0'; end; else PSTATE.EXLOCK = '0'; end; end; PSTATE.EL = target_el; PSTATE.nRW = '0'; PSTATE.SP = '1'; SPSR_ELx() = spsr; ELR_ELx() = preferred_exception_return; PSTATE.SS = '0'; if IsFeatureImplemented(FEAT_SSBS) then PSTATE.SSBS = SCTLR_ELx().DSSBS; end; if (IsFeatureImplemented(FEAT_EBEP) || IsFeatureImplemented(FEAT_SPE_EXC) || IsFeatureImplemented(FEAT_TRBE_EXC)) then PSTATE.PM = '1'; end; if IsFeatureImplemented(FEAT_NMI) then PSTATE.ALLINT = NOT SCTLR_ELx().SPINTMASK; end; PSTATE.[D,A,I,F] = '1111'; if IsFeatureImplemented(FEAT_MTE) then PSTATE.TCO = '1'; end; PSTATE.IL = '0'; if IsFeatureImplemented(FEAT_UAO) then PSTATE.UAO = '0'; end; if IsFeatureImplemented(FEAT_UINJ) then PSTATE.UINJ = '0'; end; if IsFeatureImplemented(FEAT_PAuth_LR) then PSTATE.PACM = '0'; end; if IsFeatureImplemented(FEAT_PAN) && SCTLR_ELx().SPAN == '0' then if PSTATE.EL == EL1 then PSTATE.PAN = '1'; elsif PSTATE.EL == EL2 && ELIsInHost(EL0) then PSTATE.PAN = '1'; elsif (PSTATE.EL == EL2 && ELIsInHost(EL2) && (IsFeatureImplemented(FEAT_NV3) || ImpDefBool("Set PAN as 1 when E2H,TGE is '10'"))) then PSTATE.PAN = '1'; end; end; if from_32 then // Coming from AArch32 PSTATE.IT = '00000000'; PSTATE.T = '0'; // PSTATE.J is RES0 end; if IsFeatureImplemented(FEAT_BTI) then PSTATE.BTYPE = '00'; end; let branch_conditional : boolean = FALSE; BranchTo{64}(target_vector, BranchType_EXCEPTION, branch_conditional); CheckExceptionCatch(TRUE); // Check for debug event on exception entry if sync_errors then SynchronizeErrors(); iesb_req = TRUE; TakeUnmaskedPhysicalSErrorInterrupts(iesb_req); end; EndOfInstruction(EndOfInstructionReason_Exception); end;

Library pseudocode for aarch64/exceptions/traps/CheckLDST64BEnabled

// CheckLDST64BEnabled() // ===================== // Checks for trap on ST64B, LD64B, STL64B, and LDA64B instructions // Checks for trap on ST64B and LD64B instructions func CheckLDST64BEnabled(acqrel : boolean) CheckLDST64BEnabled() begin var trap : boolean = FALSE; let iss : bits(25) = if acqrel then 0x8[24:0] else 0x2[24:0]; let iss : bits(25) = 0x2[24:0]; var target_el : bits(2); if PSTATE.EL == EL0 then if !IsInHost() then trap = SCTLR_EL1().EnALS == '0'; target_el = if EL2Enabled() && HCR_EL2().TGE == '1' then EL2 else EL1; else trap = SCTLR_EL2().EnALS == '0'; target_el = EL2; end; else target_el = EL1; end; if !trap && if (!trap && EL2Enabled() && ((PSTATE.EL == EL0 && !IsInHost()) || PSTATE.EL == EL1) then )) then trap = !IsHCRXEL2Enabled() || HCRX_EL2().EnALS == '0'; target_el = EL2; end; if trap then AArch64_OtherInstrTrap(target_el, iss); end; end;

Library pseudocode for aarch64/exceptions/traps/CheckST64BV0Enabled

// CheckST64BV0Enabled() // ===================== // Checks for trap on ST64BV0 and STL64BV0 instructions // Checks for trap on ST64BV0 instruction func CheckST64BV0Enabled(acqrel : boolean) CheckST64BV0Enabled() begin var trap : boolean = FALSE; let iss : bits(25) = if acqrel then 0x7[24:0] else 0x1[24:0]; let iss : bits(25) = 0x1[24:0]; var target_el : bits(2); if if ( PSTATE.EL != EL3 && HaveEL(EL3) && SCR_EL3().EnAS0 == '0' && EL3SDDUndefPriority() then ()) then Undefined(); end; if PSTATE.EL == EL0 then if !IsInHost() then trap = SCTLR_EL1().EnAS0 == '0'; target_el = if EL2Enabled() && HCR_EL2().TGE == '1' then EL2 else EL1; else trap = SCTLR_EL2().EnAS0 == '0'; target_el = EL2; end; end; if !trap && if (!trap && EL2Enabled() && ((PSTATE.EL == EL0 && !IsInHost()) || PSTATE.EL == EL1) then )) then trap = !IsHCRXEL2Enabled() || HCRX_EL2().EnAS0 == '0'; target_el = EL2; end; if !trap && PSTATE.EL != EL3 then trap = HaveEL(EL3) && SCR_EL3().EnAS0 == '0'; target_el = EL3; end; if trap then if target_el == EL3 && EL3SDDUndef() then Undefined(); else AArch64_OtherInstrTrap(target_el, iss); end; end; end;

Library pseudocode for aarch64/exceptions/traps/CheckST64BVEnabled

// CheckST64BVEnabled() // ==================== // Checks for trap on ST64BV and STL64BV instructions // Checks for trap on ST64BV instruction func CheckST64BVEnabled(acqrel : boolean) CheckST64BVEnabled() begin var trap : boolean = FALSE; let iss : bits(25) = if acqrel then 0x6[24:0] else 0x0[24:0]; let iss : bits(25) = 0x0[24:0]; var target_el : bits(2); if PSTATE.EL == EL0 then if !IsInHost() then trap = SCTLR_EL1().EnASR == '0'; target_el = if EL2Enabled() && HCR_EL2().TGE == '1' then EL2 else EL1; else trap = SCTLR_EL2().EnASR == '0'; target_el = EL2; end; end; if !trap && if (!trap && EL2Enabled() && ((PSTATE.EL == EL0 && !IsInHost()) || PSTATE.EL == EL1) then )) then trap = !IsHCRXEL2Enabled() || HCRX_EL2().EnASR == '0'; target_el = EL2; end; if trap then AArch64_OtherInstrTrap(target_el, iss); end; end;

Library pseudocode for aarch64/functions/aborts/AArch64_FaultSyndrome

// AArch64_FaultSyndrome() // ======================= // Creates an exception syndrome value and updates the virtual address for Abort and Watchpoint // exceptions taken to an Exception level using AArch64. func AArch64_FaultSyndrome(exceptype : Exception, fault : FaultRecord, target_el : bits(2)) => IssType begin assert fault.statuscode != Fault_None; var isstype : IssType; isstype.iss = Zeros{25}; isstype.iss2 = Zeros{24}; let d_side : boolean = exceptype IN {Exception_DataAbort, Exception_NV2DataAbort, Exception_Watchpoint, Exception_NV2Watchpoint}; if IsFeatureImplemented(FEAT_RAS) && fault.statuscode == Fault_SyncExternal then let errstate : ErrorState = PEErrorState(fault); isstype.iss[12:11] = AArch64_EncodeSyncErrorSyndrome(errstate); // SET end; if d_side then if (IsFeatureImplemented(FEAT_EAESR) && exceptype == Exception_DataAbort && !fault.s2fs1walk && ! fault.accessdesc.acctype IN {AccessType_DC, AccessType_IC, AccessType_AT, AccessType_NV2}) then // LST2 field if fault.accessdesc.atomicop then isstype.iss2[15:13] = '001'; // Data Abort is from an Atomic instruction elsif (fault.accessdesc.acctype == AccessType_DCZero && fault.accessdesc.cachetype IN {CacheType_Data, CacheType_Data_Tag}) then isstype.iss2[15:13] = '010'; // Data Abort is from a DC ZVA or DC GZVA end; // Unpriv field if (fault.accessdesc.el == EL0 && PSTATE.EL != EL0 && fault.accessdesc.acctype IN {AccessType_GPR, AccessType_GCS, AccessType_ASIMD}) then isstype.iss2[12] = '1'; // Data Abort is from an unprivileged load or store end; end; if fault.accessdesc.acctype == AccessType_GCS then isstype.iss2[8] = '1'; end; if exceptype IN {Exception_Watchpoint, Exception_NV2Watchpoint} then isstype.iss[23:0] = WatchpointRelatedSyndrome(fault); end; if AArch64_InstructionSyndromeValid(fault) then if fault.accessdesc.ls64 then (isstype.iss2, isstype.iss[24:14]) = LS64InstructionSyndrome(); else isstype.iss[24:14] = LSInstructionSyndrome(); end; end; if IsFeatureImplemented(FEAT_NV2) && fault.accessdesc.acctype == AccessType_NV2 then isstype.iss[13] = '1'; // Fault is generated by use of VNCR_EL2 end; if (IsFeatureImplemented(FEAT_LS64) && fault.statuscode IN {Fault_AccessFlag, Fault_Translation, Fault_Permission}) then isstype.iss[12:11] = GetLoadStoreType(); end; if fault.accessdesc.acctype IN {AccessType_DC, AccessType_IC, AccessType_AT} then isstype.iss[8] = '1'; end; if fault.accessdesc.acctype IN {AccessType_DC, AccessType_IC, AccessType_AT} then isstype.iss[6] = '1'; elsif fault.statuscode IN {Fault_UnsupportedAtomicHWUpdate, Fault_Exclusive} then isstype.iss[6] = ARBITRARY : bit; elsif fault.accessdesc.atomicop && IsExternalAbort(fault) then isstype.iss[6] = ARBITRARY : bit; else isstype.iss[6] = if fault.write then '1' else '0'; end; isstype.iss2[9] = if fault.tagaccess then '1' else '0'; if exceptype IN { if fault.statuscode ==Exception_DataAbortFault_Permission,then isstype.iss2[5] = if fault.dirtybit then '1' else '0'; isstype.iss2[6] = if fault.overlay then '1' else '0'; if isstype.iss[24] == '0' then isstype.iss[21] = if fault.toplevel then '1' else '0'; end; isstype.iss2[7] = if fault.assuredonly then '1' else '0'; isstype.iss2[10] = if fault.s1tagnotdata then '1' else '0'; end; else if (fault.accessdesc.acctype == Exception_NV2DataAbortAccessType_IFETCH} then isstype.iss2[5] = if fault.dirtybit then '1' else '0'; isstype.iss2[6] = if fault.overlay then '1' else '0'; if isstype.iss[24] == '0' then isstype.iss[21] = if fault.toplevel then '1' else '0'; end; isstype.iss2[7] = if fault.assuredonly then '1' else '0'; isstype.iss2[10] = if fault.s1tagnotdata then '1' else '0'; end; else if fault.accessdesc.acctype ==&& fault.statuscode == AccessType_IFETCHFault_Permission then ) then isstype.iss2[5] = if fault.dirtybit then '1' else '0'; isstype.iss[21] = if fault.toplevel then '1' else '0'; isstype.iss2[7] = if fault.assuredonly then '1' else '0'; isstype.iss2[6] = if fault.overlay then '1' else '0'; end; end; if fault.hdbssf then isstype.iss2[11] = '1'; end; if (IsFeatureImplemented(FEAT_PFAR) && IsExternalSyncAbort(fault) && !(EL2Enabled() && (HCR_EL2().VM == '1' || (IsFeatureImplemented(FEAT_HCRMAC) && HCR_EL2().DC == '1')) && target_el ==() && (HCR_EL2().VM == '1' || HCR_EL2().DC == '1') && target_el == EL1)) then isstype.iss[14] = if IsPFARValid(fault) then '1' else '0'; end; if IsExternalAbort(fault) then isstype.iss[9] = fault.extflag; end; isstype.iss[7] = if fault.s2fs1walk then '1' else '0'; isstype.iss[5:0] = EncodeLDFSC(fault.statuscode, fault.level); return isstype; end;

Library pseudocode for aarch64/functions/cflt/AArch64_ConditionalFault

// AArch64_ConditionalFault() // ========================== // Generate a Conditional fault. noreturn func AArch64_ConditionalFault(isflt : boolean, immediate : bits(16)) begin assert !UsingAArch32(); var target_el : bits(2); if PSTATE.EL == EL0 then target_el = if EffectiveTGE() == '1' then EL2 else EL1; else target_el = PSTATE.EL; end; let preferred_exception_return : bits(64) = ThisInstrAddr{}(); let vect_offset : integer{} = 0x0; var except : ExceptionRecord = ExceptionSyndrome(Exception_ConditionalFault); except.syndrome.iss[24] = if isflt then '1' else '0'; except.syndrome.iss[15:0] = immediate; AArch64_TakeException(target_el, except, preferred_exception_return, vect_offset); end;

Library pseudocode for aarch64/functions/cflt/CheckCFLTEnabled

// CheckCFLTEnabled() // ================== // Check for EL0 access to a conditional fault instruction func CheckCFLTEnabled() begin if PSTATE.EL == EL0 && !IsInHost() && !(IsSCTLR2EL1Enabled() && SCTLR2_EL1().EnCF0 == '1') then Undefined(); end; if PSTATE.EL == EL0 && IsInHost() && !(IsSCTLR2EL2Enabled() && SCTLR2_EL2().EnCF0 == '1') then Undefined(); end; end;

Library pseudocode for aarch64/functions/eret/AArch64_ExceptionReturn

// AArch64_ExceptionReturn() // ========================= func AArch64_ExceptionReturn(new_pc_in : bits(64), spsr : bits(64)) begin var new_pc : bits(64) = new_pc_in; if IsFeatureImplemented(FEAT_IESB) then var sync_errors : boolean = SCTLR_ELx().IESB == '1'; if IsFeatureImplemented(FEAT_DoubleFault) then sync_errors = sync_errors || (SCR_EL3().[EA,NMEA] == '11' && PSTATE.EL == EL3); end; if sync_errors then SynchronizeErrors(); // If FEAT_IESBv1p1 is implemented and an implicit error synchronization barrier // on exception return generates an SError exception, the resulting ESR_ELx.IESB is // set to 0. Otherwise, the value is an IMPLEMENTATION DEFINED choice of 0 or 1. let iesb_req : boolean = (!IsFeatureImplemented(FEAT_IESBv1p1) && ImpDefBool( "ESR_ELx.IESB is 1 after Implicit Error Synchronization on exception return")); // If an implicit error synchronization barrier on exception return generates an // SError exception, the resulting ESR_ELx.IESB is an IMPLEMENTATION DEFINED // choice of 0 or 1. let iesb_req : boolean = ImpDefBool( "ESR_ELx.IESB is 1 after Implicit Error Synchronization on exception return"); TakeUnmaskedPhysicalSErrorInterrupts(iesb_req); end; end; var brbe_source_allowed : boolean = FALSE; var brbe_source_address : bits(64) = Zeros{}; if IsFeatureImplemented(FEAT_BRBE) then brbe_source_allowed = BranchRecordAllowed(PSTATE.EL); brbe_source_address = PC64(); end; if !IsFeatureImplemented(FEAT_ExS) || SCTLR_ELx().EOS == '1' then SynchronizeContext(); end; // Attempts to change to an illegal state will invoke the Illegal Execution state mechanism let source_el : bits(2) = PSTATE.EL; let illegal_psr_state : boolean = IllegalExceptionReturn{64}(spsr); SetPSTATEFromPSR{64}(spsr, illegal_psr_state); ClearExclusiveLocal(ProcessorID()); SendEventLocal(); if illegal_psr_state && spsr[4] == '1' then // If the exception return is illegal, PC[63:32,1:0] are UNKNOWN new_pc[63:32] = ARBITRARY : bits(32); new_pc[1:0] = ARBITRARY : bits(2); elsif UsingAArch32() then // Return to AArch32 // ELR_ELx[1:0] or ELR_ELx[0] are treated as being 0, depending on the // target instruction set state if PSTATE.T == '1' then new_pc[0] = '0'; // T32 else new_pc[1:0] = '00'; // A32 end; else // Return to AArch64 // ELR_ELx[63:56] might include a tag new_pc = AArch64_BranchAddr(new_pc, PSTATE.EL); end; if IsFeatureImplemented(FEAT_BRBE) then BRBEExceptionReturn(new_pc, source_el, brbe_source_allowed, brbe_source_address); end; if UsingAArch32() then if IsFeatureImplemented(FEAT_SME) && PSTATE.SM == '1' then ResetSVEState(); end; // 32 most significant bits are ignored. let branch_conditional : boolean = FALSE; BranchTo{32}(new_pc[31:0], BranchType_ERET, branch_conditional); else BranchToAddr{64}(new_pc, BranchType_ERET); end; CheckExceptionCatch(FALSE); // Check for debug event on exception return end;

Library pseudocode for aarch64/functions/iesb/EIESBLibrary pseudocode for aarch64/functions/iesb/InsertIESBBeforeException

// EIESB // ===== // Implementation options for the ID_AA64MMFR4_EL1.EIESB exception-entry behavior. // InsertIESBBeforeException() // =========================== // Returns an implementation defined choice whether to insert an implicit error synchronization // barrier before exception. // If SCTLR_ELx.IESB is 1 when an exception is generated to ELx, any pending Unrecoverable // SError interrupt must be taken before executing any instructions in the exception handler. // However, this can be before the branch to the exception handler is made. typefunc EIESB of enumeration {InsertIESBBeforeException(el : bits(2)) => boolean begin return (IsFeatureImplemented(FEAT_IESB) && ImpDefBool( "Has Implicit Error Synchronization Barrier before Exception")); end; EIESB_None, // 0b0000 EIESB_Before_EL3_Conditional, // 0b0001 EIESB_Before_All_Conditional, // 0b0010 EIESB_Before_All_NonSError, // 0b0011 EIESB_After_EL3_Conditional // 0b1111 };

Library pseudocode for aarch64/functions/iesb/GetEIESB

// GetEIESB() // ========== // Returns the EIESB implementation level. impdef func GetEIESB() => EIESB begin return EIESB_Before_All_NonSError; end;

Library pseudocode for aarch64/functions/iesb/InsertIESBBeforeException

// InsertIESBBeforeException() // =========================== // Returns whether an implicit Error synchronization event is inserted before // taking an exception, according to the EIESB implementation behavior. // // If the Effective value of SCTLR_ELx.IESB is 1 when an exception is generated // to ELx, any pending Unrecoverable SError interrupt must be taken before // executing any instructions in the exception handler. Depending on the EIESB // implementation behavior, this can be before the branch to the exception // handler is made. func InsertIESBBeforeException(exceptype : Exception, target_el : bits(2)) => boolean begin // Exclude SError exceptions. if exceptype == Exception_SError then return FALSE; end; case GetEIESB() of when {EIESB_After_EL3_Conditional, EIESB_None} => // Might insert after taking an exception to EL3, unless the exception is also an SError // exception. // Or behavior is not described. return ImpDefBool("Has Implicit Error Synchronization Barrier before Exception"); when EIESB_Before_EL3_Conditional => // Insert before taking an exception to EL3, // unless the exception is also an SError exception. if target_el == EL3 && EffectiveEA() == '1' && EffectiveNMEA(EL3) == '1' then return TRUE; end; when EIESB_Before_All_Conditional => // As EIESB_Before_EL3_Conditional. Also insert before taking exceptions to EL1/EL2 // when the architectural conditions apply. if target_el == EL3 && EffectiveEA() == '1' && EffectiveNMEA(EL3) == '1' then return TRUE; elsif target_el IN {EL1, EL2} then if EffectiveNMEA(target_el) == '1' then return TRUE; end; end; when EIESB_Before_All_NonSError => // Insert before taking all exceptions other than SError exceptions, // regardless of the architectural conditions. return TRUE; end; return ImpDefBool("Has Implicit Error Synchronization Barrier before Exception"); end;

Library pseudocode for aarch64/functions/memory/AArch64_MemSingleRead

// AArch64_MemSingleRead() // ======================= // Perform an atomic, little-endian read of 'size' bits. func AArch64_MemSingleRead{size : integer{8, 16, 32, 64, 128, 256}}(address : bits(64), accdesc_in : AccessDescriptor, aligned : boolean ) => (bits(size), AddressDescriptor, PhysMemRetStatus) begin var value : bits(size) = ARBITRARY : bits(size); var memstatus : PhysMemRetStatus = ARBITRARY : PhysMemRetStatus; let bytes : integer{} = size DIV 8; memstatus.statuscode = Fault_None; var accdesc : AccessDescriptor = accdesc_in; if IsFeatureImplemented(FEAT_LSE2) then assert ((IsFeatureImplemented(FEAT_LS64WB) && bytes == 32 && accdesc.acctype == AccessType_ASIMD) || (IsFeatureImplemented(FEAT_SVE_LRCPC) && bytes == 32) ||) || AllInSCAGranule(address, bytes)); else assert IsAlignedSize(address, bytes); end; // If the instruction encoding permits tag checking, confer with system register configuration // which may override this. if accdesc.tagchecked then accdesc.tagchecked = AArch64_AccessIsTagChecked(address, accdesc); end; var memaddrdesc : AddressDescriptor; memaddrdesc = AArch64_TranslateAddress(address, accdesc, aligned, bytes); // Check for aborts or debug exceptions if IsFault(memaddrdesc) then return (value, memaddrdesc, memstatus); end; // Memory array access if accdesc.tagchecked then let ltag : bits(4) = AArch64_LogicalAddressTag(address); let readcheck : boolean = TRUE; let fault : FaultRecord = AArch64_CheckTag(memaddrdesc, accdesc, readcheck, bytes, ltag); if fault.statuscode != Fault_None then memaddrdesc.fault = fault; return (value, memaddrdesc, memstatus); end; end; if accdesc.acctype != AccessType_IFETCH && SPESampleInFlight then let is_load : boolean = TRUE; SPESampleLoadStore(is_load, accdesc, memaddrdesc); end; var atomic : boolean; if IsWBShareable(memaddrdesc.memattrs) then atomic = TRUE; elsif accdesc.exclusive then atomic = TRUE; elsif (accdesc.acctype == AccessType_SVE && accdesc.predicated && bytes == 8 && IsAlignedSize(address, 8)) then // An SVE predicated load of a 128-bit element that is 64-bit aligned // is treated as a pair of 64-bit single-copy atomic accesses. // This is one of the 64-bit single-copy atomic access. atomic = TRUE; elsif aligned then atomic = !accdesc.ispair; else // Misaligned accesses within a single-copy atomic granule but // not Normal Cacheable Writeback are Atomic atomic = ImpDefBool("FEAT_LSE2: access is atomic"); end; if atomic then (memstatus, value) = PhysMemRead{size}(memaddrdesc, accdesc); elsif accdesc.acctype == AccessType_ASIMD && bytes == 32 && accdesc.ispair then // A 32 byte LDP (SIMD&FP) that does not target Normal Inner Write-Back, Outer // Write-Back cacheable, Shareable memory is treated as four 8 byte atomic accesses. // As this access was not split in Mem(), it must be aligned to 32 bytes. assert IsAlignedSize(address, 32); accdesc.ispair = FALSE; for i = 0 to 3 do if !IsFault(memstatus) then // Do not continue past a fault (memstatus, value[i*64+:64]) = PhysMemRead{64}(memaddrdesc, accdesc); end; if !IsFault(memstatus) then memaddrdesc.paddress.address = memaddrdesc.paddress.address + 8; memaddrdesc.vaddress = memaddrdesc.vaddress + 8; end; end; elsif aligned && accdesc.ispair then let half : integer{} = (size DIV 2) as integer{32, 64, 128}; (memstatus, value[0*:half]) = PhysMemRead{half}(memaddrdesc, accdesc); if !IsFault(memstatus) then memaddrdesc.paddress.address = memaddrdesc.paddress.address + (half DIV 8); memaddrdesc.vaddress = memaddrdesc.vaddress + (half DIV 8); (memstatus, value[1*:half]) = PhysMemRead{half}(memaddrdesc, accdesc); end; else for i = 0 to bytes-1 do if !IsFault(memstatus) then // Do not continue past a fault (memstatus, value[i*:8]) = PhysMemRead{8}(memaddrdesc, accdesc); end; if !IsFault(memstatus) then memaddrdesc.paddress.address = memaddrdesc.paddress.address + 1; memaddrdesc.vaddress = memaddrdesc.vaddress + 1; end; end; end; if IsFault(memstatus) then return (value, memaddrdesc, memstatus); end; if ((accdesc.acctype != AccessType_IFETCH && ImpDefBool( "GPF, GPC, Data SyncExternal Aborts, TagChecks prioritized over Watchpoints")) || (accdesc.acctype == AccessType_IFETCH && ImpDefBool("Instruction SyncExternal Aborts prioritized over Breakpoints"))) then memaddrdesc.fault = AArch64_CheckDebug(address, accdesc, bytes); end; return (value, memaddrdesc, memstatus); end;

Library pseudocode for aarch64/functions/memory/AArch64_MemSingleWrite

// AArch64_MemSingleWrite() // ======================== // Perform an atomic, little-endian write of 'size' bits. func AArch64_MemSingleWrite{size : integer{8, 16, 32, 64, 128, 256}}(address : bits(64), accdesc_in : AccessDescriptor, aligned : boolean, value : bits(size) ) => (AddressDescriptor, PhysMemRetStatus) begin var accdesc : AccessDescriptor = accdesc_in; let bytes : integer{} = size DIV 8; if IsFeatureImplemented(FEAT_LSE2) then assert ((IsFeatureImplemented(FEAT_LS64WB) && bytes == 32 && accdesc.acctype == AccessType_ASIMD) || (IsFeatureImplemented(FEAT_SVE_LRCPC) && bytes == 32) ||) || AllInSCAGranule(address, bytes)); else assert IsAlignedSize(address, bytes); end; // If the instruction encoding permits tag checking, confer with system register configuration // which may override this. if accdesc.tagchecked then accdesc.tagchecked = AArch64_AccessIsTagChecked(address, accdesc); end; var memaddrdesc : AddressDescriptor; var memstatus : PhysMemRetStatus = ARBITRARY : PhysMemRetStatus; memaddrdesc = AArch64_TranslateAddress(address, accdesc, aligned, bytes); // Check for aborts or debug exceptions if IsFault(memaddrdesc) then return (memaddrdesc, memstatus); end; // Effect on exclusives if memaddrdesc.memattrs.shareability != Shareability_NSH then ClearExclusiveByAddress(memaddrdesc.paddress, ProcessorID(), bytes); end; if accdesc.tagchecked then let ltag : bits(4) = AArch64_LogicalAddressTag(address); let readcheck : boolean = FALSE; let fault : FaultRecord = AArch64_CheckTag(memaddrdesc, accdesc, readcheck, bytes, ltag); if fault.statuscode != Fault_None then memaddrdesc.fault = fault; return (memaddrdesc, memstatus); end; end; if SPESampleInFlight then let is_load : boolean = FALSE; SPESampleLoadStore(is_load, accdesc, memaddrdesc); end; var atomic : boolean; if IsWBShareable(memaddrdesc.memattrs) then atomic = TRUE; elsif accdesc.exclusive then atomic = TRUE; elsif (accdesc.acctype == AccessType_SVE && accdesc.predicated && bytes == 8 && IsAlignedSize(address, 8)) then // An SVE predicated load of a 128-bit element that is 64-bit aligned // is treated as a pair of 64-bit single-copy atomic accesses. // This is one of the 64-bit single-copy atomic access. atomic = TRUE; elsif aligned then atomic = !accdesc.ispair; else // Misaligned accesses within a single-copy atomic granule but // not Normal Cacheable Writeback are Atomic atomic = ImpDefBool("FEAT_LSE2: access is atomic"); end; if atomic then memstatus = PhysMemWrite{size}(memaddrdesc, accdesc, value); if IsFault(memstatus) then return (memaddrdesc, memstatus); end; elsif accdesc.acctype == AccessType_ASIMD && bytes == 32 && accdesc.ispair then // A 32 byte STP (SIMD&FP) that does not target Normal Inner Write-Back, Outer // Write-Back cacheable, Shareable memory is treated as four 8 byte atomic accesses. // As this access was not split in Mem(), it must be aligned to 32 bytes. assert IsAlignedSize(address, 32); accdesc.ispair = FALSE; for i = 0 to 3 do memstatus = PhysMemWrite{64}(memaddrdesc, accdesc, value[64*i+:64]); if IsFault(memstatus) then return (memaddrdesc, memstatus); end; memaddrdesc.paddress.address = memaddrdesc.paddress.address + 8; memaddrdesc.vaddress = memaddrdesc.vaddress + 8; end; elsif aligned && accdesc.ispair then let half : integer{} = (size DIV 2) as integer{32, 64}; memstatus = PhysMemWrite{half}(memaddrdesc, accdesc, value[0*:half]); if IsFault(memstatus) then return (memaddrdesc, memstatus); end; memaddrdesc.paddress.address = memaddrdesc.paddress.address + (half DIV 8); memaddrdesc.vaddress = memaddrdesc.vaddress + (half DIV 8); memstatus = PhysMemWrite{half}(memaddrdesc, accdesc, value[1*:half]); if IsFault(memstatus) then return (memaddrdesc, memstatus); end; else for i = 0 to bytes-1 do memstatus = PhysMemWrite{8}(memaddrdesc, accdesc, value[i*:8]); if IsFault(memstatus) then return (memaddrdesc, memstatus); end; memaddrdesc.paddress.address = memaddrdesc.paddress.address + 1; memaddrdesc.vaddress = memaddrdesc.vaddress + 1; end; end; if (accdesc.acctype != AccessType_IFETCH && ImpDefBool( "GPF, GPC, Data SyncExternal Aborts, TagChecks prioritized over Watchpoints")) then memaddrdesc.fault = AArch64_CheckDebug(address, accdesc, bytes); end; return (memaddrdesc, memstatus); end;

Library pseudocode for aarch64/functions/memory/AArch64_UnalignedAccessFaults

// AArch64_UnalignedAccessFaults() // =============================== // Determine whether the unaligned access generates an Alignment fault func AArch64_UnalignedAccessFaults(accdesc : AccessDescriptor, address : bits(64), size : integer) => boolean begin if AlignmentEnforced() then return TRUE; elsif accdesc.acctype == AccessType_GCS then return TRUE; elsif accdesc.rcw then return TRUE; elsif accdesc.ls64 then return TRUE; elsif (accdesc.exclusive || accdesc.atomicop) then return (!IsFeatureImplemented(FEAT_LSE2) || !AllInSCAGranule(address, size)); elsif (accdesc.acqsc || accdesc.acqpc || accdesc.relsc) then // If nAA is 0, the address accessed by each register in the pair // must lie within a single 16-byte aligned block if accdesc.ispair then return (SCTLR_ELx().nAA == '0' && (!AllInAlignedQuantity{64}(address, size DIV 2, 16) || !AllInAlignedQuantity{64}(address + size DIV 2, size DIV 2, 16))); // Octaword load/store are 32 bytes aligned elsif IsFeatureImplemented(FEAT_SVE_LRCPC) && (size == 32) then else return (SCTLR_ELx().nAA == '0' && !AllInAlignedQuantity{64}(address, size, 32)); else return ({64}(address, size, 16)); end; else return FALSE; end; end;SCTLR_ELx().nAA == '0' && !AllInAlignedQuantity{64}(address, size, 16)); end; else return FALSE; end; end;

Library pseudocode for aarch64/functions/memory/AllInSCAGranule

// AllInSCAGranule() // ================= // When FEAT_LSE2 is implemented, for some memory accesses if all bytes of the access lie within // the single-copy atomicity granule corresponding to CTR_EL0.LSE2Size and satisfy additional // requirements, then the access is guaranteed to be single-copy atomic. // When FEAT_LSE2 is implemented, for some memory accesses if all bytes // of the accesses are within 16-byte quantity aligned to 16-bytes and // satisfy additional requirements - then the access is guaranteed to // be single copy atomic. // However, when the accesses do not all lie within such a boundary, it // is CONSTRAINED UNPREDICTABLE if the access is single copy atomic. // In the pseudocode, this CONSTRAINED UNPREDICTABLE aspect is modeled via // an IMPLEMENTATION DEFINED aligned quantity that is at least 16 bytes and // at most 4096 bytes. // This is a limitation of the pseudocode. readonly func AllInSCAGranule(address : bits(64), size : integer) => boolean begin if NUM_SCA_GRANULE_BYTES == 0 then // The single-copy atomicity granule size is unbounded. return TRUE; end; let quantity : integer = ImpDefInt("Aligned quantity for atomic access"); // access is assumed to be within 4096 byte aligned quantity to // avoid multiple translations for a single copy atomic access. assert (quantity >= 16) && (quantity <= 4096); return AllInAlignedQuantity{64}(address, size, NUM_SCA_GRANULE_BYTES); {64}(address, size, quantity); end;

Library pseudocode for aarch64/functions/memory/MemAtomic

// MemAtomic() // =========== // Performs load and store memory operations for a given virtual address. func MemAtomic{size : integer{8, 16, 32, 64, 128}}(address : bits(64), cmpoperand : bits(size), operand : bits(size), accdesc_in : AccessDescriptor ) => bits(size) begin assert accdesc_in.atomicop; let bytes : integer{} = (size DIV 8) as integer{1, 2, 4, 8, 16}; var newvalue : bits(size); var oldvalue : bits(size); var accdesc : AccessDescriptor = accdesc_in; let aligned : boolean = IsAlignedSize(address, bytes); // If the instruction encoding permits tag checking, confer with system register configuration // which may override this. if accdesc.tagchecked then accdesc.tagchecked = AArch64_AccessIsTagChecked(address, accdesc); end; if !aligned && AArch64_UnalignedAccessFaults(accdesc, address, bytes) then let fault : FaultRecord = AlignmentFault(accdesc, address); AArch64_Abort(fault); end; // MMU or MPU lookup let memaddrdesc : AddressDescriptor = AArch64_TranslateAddress(address, accdesc, aligned, bytes); // Check for aborts or debug exceptions if IsFault(memaddrdesc) then AArch64_Abort(memaddrdesc.fault); end; if (!IsWBShareable(memaddrdesc.memattrs) && ConstrainUnpredictableBool(Unpredictable_Atomic_NOP)) then return ARBITRARY : bits(size); end; // Effect on exclusives if memaddrdesc.memattrs.shareability != Shareability_NSH then ClearExclusiveByAddress(memaddrdesc.paddress, ProcessorID(), bytes); end; // For Store-only Tag checking, the tag check is performed on the store. if (accdesc.tagchecked && (!IsFeatureImplemented(FEAT_MTE_STORE_ONLY) || !StoreOnlyTagCheckingEnabled(accdesc.el))) then let ltag : bits(4) = AArch64_LogicalAddressTag(address); let readcheck : boolean = TRUE; let fault : FaultRecord = AArch64_CheckTag(memaddrdesc, accdesc, readcheck, bytes, ltag); if fault.statuscode != Fault_None then AArch64_Abort(fault); end; end; // All observers in the shareability domain observe the following load and store atomically. var memstatus : PhysMemRetStatus; (memstatus, oldvalue) = PhysMemRead{size}(memaddrdesc, accdesc); // Depending on the memory type of the physical address, the access might generate // either a synchronous External abort or an SError exception // among other CONSTRAINED UNPREDICTABLE choices. if IsFault(memstatus) then HandleExternalReadAbort(memstatus, memaddrdesc, bytes, accdesc); end; if BigEndian(accdesc.acctype) then oldvalue = BigEndianReverse{size}(oldvalue); end; var cmpfail : boolean = FALSE; var retvalue : bits(size) = oldvalue; if accdesc.acctype == AccessType_FP then newvalue = MemAtomicFP{size}(accdesc.modop, oldvalue, operand); else (newvalue, cmpfail, retvalue) = MemAtomicInt{size}(accdesc.modop, oldvalue, operand, cmpoperand); end; let requirewrite : boolean = (!cmpfail || ConstrainUnpredictableBool(Unpredictable_WRITEFAILEDCAS)); if IsFeatureImplemented(FEAT_MTE_STORE_ONLY) && StoreOnlyTagCheckingEnabled(accdesc.el) then // If the compare on a Tag checked CAS fails and no write is performed, then it is // CONSTRAINED UNPREDICTABLE whether the Tag check is performed. // If the compare on a CAS fails, then it is CONSTRAINED UNPREDICTABLE whether the // Tag check is performed. if accdesc.tagchecked && !requirewrite then accdesc.tagchecked = ConstrainUnpredictableBool(Unpredictable_STRONLYTAGCHECKEDCAS); end; if accdesc.tagchecked then let ltag : bits(4) = AArch64_LogicalAddressTag(address); let readcheck : boolean = FALSE; var fault : FaultRecord = AArch64_CheckTag(memaddrdesc, accdesc, readcheck, bytes, ltag); if fault.statuscode != Fault_None then // For a synchronous Tag Check Fault due to FEAT_MTE_STORE_ONLY, set WnR. fault.write = TRUE; AArch64_Abort(fault); end; end; end; if requirewrite then if BigEndian(accdesc.acctype) then newvalue = BigEndianReverse{size}(newvalue); end; memstatus = PhysMemWrite{size}(memaddrdesc, accdesc, newvalue); if IsFault(memstatus) then HandleExternalWriteAbort(memstatus, memaddrdesc, bytes, accdesc); end; end; if SPESampleInFlight then let is_load : boolean = FALSE; SPESampleLoadStore(is_load, accdesc, memaddrdesc); end; // Load operations return the old (pre-operation) value. // Compare and Swap operations return the old (pre-operation) value. For a successful CAS, // this might be the value from the compare operand or from memory. return retvalue; end;

Library pseudocode for aarch64/functions/memory/MemAtomicRCW

// MemAtomicRCW() // ============== // Perform a single-copy-atomic access with Read-Check-Write operation func MemAtomicRCW{size : integer{64, 128}}(address : bits(64), cmpoperand : bits(size), operand : bits(size), accdesc_in : AccessDescriptor ) => (bits(4), bits(size)) begin assert accdesc_in.atomicop; assert accdesc_in.rcw; let bytes : integer{} = (size DIV 8) as integer{8, 16}; var nzcv : bits(4); var oldvalue : bits(size); var newvalue : bits(size); var accdesc : AccessDescriptor = accdesc_in; let aligned : boolean = IsAlignedSize(address, bytes); // If the instruction encoding permits tag checking, confer with system register configuration // which may override this. if accdesc.tagchecked then accdesc.tagchecked = AArch64_AccessIsTagChecked(address, accdesc); end; if !aligned && AArch64_UnalignedAccessFaults(accdesc, address, bytes) then let fault : FaultRecord = AlignmentFault(accdesc, address); AArch64_Abort(fault); end; // MMU or MPU lookup let memaddrdesc : AddressDescriptor = AArch64_TranslateAddress(address, accdesc, aligned, bytes); // Check for aborts or debug exceptions if IsFault(memaddrdesc) then AArch64_Abort(memaddrdesc.fault); end; if (!IsWBShareable(memaddrdesc.memattrs) && ConstrainUnpredictableBool(Unpredictable_Atomic_NOP)) then return (ARBITRARY : bits(4), ARBITRARY : bits(size)); end; // Effect on exclusives if memaddrdesc.memattrs.shareability != Shareability_NSH then ClearExclusiveByAddress(memaddrdesc.paddress, ProcessorID(), bytes); end; // For Store-only Tag checking, the tag check is performed on the store. if (accdesc.tagchecked && (!IsFeatureImplemented(FEAT_MTE_STORE_ONLY) || !StoreOnlyTagCheckingEnabled(accdesc.el))) then let ltag : bits(4) = AArch64_LogicalAddressTag(address); let readcheck : boolean = TRUE; let fault : FaultRecord = AArch64_CheckTag(memaddrdesc, accdesc, readcheck, bytes, ltag); if fault.statuscode != Fault_None then AArch64_Abort(fault); end; end; // All observers in the shareability domain observe the following load and store atomically. var memstatus : PhysMemRetStatus; (memstatus, oldvalue) = PhysMemRead{size}(memaddrdesc, accdesc); // Depending on the memory type of the physical address, the access might generate // either a synchronous External abort or an SError exception // among other CONSTRAINED UNPREDICTABLE choices. if IsFault(memstatus) then HandleExternalReadAbort(memstatus, memaddrdesc, bytes, accdesc); end; if BigEndian(accdesc.acctype) then oldvalue = BigEndianReverse{size}(oldvalue); end; var cmpfail : boolean = FALSE; var retvalue : bits(size) = oldvalue; case accdesc.modop of when MemAtomicOp_BIC => newvalue = oldvalue AND NOT(operand); when MemAtomicOp_ORR => newvalue = oldvalue OR operand; when MemAtomicOp_SWP => newvalue = operand; when MemAtomicOp_CAS => (newvalue, cmpfail, retvalue) = CASCompare{size}(oldvalue, cmpoperand, operand); end; if cmpfail then nzcv = '1010'; // N = 1 indicates compare failure else nzcv = RCWCheck{size}(retvalue, newvalue, accdesc.rcws); end; // If RCWCheck() passes, it returns nzcv == '0010' let requirewrite : boolean = (nzcv == '0010' || ConstrainUnpredictableBool(Unpredictable_WRITEFAILEDRCWCAS)); if IsFeatureImplemented(FEAT_MTE_STORE_ONLY) && StoreOnlyTagCheckingEnabled(accdesc.el) then // If the RCW(S) checks, or if the compare on a Tag checked RCW(S)CAS fails and no write is // performed, then it is CONSTRAINED UNPREDICTABLE whether the Tag check is performed. // If the RCW(S) check fails, or if the compare on a RCW(S)CAS fails, // then it is CONSTRAINED UNPREDICTABLE whether the Tag check is performed. if accdesc.tagchecked && !requirewrite then accdesc.tagchecked = ConstrainUnpredictableBool(Unpredictable_STRONLYTAGCHECKEDRCWSCAS); end; if accdesc.tagchecked then let ltag : bits(4) = AArch64_LogicalAddressTag(address); let readcheck : boolean = FALSE; var fault : FaultRecord = AArch64_CheckTag(memaddrdesc, accdesc, readcheck, bytes, ltag); if fault.statuscode != Fault_None then // For a synchronous Tag Check Fault due to FEAT_MTE_STORE_ONLY, set WnR. fault.write = TRUE; AArch64_Abort(fault); end; end; end; if requirewrite then if BigEndian(accdesc.acctype) then newvalue = BigEndianReverse{size}(newvalue); end; memstatus = PhysMemWrite{size}(memaddrdesc, accdesc, newvalue); if IsFault(memstatus) then HandleExternalWriteAbort(memstatus, memaddrdesc, bytes, accdesc); end; end; if SPESampleInFlight then let is_load : boolean = TRUE; SPESampleLoadStore(is_load, accdesc, memaddrdesc); end; // Load operations return the old (pre-operation) value. // Compare and Swap operations return the old (pre-operation) value. For a successful CAS, // this might be the value from the compare operand or from memory. return (nzcv, retvalue); end;

Library pseudocode for aarch64/functions/mops/MaxBlockSizeCopiedBytes

// MaxBlockSizeCopiedBytes() // ========================= // Returns the maximum number of bytes that can used in a single block of the copy. func MaxBlockSizeCopiedBytes() => integer begin return ImpDefInt("Maximum bytes used in a single block of a copy"); end;

Library pseudocode for aarch64/functions/ras/AArch64_PhysicalSErrorSyndrome

// AArch64_PhysicalSErrorSyndrome() // ================================ // Generate SError syndrome. func AArch64_PhysicalSErrorSyndrome(is_esb : boolean, implicit_esb : boolean) => bits(25) begin var syndrome : bits(25) = Zeros{}; var target_el : bits(2); (-, target_el) = PhysicalSErrorTarget(); if ReportErrorAsUncategorized() then syndrome = Zeros{25}; elsif ReportErrorAsIMPDEF() then syndrome[24] = '1'; // IDS syndrome[23:0] = ImpDefBits{24}("IMPDEF ErrorState"); else let fault : FaultRecord = GetPendingPhysicalSError(); let errorstate : ErrorState = PEErrorState(fault); syndrome[24] = '0'; // IDS if (!is_esb && IsFeatureImplemented(FEAT_PFAR) && !(EL2Enabled() && (HCR_EL2().VM == '1' || (IsFeatureImplemented(FEAT_HCRMAC) && HCR_EL2().DC == '1')) && target_el == (HCR_EL2().VM == '1' || HCR_EL2().DC == '1') && target_el == EL1)) then syndrome[14] = if IsPFARValid(fault) then '1' else '0'; end; syndrome[13] = if implicit_esb then '1' else '0'; // IESB syndrome[12:10] = AArch64_EncodeAsyncErrorSyndrome(errorstate); // AET syndrome[9] = fault.extflag; // EA syndrome[5:0] = '010001'; // DFSC end; return syndrome; end;

Library pseudocode for aarch64/functions/ras/IsDeviceMemoryReadErrorSynchronous

// IsDeviceMemoryReadErrorSynchronous() // ==================================== // Returns TRUE when the Device memory read is synchronous in the current Exception level. func IsDeviceMemoryReadErrorSynchronous(accdesc : AccessDescriptor, desc : AddressDescriptor) => boolean begin if !IsFeatureImplemented(FEAT_ADERR) || ! if IsFeatureImplemented(FEAT_ADERR) &&CheckEnADERRApplies(accdesc) then return ImpDefBool("Device read error sync when EnADERR not implemented or does not apply"); end; case case S1TranslationRegime(accdesc.el) of when EL3 => if ((!IsFeatureImplemented(FEAT_ANERR) || if HaveEL(EL3) && SCR_EL3().SCTLR2En == '0' then return TRUE; end; if ((!IsFeatureImplemented(FEAT_ANERR) || GetADERRErrorMode() != ErrSignalMode_TiedToPeer || SCTLR2_EL3().EnANERR == '0') && SCTLR2_EL3().EnADERR == '0') then return TRUE; end; when EL2 => if ! if (!IsSCTLR2EL2Enabled() then if ImpDefBool("SCTLR2_ELx.EnADERR resets to 0 at highest ELx") then return TRUE; end; elsif ((!IsFeatureImplemented(FEAT_ANERR) ||() || ((!IsFeatureImplemented(FEAT_ANERR) || GetADERRErrorMode() != ErrSignalMode_TiedToPeer || SCTLR2_EL2().EnANERR == '0') && SCTLR2_EL2().EnADERR == '0') then return TRUE; end; SCTLR2_EL2().EnANERR == '0') && SCTLR2_EL2().EnADERR == '0')) then return TRUE; end; when when EL1 => if IsHCRXEL2Enabled => if() && EffectiveHCRX_EL2_EnSDERR() == '1' then return TRUE; end; if ! return TRUE; end; if (!IsSCTLR2EL1Enabled() then if ImpDefBool("SCTLR2_ELx.EnADERR resets to 0 at highest ELx") then return TRUE; end; elsif ((!IsFeatureImplemented(FEAT_ANERR) ||() || ((!IsFeatureImplemented(FEAT_ANERR) || GetADERRErrorMode() != ErrSignalMode_TiedToPeer || SCTLR2_EL1().EnANERR == '0') && SCTLR2_EL1().EnADERR == '0') then return TRUE; end; otherwise => unreachable; SCTLR2_EL1().EnANERR == '0') && SCTLR2_EL1().EnADERR == '0')) then return TRUE; end; otherwise => unreachable; end; end; return ImpDefBool("Device read error sync when the Effective value of EnADERR is 1"); return ImpDefBool("Device read error sync when EnADERR not implemented or enabled"); end;

Library pseudocode for aarch64/functions/ras/IsNormalMemoryReadErrorSynchronous

// IsNormalMemoryReadErrorSynchronous() // ==================================== // Returns TRUE when error signaled on a load from Normal memory is taken synchronously. func IsNormalMemoryReadErrorSynchronous(accdesc : AccessDescriptor, desc : AddressDescriptor) => boolean begin if !IsFeatureImplemented(FEAT_ANERR) || ! if IsFeatureImplemented(FEAT_ANERR) &&CheckEnANERRApplies(accdesc, desc) then return ImpDefBool("Normal read error sync when EnANERR not implemented or does not apply"); end; case case S1TranslationRegime(accdesc.el) of when EL3 => if ((!IsFeatureImplemented(FEAT_ADERR) || GetANERRErrorMode() != ErrSignalMode_TiedToPeer || SCTLR2_EL3().EnADERR == '0') && SCTLR2_EL3().EnANERR == '0') then return TRUE; end; when EL2 => if ! if (!IsSCTLR2EL2Enabled() then if ImpDefBool("SCTLR2_ELx.EnANERR resets to 0 at highest ELx") then return TRUE; end; elsif ((!IsFeatureImplemented(FEAT_ADERR) ||() || ((!IsFeatureImplemented(FEAT_ADERR) || GetANERRErrorMode() != ErrSignalMode_TiedToPeer || SCTLR2_EL2().EnADERR == '0') && SCTLR2_EL2().EnANERR == '0') then return TRUE; end; SCTLR2_EL2().EnADERR == '0') && SCTLR2_EL2().EnANERR == '0')) then return TRUE; end; when when EL1 => if EffectiveHCRX_EL2_EnSNERR() == '1' then return TRUE; end; if ! return TRUE; end; if (!IsSCTLR2EL1Enabled() then if ImpDefBool("SCTLR2_ELx.EnANERR resets to 0 at highest ELx") then return TRUE; end; elsif ((!IsFeatureImplemented(FEAT_ADERR) ||() || ((!IsFeatureImplemented(FEAT_ADERR) || GetANERRErrorMode() != ErrSignalMode_TiedToPeer || SCTLR2_EL1().EnADERR == '0') && SCTLR2_EL1().EnANERR == '0') then return TRUE; end; otherwise => unreachable; SCTLR2_EL1().EnADERR == '0') && SCTLR2_EL1().EnANERR == '0')) then return TRUE; end; otherwise => unreachable; end; end; return ImpDefBool("Normal read error sync when the Effective value of EnANERR is 1"); return ImpDefBool("Normal read error sync when EnANERR not implemented or enabled"); end;

Library pseudocode for aarch64/functions/sve/CheckSMEAccess

// CheckSMEAccess() // ================ // Check that access to SME System registers is enabled. func CheckSMEAccess() begin var disabled : boolean; if HaveEL(EL3) && CPTR_EL3().ESM == '0' && EL3SDDUndefPriority() then Undefined(); end; // Check if access disabled in CPACR_EL1 if PSTATE.EL IN {EL0, EL1} && !IsInHost() then // Check SME at EL0/EL1 case CPACR_EL1().SMEN of when 'x0' => disabled = TRUE; when '01' => disabled = EffectivelyAtEL0NotInHostPSTATE(); when '11' => disabled = FALSE; end; if disabled then.EL == EL0; when '11' => disabled = FALSE; end; if disabled then SMEAccessTrap(SMEExceptionType_AccessTrap, EL1); end; end; if PSTATE.EL IN {EL0, EL1, EL2} && EL2Enabled() then if ELIsInHost(EL2) then // Check SME at EL2 case CPTR_EL2().SMEN of when 'x0' => disabled = TRUE; when '01' => disabled = .EL == EL0EffectivelyAtEL0InHostPSTATE(); && HCR_EL2().TGE == '1'; when '11' => disabled = FALSE; end; if disabled then SMEAccessTrap(SMEExceptionType_AccessTrap, EL2); end; else if CPTR_EL2().TSM == '1' then SMEAccessTrap(SMEExceptionType_AccessTrap, EL2); end; end; end; // Check if access disabled in CPTR_EL3 if HaveEL(EL3) then if CPTR_EL3().ESM == '0' then if EL3SDDUndef() then Undefined(); end; SMEAccessTrap(SMEExceptionType_AccessTrap, EL3); end; end; end;

Library pseudocode for aarch64/functions/sve/FPMinNormal

// FPMinNormal() // ============= func FPMinNormal{N}(sign : bit) => bits(N) begin assert N IN {16,32,64}; let E : integer{} = (if N == 16 then 5 else (if N == 32 then 8 else 11)); let F : integer{} = N - (E + 1); let exp : bits(E) = Zeros{E-1}::'1'; let frac : bits(F) = Zeros{}; return sign :: exp :: frac; end;

Library pseudocode for aarch64/functions/sve/IntReducePredicated

// IntReducePredicated() // ===================== func IntReducePredicated{esize, N, M}(op : ReduceOp, input : bits(N), mask : bits(M), identity : bits(esize)) => bits(esize) begin assert(N == M * 8); assert IsPow2(N); var operand : bits(N); let elements : integer = N DIV esize; for e = 0 to elements-1 do if e * esize < N && ActivePredicateElement{M}(mask, e, esize) then operand[e*:esize] = input[e*:esize]; else operand[e*:esize] = identity; end; end; return IntReduce{esize, N}(op, operand); end;

Library pseudocode for aarch64/functions/sve/MaxImplementedVL

// MaxImplementedVL() // ================== readonly func MaxImplementedVL() => integer begin let max_vl : integer = ImpDefInt("Max implemented VL"); if IsFeatureImplemented(FEAT_SME_FA64) then let max_svl : integer = ImpDefInt("Max implemented SVL"); return Max(max_vl, max_svl); end; return max_vl; return ImpDefInt("Max implemented VL"); end;

Library pseudocode for aarch64/functions/sve/MemNF

// MemNF // ===== func MemNF{size : integer{8, 16, 32, 64, 128}}(address : bits(64), accdesc : AccessDescriptor ) => (bits(size), boolean) begin let bytes : integer{} = size DIV 8; var value : bits(size); var bad : boolean; var aligned : boolean = IsAlignedSize{64}(address, bytes); if !aligned && AArch64_UnalignedAccessFaultsAlignmentEnforced(accdesc, address, bytes) then return (ARBITRARY : bits(size), TRUE); end; let atomic : boolean = (aligned || (IsFeatureImplemented(FEAT_LSE2) && AllInSCAGranule(address, bytes))); () then return (ARBITRARY : bits(size), TRUE); end; let atomic : boolean = aligned || bytes == 1; if !atomic then (value[7:0], bad) = MemSingleNF{8}(address, accdesc, aligned); if bad then return (ARBITRARY : bits(size), TRUE); end; // For subsequent bytes, if they cross to a new translation page which assigns // Device memory type, it is CONSTRAINED UNPREDICTABLE whether an unaligned access // will generate an Alignment Fault. if !aligned then let c : Constraint = ConstrainUnpredictable(Unpredictable_DEVPAGE2); assert c IN {Constraint_FAULT, Constraint_NONE}; if c == Constraint_NONE then aligned = TRUE; end; end; for i = 1 to bytes-1 do (value[i*:8], bad) = MemSingleNF{8}(address+i, accdesc, aligned); if bad then return (ARBITRARY : bits(size), TRUE); end; end; else (value, bad) = MemSingleNF{size}(address, accdesc, aligned); if bad then return (ARBITRARY : bits(size), TRUE); end; end; if BigEndian(accdesc.acctype) then value = BigEndianReverse{size}(value); end; return (value, FALSE); end;

Library pseudocode for aarch64/functions/sve/MemSingleNF

// MemSingleNF // =========== func MemSingleNF{size : integer{8, 16, 32, 64, 128}}(address : bits(64), accdesc_in : AccessDescriptor, aligned : boolean) => (bits(size), boolean) begin assert accdesc_in.acctype == AccessType_SVE; assert accdesc_in.nonfault || (accdesc_in.firstfault && !accdesc_in.first); let bytes : integer{} = size DIV 8; var value : bits(size); var memaddrdesc : AddressDescriptor; var memstatus : PhysMemRetStatus; var accdesc : AccessDescriptor = accdesc_in; var fault : FaultRecord = NoFault(accdesc, address); // Implementation may suppress NF load for any reason if ConstrainUnpredictableBool(Unpredictable_NONFAULT) then return (ARBITRARY : bits(size), TRUE); end; // If the instruction encoding permits tag checking, confer with system register configuration // which may override this. if accdesc.tagchecked then accdesc.tagchecked = AArch64_AccessIsTagChecked(address, accdesc); end; // MMU or MPU memaddrdesc = AArch64_TranslateAddress(address, accdesc, aligned, bytes); // Non-fault and first-fault loads from non-Conventional Device memory must not be performed // externally. For Conventional memory, it is IMPLEMENTATION DEFINED. // Non-fault load from Device memory must not be performed externally if memaddrdesc.memattrs.memtype == MemType_Device then if (! return (ARBITRARY : bits(size), TRUE); end; // Check for aborts or debug exceptions if IsFault(memaddrdesc) then return (ARBITRARY : bits(size), TRUE); end; if accdesc.tagchecked then let ltag : bits(4) =IsConventionalMemory(memaddrdesc) || ImpDefBool("SVE NF/FF load from Device Conventional memory is suppressed")) then return (ARBITRARY : bits(size), TRUE); end; end; // Check for aborts or debug exceptions if IsFault(memaddrdesc) then return (ARBITRARY : bits(size), TRUE); end; if accdesc.tagchecked then let ltag : bits(4) = AArch64_LogicalAddressTag(address); let readcheck : boolean = TRUE; fault = AArch64_CheckTag(memaddrdesc, accdesc, readcheck, bytes, ltag); if fault.statuscode != Fault_None then return (ARBITRARY : bits(size), TRUE); end; end; (memstatus, value) = PhysMemRead{size}(memaddrdesc, accdesc); if IsFault(memstatus) then let iswrite : boolean = FALSE; if IsExternalAbortTakenSynchronously(memstatus, iswrite, memaddrdesc, bytes, accdesc) then return (ARBITRARY : bits(size), TRUE); end; fault.merrorstate = memstatus.merrorstate; fault.extflag = memstatus.extflag; fault.statuscode = memstatus.statuscode; PendSErrorInterrupt(fault); end; return (value, FALSE); end;

Library pseudocode for aarch64/functions/syshintop/SystemHintOp

// SystemHintOp // ============ // System Hint instruction types. type SystemHintOp of enumeration { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_STSHH, SystemHintOp_SHUH, SystemHintOp_STCPH, SystemHintOp_SLBND,SystemHintOp_CSDB }; SystemHintOp_SRLS, SystemHintOp_CSDB };

Library pseudocode for aarch64/functions/sysregisters/GetSPSR_EL1_M4

// GetSPSR_EL1_M4() // ================ // Query the SPSR_EL1.M[4] field. func GetSPSR_EL1_M4() => bit begin return SPSR_EL1().M[4]; end;

Library pseudocode for aarch64/functions/sysregisters/GetSPSR_EL2_M4

// GetSPSR_EL2_M4() // ================ // Query the SPSR_EL2.M[4] field. func GetSPSR_EL2_M4() => bit begin return SPSR_EL2().M[4]; end;

Library pseudocode for aarch64/functions/sysregisters/GetSPSR_EL3_M4

// GetSPSR_EL3_M4() // ================ // Query the SPSR_EL3.M[4] field. func GetSPSR_EL3_M4() => bit begin return SPSR_EL3().M[4]; end;

Library pseudocode for aarch64/functions/system/AArch64_CheckDAIFAccess

// AArch64_CheckDAIFAccess() // ========================= // Check that an AArch64 MSR/MRS access to the DAIF flags is permitted. func AArch64_CheckDAIFAccess(field : PSTATEField) begin if field IN { ifPSTATE.EL == EL0 && field IN {PSTATEField_DAIFSet, PSTATEField_DAIFClr} then if ( ifEffectivelyAtEL0InHostIsInHost() || (() || SCTLR_EL1().UMA == '0' then ifEffectivelyAtEL0NotInHostEL2Enabled() && SCTLR_EL1().UMA == '0')) then() && HCR_EL2().TGE == '1' then (EL2, 0x18); else AArch64_SystemAccessTrap(EL1AArch64_SystemAccessTraptoEL1orEL2AArch64_SystemAccessTrap(0x18); , 0x18); end; end; end; end;

Library pseudocode for aarch64/functions/system/AArch64_ChooseEIRGNonExcludedTag

// AArch64_ChooseEIRGNonExcludedTag() // ================================== // Return a tag derived from SEED and EIRGSTATE, excluding any tags in the // given mask. func AArch64_ChooseEIRGNonExcludedTag(exclude : bits(16)) => bits(4) begin assert GCR_EL1().RRND == '0'; if IsOnes(exclude) then return '0000'; end; var bins : array[[16]] of bits(4); var N : integer = 0; for i = 0 to 15 do if exclude[i] == '0' then bins[[N]] = i[3:0]; N = N + 1; end; end; let seed : bits(16) = RGSR_EL1().RRND0.SEED[15:0]; let seed : bits(16) = RGSR_EL1().SEED[15:0]; var eirgstate : integer = UInt(RGSR_EL1().TAG); eirgstate = eirgstate + 1; if eirgstate >= N then eirgstate = 0; end; let lbin : integer = (eirgstate + (N * UInt(seed)) >> 16) MOD N; RGSR_EL1().TAG = eirgstate[3:0]; let top : bit = seed[5] XOR seed[3] XOR seed[2] XOR seed[0]; RGSR_EL1().RRND0.SEED[15:0] = top::seed[15:1]; RGSR_EL1().SEED[15:0] = top::seed[15:1]; return bins[[lbin]]; end;

Library pseudocode for aarch64/functions/system/AArch64_ChooseNonExcludedTagOrZeroLibrary pseudocode for aarch64/functions/system/AArch64_ChooseNonExludedTagOrZero

// AArch64_ChooseNonExcludedTagOrZero() // ==================================== // AArch64_ChooseNonExludedTagOrZero() // =================================== // Return a tag derived from the start and the offset values, excluding any // tags in the given mask, or zero if Allocation Tag access is not enabled. func AArch64_ChooseNonExcludedTagOrZero(tag : bits(4), offset : bits(4), exclude : bits(16)) => bits(4) begin if IsMTEEnabled(PSTATE.EL) then return AArch64_ChooseNonExcludedTag(tag, offset, exclude); else return '0000'; end; end;

Library pseudocode for aarch64/functions/system/AArch64_NextRandomTagBit

// AArch64_NextRandomTagBit() // ========================== // Generate a random bit suitable for generating a random Allocation Tag. func AArch64_NextRandomTagBit() => bit begin assert GCR_EL1().RRND == '0'; let lfsr : bits(16) = RGSR_EL1().RRND0.SEED[15:0]; let lfsr : bits(16) = RGSR_EL1().SEED[15:0]; let top : bit = lfsr[5] XOR lfsr[3] XOR lfsr[2] XOR lfsr[0]; RGSR_EL1().RRND0.SEED[15:0] = top::lfsr[15:1]; RGSR_EL1().SEED[15:0] = top::lfsr[15:1]; return top; end;

Library pseudocode for aarch64/functions/system/IsGMEnabledAtEL0

// IsGMEnabledAtEL0() // ================== func IsGMEnabledAtEL0() => boolean begin if IsFeatureImplemented(FEAT_MTE_GM0) then if IsInHost() then return IsSCTLR2EL2Enabled() && SCTLR2_EL2().GM0 == '1'; else return IsSCTLR2EL1Enabled() && SCTLR2_EL1().GM0 == '1'; end; else return FALSE; end; end;

Library pseudocode for aarch64/functions/tlbi/AArch64_TLBI_PAALL

// AArch64_TLBI_PAALL() // ==================== // TLB Invalidate ALL GPT Information. // Invalidates cached copies of GPT entries from TLBs in the indicated // Shareability domain. // Shareabilty domain. // The invalidation applies to all TLB entries containing GPT information. func AArch64_TLBI_PAALL(broadcast : Broadcast) begin assert IsFeatureImplemented(FEAT_RME) && PSTATE.EL == EL3; var r : TLBIRecord; // r.security and r.regime do not apply for TLBI by PA operations r.op = TLBIOp_PAALL; r.level = TLBILevel_Any; r.attr = TLBI_AllAttr; TLBI(r); if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r); end; return; end;

Library pseudocode for aarch64/functions/tlbi/AArch64_TLBI_RPA

// AArch64_TLBI_RPA() // ================== // TLB Range Invalidate GPT Information by PA. // Invalidates cached copies of GPT entries from TLBs in the indicated // Shareability domain. // Shareabilty domain. // The invalidation applies to TLB entries containing GPT information relating // to the indicated physical address range. // When the indicated level is // TLBILevel_Any : this applies to TLB entries containing GPT information // from all levels of the GPT walk // TLBILevel_Last : this applies to TLB entries containing GPT information // from the last level of the GPT walk func AArch64_TLBI_RPA(level : TLBILevel, Xt : bits(64), broadcast : Broadcast) begin assert IsFeatureImplemented(FEAT_RME) && PSTATE.EL == EL3; var r : TLBIRecord; var range_bits : AddressSize; var p : AddressSize; // r.security and r.regime do not apply for TLBI by PA operations r.op = TLBIOp_RPA; r.level = level; r.attr = TLBI_AllAttr; // SIZE field case Xt[47:44] of when '0000' => range_bits = 12; // 4KB when '0001' => range_bits = 14; // 16KB when '0010' => range_bits = 16; // 64KB when '0011' => range_bits = 21; // 2MB when '0100' => range_bits = 25; // 32MB when '0101' => range_bits = 29; // 512MB when '0110' => range_bits = 30; // 1GB when '0111' => range_bits = 34; // 16GB when '1000' => range_bits = 36; // 64GB when '1001' => range_bits = 39; // 512GB otherwise => return; // Reserved encoding, no TLB entries are required to be invalidated end; // If SIZE selects a range smaller than PGS, then PGS is used instead case DecodePGS(GPCCR_EL3().PGS) of when PGS_4KB => p = 12; when PGS_16KB => p = 14; when PGS_64KB => p = 16; otherwise => return; // Reserved encoding, no TLB entries are required to be invalidated end; if range_bits < p then range_bits = p; end; var BaseADDR : bits(NUM_PABITS) = Zeros{}; case GPCCR_EL3().PGS of when '00' => BaseADDR[51:12] = Xt[39:0]; // 4KB when '10' => BaseADDR[51:14] = Xt[39:2]; // 16KB when '01' => BaseADDR[51:16] = Xt[39:4]; // 64KB end; if IsFeatureImplemented(FEAT_D128) && AArch64_PAMax() == 56 then BaseADDR[55:52] = Xt[43:40]; // Extension to Address end; // The calculation here automatically aligns BaseADDR to the size of // the region specified in SIZE. However, the architecture does not // require this alignment and if BaseADDR is not aligned to the region // specified by SIZE then no entries are required to be invalidated. let range_pbits : integer{} = range_bits; let start_addr : bits(NUM_PABITS) = BaseADDR AND NOT ZeroExtend{NUM_PABITS}(Ones{range_pbits}); let end_addr : bits(NUM_PABITS) = start_addr + ZeroExtend{NUM_PABITS}(Ones{range_pbits}); // PASpace is not considered in TLBI by PA operations r.address = ZeroExtend{64}(start_addr); r.end_address = ZeroExtend{64}(end_addr); TLBI(r); if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r); end; return; end;

Library pseudocode for aarch64/functions/tlbi/HasLargeAddress

// HasLargeAddress() // ================= // Returns TRUE if the regime is configured for 52 bit addresses, FALSE otherwise. func HasLargeAddress(regime : Regime) => boolean begin if !IsFeatureImplemented(FEAT_LPA2) then return FALSE; end; case regime of when Regime_EL3 => return TCR_EL3().DS == '1'; when Regime_EL2 => return TCR_EL2().E2H0.DS == '1'; return TCR_EL2().DS == '1'; when Regime_EL20 => return TCR_EL2().E2H1.DS == '1'; return TCR_EL2().DS == '1'; when Regime_EL10 => return TCR_EL1().DS == '1'; otherwise => unreachable; end; end;

Library pseudocode for aarch64/translation/vmsa_addrcalc/AArch64_S1SLTTEntryAddress

// AArch64_S1SLTTEntryAddress() // ============================ // Compute the first stage 1 translation table descriptor address within the // table pointed to by the base at the start level func AArch64_S1SLTTEntryAddress(level : integer, walkparams : S1TTWParams, ia : bits(64), tablebase : FullAddress) => FullAddress begin let descsizelog2 : integer{} = if walkparams.d128 == '1' then 4 else 3; let nstride : integer = 1; let start_level_lookup : boolean = TRUE; let (lsb, msb) = // Input Address size let iasize : AArch64_TTEntryAddressBoundsAddressSize(level, walkparams.txsz, walkparams.tgx, descsizelog2, start_level_lookup, nstride); let index : bits(=AArch64_IASize(walkparams.txsz); let granulebits : AddressSize = TGxGranuleBits(walkparams.tgx); let descsizelog2 : integer{} = if walkparams.d128 == '1' then 4 else 3; let stride : integer{} = granulebits - descsizelog2; let levels : integer = FINAL_LEVEL - level; var index : bits(NUM_PABITS); let lsb : AddressSize = (levels*stride + granulebits) as AddressSize; let msb : AddressSize = (iasize - 1) as AddressSize) = ZeroExtend{; index = ZeroExtend{NUM_PABITS}(ia[msb:lsb]::Zeros{descsizelog2}); var descaddress : FullAddress; descaddress.address = tablebase.address OR index; descaddress.paspace = tablebase.paspace; return descaddress; end;

Library pseudocode for aarch64/translation/vmsa_addrcalc/AArch64_S1TTEntryAddress

// AArch64_S1TTEntryAddress() // ========================== // Compute translation table descriptor address within the table pointed to by // the table base func AArch64_S1TTEntryAddress{N}(level : integer, walkparams : S1TTWParams, skl : bits(2), ia : bits(64), tablebase : FullAddress, descriptor : bits(N)) => FullAddress begin let nstride : integer = if walkparams.d128 == '1' then UInt(skl) + 1 else 1; let descsizelog2 : integer{} = if walkparams.d128 == '1' then 4 else 3; let start_level_lookup : boolean = FALSE; let (lsb, msb) = // Input Address size let iasize : AArch64_TTEntryAddressBoundsAddressSize(level, walkparams.txsz, walkparams.tgx, descsizelog2, start_level_lookup, nstride); let index : bits(=AArch64_IASize(walkparams.txsz); let granulebits : AddressSize = TGxGranuleBits(walkparams.tgx); let descsizelog2 : integer{} = if walkparams.d128 == '1' then 4 else 3; let stride : integer{} = granulebits - descsizelog2; let levels : integer = FINAL_LEVEL - level; var index : bits(NUM_PABITS); let lsb : AddressSize = (levels*stride + granulebits) as AddressSize; let nstride : integer = if walkparams.d128 == '1' then UInt(skl) + 1 else 1; let msb : AddressSize = ((lsb + (stride * nstride)) - 1) as AddressSize) = ZeroExtend{; index = ZeroExtend{NUM_PABITS}(ia[msb:lsb]::Zeros{descsizelog2}); var descaddress : FullAddress; descaddress.address = tablebase.address OR index; descaddress.paspace = tablebase.paspace; return descaddress; end;

Library pseudocode for aarch64/translation/vmsa_addrcalc/AArch64_S2SLTTEntryAddress

// AArch64_S2SLTTEntryAddress() // ============================ // Compute the first stage 2 translation table descriptor address within the // table pointed to by the base at the start level func AArch64_S2SLTTEntryAddress(walkparams : S2TTWParams, ipa : bits(NUM_PABITS), tablebase : FullAddress) => FullAddress begin let startlevel = AArch64_S2StartLevel(walkparams); let descsizelog2 : integer{} = if walkparams.d128 == '1' then 4 else 3; let nstride : integer = 1; let start_level_lookup : boolean = TRUE; let (lsb, msb) = let iasize = AArch64_TTEntryAddressBoundsAArch64_IASize(startlevel, walkparams.txsz, walkparams.tgx, descsizelog2, start_level_lookup, nstride); let index : bits((walkparams.txsz); let granulebits = TGxGranuleBits(walkparams.tgx); let descsizelog2 : integer{} = if walkparams.d128 == '1' then 4 else 3; let stride : integer{} = granulebits - descsizelog2; let levels : integer =FINAL_LEVEL - startlevel; var index : bits(NUM_PABITS); let lsb : AddressSize = (levels*stride + granulebits) as AddressSize; let msb : AddressSize = (iasize - 1) as AddressSize) = ZeroExtend{; index = ZeroExtend{NUM_PABITS}(ipa[msb:lsb]::Zeros{descsizelog2}); var descaddress : FullAddress; descaddress.address = tablebase.address OR index; descaddress.paspace = tablebase.paspace; return descaddress; end;

Library pseudocode for aarch64/translation/vmsa_addrcalc/AArch64_S2TTEntryAddress

// AArch64_S2TTEntryAddress() // ========================== // Compute translation table descriptor address within the table pointed to by // the table base func AArch64_S2TTEntryAddress(level : integer, walkparams : S2TTWParams, skl : bits(2), ipa : bits(NUM_PABITS), tablebase : FullAddress) => FullAddress begin let nstride : integer = if walkparams.d128 == '1' then UInt(skl) + 1 else 1; let descsizelog2 : integer{} = if walkparams.d128 == '1' then 4 else 3; let start_level_lookup : boolean = FALSE; let (lsb, msb) = let ipasize : AArch64_TTEntryAddressBoundsAddressSize(level, walkparams.txsz, walkparams.tgx, descsizelog2, start_level_lookup, nstride); let index : bits(=AArch64_IASize(walkparams.txsz); let granulebits : AddressSize = TGxGranuleBits(walkparams.tgx); let descsizelog2 : integer{} = if walkparams.d128 == '1' then 4 else 3; let stride : integer{} = granulebits - descsizelog2; let levels : integer = FINAL_LEVEL - level; var index : bits(NUM_PABITS); let lsb : AddressSize = (levels*stride + granulebits) as AddressSize; let nstride : integer = if walkparams.d128 == '1' then UInt(skl) + 1 else 1; let msb : AddressSize = ((lsb + (stride * nstride)) - 1) as AddressSize) = ZeroExtend{; index = ZeroExtend{NUM_PABITS}(ipa[msb:lsb]::Zeros{descsizelog2}); var descaddress : FullAddress; descaddress.address = tablebase.address OR index; descaddress.paspace = tablebase.paspace; return descaddress; end;

Library pseudocode for aarch64/translation/vmsa_addrcalc/AArch64_TTEntryAddressBounds

// AArch64_TTEntryAddressBounds() // ============================== // Calculate the input-address bounds used to index a translation table entry func AArch64_TTEntryAddressBounds(level : integer, txsz : bits(6), tgx : TGx, descsizelog2 : integer{3,4}, start_level_lookup : boolean, nstride : integer) => (AddressSize, AddressSize) begin let iasize : AddressSize = AArch64_IASize(txsz); let granulebits : AddressSize = TGxGranuleBits(tgx); let stride : integer{} = granulebits - descsizelog2; let levels : integer = FINAL_LEVEL - level; let lsb : AddressSize = (levels * stride + granulebits) as AddressSize; var msb : AddressSize; if start_level_lookup then msb = (iasize - 1) as AddressSize; else msb = ((lsb + (stride * nstride)) - 1) as AddressSize; end; return(lsb, msb); end;

Library pseudocode for aarch64/translation/vmsa_faults/AArch64_PermissionsOverlaysAppliedLibrary pseudocode for aarch64/translation/vmsa_faults/AArch64_PermissionOverlaysApplied

// AArch64_PermissionsOverlaysApplied() // ==================================== // AArch64_PermissionOverlaysApplied() // =================================== // Returns TRUE if Permission overlays are applied for the given access type. func AArch64_PermissionsOverlaysApplied(acctype : AccessType) => boolean begin case acctype of when AccessType_SPE => return FALSE; when AccessType_TRBE => return FALSE; otherwise => return TRUE; end; end;

Library pseudocode for aarch64/translation/vmsa_faults/AArch64_S1DirectBasePermissions

// AArch64_S1DirectBasePermissions() // ================================= // Computes the stage 1 direct base permissions func AArch64_S1DirectBasePermissions(regime : Regime, walkstate : TTWState, walkparams : S1TTWParams, accdesc : AccessDescriptor) => S1AccessControls begin var r, w, x, wxn : bit; var pr, pw, px, pwxn : bit; var ur, uw, ux, uwxn : bit; var permissions : Permissions = walkstate.permissions; var s1perms : S1AccessControls; // Descriptors marked with DBM set have the effective value of AP[2] cleared. // This implies no Permission faults caused by lack of write permissions are // reported, and the Dirty bit can be set. if permissions.dbm == '1' && walkparams.hd == '1' then permissions.ap[2] = '0'; end; if HasUnprivileged(regime) then // Apply leaf permissions case permissions.ap[2:1] of when '00' => (pr,pw,ur,uw) = ('1','1','0','0'); // Privileged access when '01' => (pr,pw,ur,uw) = ('1','1','1','1'); // No effect when '10' => (pr,pw,ur,uw) = ('1','0','0','0'); // Read-only, privileged access when '11' => (pr,pw,ur,uw) = ('1','0','1','0'); // Read-only end; // Apply hierarchical permissions case permissions.ap_table of when '00' => (pr,pw,ur,uw) = (pr, pw, ur, uw); // No effect when '01' => (pr,pw,ur,uw) = (pr, pw,'0','0'); // Privileged access when '10' => (pr,pw,ur,uw) = (pr,'0', ur,'0'); // Read-only when '11' => (pr,pw,ur,uw) = (pr,'0','0','0'); // Read-only, privileged access end; // Locations writable by unprivileged cannot be executed by privileged px = NOT(permissions.pxn OR permissions.pxn_table OR uw); ux = NOT(permissions.uxn OR permissions.uxn_table); pwxn = walkparams.wxn AND pw AND px; uwxn = walkparams.wxn AND uw AND ux; if (IsFeatureImplemented(FEAT_PAN) && accdesc.pan && !(regime == Regime_EL10 && walkparams.nv1 == '1')) then if (ImpDefBool("SCR_EL3.SIF affects EPAN") && accdesc.ss == SS_Secure && walkstate.baseaddress.paspace == PAS_NonSecure && walkparams.sif == '1') then ux = '0'; end; if (ImpDefBool("Realm EL2&0 regime affects EPAN") && accdesc.ss == SS_Realm && regime == Regime_EL20 && walkstate.baseaddress.paspace != PAS_Realm) then ux = '0'; end; let pan : bit = PSTATE.PAN AND (ur OR uw OR (walkparams.epan AND ux)); pr = pr AND NOT(pan); pw = pw AND NOT(pan); end; else // Apply leaf permissions case permissions.ap[2] of when '0' => (pr,pw) = ('1','1'); // No effect when '1' => (pr,pw) = ('1','0'); // Read-only end; // Apply hierarchical permissions case permissions.ap_table[1] of when '0' => (pr,pw) = (pr, pw); // No effect when '1' => (pr,pw) = (pr,'0'); // Read-only end; px = NOT(permissions.xn OR permissions.xn_table); pwxn = walkparams.wxn AND pw AND px; end; (r,w,x,wxn) = if accdesc.el == EL0 then (ur,uw,ux,uwxn) else (pr,pw,px,pwxn); // Prevent execution from Non-secure space by PE in secure state if SIF is set if accdesc.ss == SS_Secure && walkstate.baseaddress.paspace == PAS_NonSecure then x = x AND NOT(walkparams.sif); end; // Prevent execution from non-Root space by Root if accdesc.ss == SS_Root && walkstate.baseaddress.paspace != PAS_Root then x = '0'; end; // Prevent execution from non-Realm space by Realm EL2 and Realm EL2&0 if (accdesc.ss == SS_Realm && regime IN {Regime_EL2, Regime_EL20} && walkstate.baseaddress.paspace != PAS_Realm) then x = '0'; end; s1perms.r = r; s1perms.w = w; s1perms.x = x; s1perms.gcs = '0'; s1perms.wxn = wxn; s1perms.overlay = s1perms.overlay = TRUE; return s1perms; end; AArch64_PermissionsOverlaysApplied(accdesc.acctype); return s1perms; end;

Library pseudocode for aarch64/translation/vmsa_faults/AArch64_S1IndirectBasePermissions

// AArch64_S1IndirectBasePermissions() // =================================== // Computes the stage 1 indirect base permissions func AArch64_S1IndirectBasePermissions(regime : Regime, walkstate : TTWState, walkparams : S1TTWParams, accdesc : AccessDescriptor) => S1AccessControls begin var r, w, x, gcs, wxn, overlay : bit; var pr, pw, px, pgcs, pwxn, p_overlay : bit; var ur, uw, ux, ugcs, uwxn, u_overlay : bit; let permissions : Permissions = walkstate.permissions; var s1perms : S1AccessControls; // Apply privileged indirect permissions case permissions.ppi of when '0000' => (pr,pw,px,pgcs) = ('0','0','0','0'); // No access when '0001' => (pr,pw,px,pgcs) = ('1','0','0','0'); // Privileged read when '0010' => (pr,pw,px,pgcs) = ('0','0','1','0'); // Privileged execute when '0011' => (pr,pw,px,pgcs) = ('1','0','1','0'); // Privileged read and execute when '0100' => (pr,pw,px,pgcs) = ('0','0','0','0'); // Reserved when '0101' => (pr,pw,px,pgcs) = ('1','1','0','0'); // Privileged read and write when '0110' => (pr,pw,px,pgcs) = ('1','1','1','0'); // Privileged read, write and execute when '0111' => (pr,pw,px,pgcs) = ('1','1','1','0'); // Privileged read, write and execute when '1000' => (pr,pw,px,pgcs) = ('1','0','0','0'); // Privileged read when '1001' => if IsFeatureImplemented(FEAT_GCS) then (pr,pw,px,pgcs) = ('1','0','0','1'); // Privileged read and gcs else (pr,pw,px,pgcs) = ('0','0','0','0'); // Reserved end; when '1010' => (pr,pw,px,pgcs) = ('1','0','1','0'); // Privileged read and execute when '1011' => (pr,pw,px,pgcs) = ('0','0','0','0'); // Reserved when '1100' => (pr,pw,px,pgcs) = ('1','1','0','0'); // Privileged read and write when '1101' => (pr,pw,px,pgcs) = ('0','0','0','0'); // Reserved when '1110' => (pr,pw,px,pgcs) = ('1','1','1','0'); // Privileged read, write and execute when '1111' => (pr,pw,px,pgcs) = ('0','0','0','0'); // Reserved end; p_overlay = NOT(permissions.ppi[3]); pwxn = if permissions.ppi == '0110' then '1' else '0'; var reserved_upi : boolean = FALSE; if HasUnprivileged(regime) then // Apply unprivileged indirect permissions case permissions.upi of when '0000' => (ur,uw,ux,ugcs) = ('0','0','0','0'); // No access when '0001' => (ur,uw,ux,ugcs) = ('1','0','0','0'); // Unprivileged read when '0010' => (ur,uw,ux,ugcs) = ('0','0','1','0'); // Unprivileged execute when '0011' => (ur,uw,ux,ugcs) = ('1','0','1','0'); // Unprivileged read and execute when '0100' => (ur,uw,ux,ugcs) = ('0','0','0','0'); // Reserved reserved_upi = TRUE; when '0101' => (ur,uw,ux,ugcs)=('1','1','0','0');// Unprivileged read and write when '0110' => (ur,uw,ux,ugcs)=('1','1','1','0');// Unprivileged read, write and execute when '0111' => (ur,uw,ux,ugcs)=('1','1','1','0');// Unprivileged read, write and execute when '1000' => (ur,uw,ux,ugcs)=('1','0','0','0');// Unprivileged read when '1001' => if IsFeatureImplemented(FEAT_GCS) then (ur,uw,ux,ugcs) = ('1','0','0','1'); // Unprivileged read and gcs else (ur,uw,ux,ugcs) = ('0','0','0','0'); // Reserved reserved_upi = TRUE; end; when '1010' => (ur,uw,ux,ugcs)=('1','0','1','0');// Unprivileged read and execute when '1011' => (ur,uw,ux,ugcs) = ('0','0','0','0'); // Reserved reserved_upi = TRUE; when '1100' => (ur,uw,ux,ugcs) =('1','1','0','0');// Unprivileged read and write when '1101' => (ur,uw,ux,ugcs) =('0','0','0','0'); // Reserved reserved_upi = TRUE; when '1110' => (ur,uw,ux,ugcs) =('1','1','1','0');// Unprivileged read, write // and execute when '1111' => (ur,uw,ux,ugcs) = ('0','0','0','0'); // Reserved reserved_upi = TRUE; end; u_overlay = NOT(permissions.upi[3]); uwxn = if permissions.upi == '0110' then '1' else '0'; // If the decoded permissions has either px or pgcs along with either uw or ugcs, // then all effective Stage 1 Base Permissions are set to 0 if ((px == '1' || pgcs == '1') && (uw == '1' || ugcs == '1')) then (pr,pw,px,pgcs) = ('0','0','0','0'); (ur,uw,ux,ugcs) = ('0','0','0','0'); end; end; // Prevent execution from Non-secure space by PE in secure state if accdesc.ss == SS_Secure && walkstate.baseaddress.paspace == PAS_NonSecure then pgcs = '0'; if HasUnprivileged(regime) then ugcs = '0'; end; if walkparams.sif == '1' then px = '0'; if HasUnprivileged(regime) then ux = '0'; end; end; end; // Prevent execution from non-Root space by Root if accdesc.ss == SS_Root && walkstate.baseaddress.paspace != PAS_Root then (px, pgcs) = ('0','0'); if HasUnprivileged(regime) then (ux, ugcs) = ('0','0'); end; end; // Prevent execution from non-Realm space by Realm EL2 and Realm EL2&0 if (accdesc.ss == SS_Realm && regime IN {Regime_EL2, Regime_EL20} && walkstate.baseaddress.paspace != PAS_Realm) then (px, pgcs) = ('0','0'); if HasUnprivileged(regime) then (ux, ugcs) = ('0','0'); end; end; if (HasUnprivileged(regime) && IsFeatureImplemented(FEAT_PAN) && accdesc.pan && !(regime == Regime_EL10 && walkparams.nv1 == '1') && PSTATE.PAN == '1' && !IsZero(permissions.upi)) then if reserved_upi then if ImpDefBool("PAN applies when S1UnprivBasePerm is reserved") then (pr,pw) = ('0','0'); end; elsif (!IsZero(ur::uw::ux::ugcs) || ImpDefBool("PAN applies when S1UnprivBasePerms are removed")) then (pr,pw) = ('0','0'); end; end; if accdesc.el == EL0 then (r,w,x,gcs,wxn,overlay) = (ur,uw,ux,ugcs,uwxn,u_overlay); else (r,w,x,gcs,wxn,overlay) = (pr,pw,px,pgcs,pwxn,p_overlay); end; s1perms.r = r; s1perms.w = w; s1perms.x = x; s1perms.gcs = gcs; s1perms.wxn = wxn; s1perms.overlay = s1perms.overlay = overlay == '1'; return s1perms; end; AArch64_PermissionsOverlaysApplied(accdesc.acctype) && overlay == '1'; return s1perms; end;

Library pseudocode for aarch64/translation/vmsa_faults/AArch64_S2CheckPermissions

// AArch64_S2CheckPermissions() // ============================ // Verifies memory access with available permissions. func AArch64_S2CheckPermissions(fault_in : FaultRecord, walkstate : TTWState, walkparams : S2TTWParams, ipa : AddressDescriptor, accdesc : AccessDescriptor) => (FaultRecord, boolean) begin let memtype : MemType = walkstate.memattrs.memtype; let permissions : Permissions = walkstate.permissions; var fault : FaultRecord = fault_in; let s2perms : S2AccessControls = AArch64_S2ComputePermissions(permissions, walkparams, accdesc); var r, w : bit; var or, ow : bit; if accdesc.acctype == AccessType_TTW then r = s2perms.r_mmu; w = s2perms.w_mmu; or = s2perms.or_mmu; ow = s2perms.ow_mmu; elsif accdesc.rcw then r = s2perms.r_rcw; w = s2perms.w_rcw; or = s2perms.or_rcw; ow = s2perms.ow_rcw; else r = s2perms.r; w = s2perms.w; or = s2perms.or; ow = s2perms.ow; end; if accdesc.acctype == AccessType_TTW then if (accdesc.toplevel && accdesc.varange == VARange_LOWER && ((walkparams.tl0 == '1' && s2perms.toplevel0 == '0') || (walkparams.tl1 == '1' && s2perms.[toplevel1,toplevel0] == '10'))) then fault.statuscode = Fault_Permission; fault.toplevel = TRUE; elsif (accdesc.toplevel && accdesc.varange == VARange_UPPER && ((walkparams.tl1 == '1' && s2perms.toplevel1 == '0') || (walkparams.tl0 == '1' && s2perms.[toplevel1,toplevel0] == '01'))) then fault.statuscode = Fault_Permission; fault.toplevel = TRUE; // Stage 2 Permission fault due to AssuredOnly check elsif (walkstate.s2assuredonly == '1' && !ipa.s1assured) then fault.statuscode = Fault_Permission; fault.assuredonly = TRUE; elsif s2perms.overlay && or == '0' then fault.statuscode = Fault_Permission; fault.overlay = TRUE; elsif accdesc.write && s2perms.overlay && ow == '0' then fault.statuscode = Fault_Permission; fault.overlay = TRUE; elsif walkparams.ptw == '1' && memtype == MemType_Device then fault.statuscode = Fault_Permission; // Prevent translation table walks in Non-secure space by Realm state elsif accdesc.ss == SS_Realm && walkstate.baseaddress.paspace != PAS_Realm then fault.statuscode = Fault_Permission; elsif r == '0' then fault.statuscode = Fault_Permission; elsif accdesc.write && w == '0' then fault.statuscode = Fault_Permission; fault.hdbssf = walkparams.hdbss == '1' && !CanAppendToHDBSS() && permissions.dbm == '1'; elsif (accdesc.write && walkparams.s2pie == '1' && permissions.s2dirty == '0' && (walkparams.hd != '1' || (accdesc.acctype != AccessType_AT && walkparams.hdbss == '1' && !CanAppendToHDBSS()))) then fault.statuscode = Fault_Permission; fault.dirtybit = TRUE; fault.hdbssf = walkparams.hdbss == '1' && !CanAppendToHDBSS(); end; // Stage 2 Permission fault due to AssuredOnly check elsif ((walkstate.s2assuredonly == '1' && !ipa.s1assured) || (walkstate.s2assuredonly != '1' && IsFeatureImplemented(FEAT_GCS) && VTCR_EL2().GCSH == '1' && accdesc.acctype == AccessType_GCS && accdesc.el != EL0)) then fault.statuscode = Fault_Permission; fault.assuredonly = TRUE; elsif accdesc.acctype == AccessType_IFETCH then if s2perms.overlay && s2perms.ox == '0' then fault.statuscode = Fault_Permission; fault.overlay = TRUE; elsif (memtype == MemType_Device && ConstrainUnpredictable(Unpredictable_INSTRDEVICE) == Constraint_FAULT) then fault.statuscode = Fault_Permission; // Prevent execution from Non-secure space by Realm state elsif accdesc.ss == SS_Realm && walkstate.baseaddress.paspace != PAS_Realm then fault.statuscode = Fault_Permission; elsif s2perms.x == '0' then fault.statuscode = Fault_Permission; end; elsif accdesc.acctype == AccessType_DC then if accdesc.cacheop == CacheOp_Invalidate then if !ELUsingAArch32(EL1) && s2perms.overlay && ow == '0' then fault.statuscode = Fault_Permission; fault.overlay = TRUE; elsif !ELUsingAArch32(EL1) && w == '0' then fault.statuscode = Fault_Permission; elsif (walkparams.hd != '1' && walkparams.s2pie == '1' && permissions.s2dirty == '0') then fault.statuscode = Fault_Permission; fault.dirtybit = TRUE; end; elsif !ELUsingAArch32(EL1) && accdesc.el == EL0 && s2perms.overlay && or == '0' then fault.statuscode = Fault_Permission; fault.overlay = TRUE; elsif (walkparams.cmow == '1' && accdesc.cacheop == CacheOp_CleanInvalidate && s2perms.overlay && ow == '0') then fault.statuscode = Fault_Permission; fault.overlay = TRUE; elsif !ELUsingAArch32(EL1) && accdesc.el == EL0 && r == '0' then fault.statuscode = Fault_Permission; elsif (walkparams.cmow == '1' && accdesc.cacheop == CacheOp_CleanInvalidate && w == '0') then fault.statuscode = Fault_Permission; elsif (walkparams.cmow == '1' && accdesc.cacheop == CacheOp_CleanInvalidate && walkparams.hd != '1' && walkparams.s2pie == '1' && permissions.s2dirty == '0') then fault.statuscode = Fault_Permission; fault.dirtybit = TRUE; end; elsif accdesc.acctype == AccessType_IC then if (!ELUsingAArch32(EL1) && accdesc.el == EL0 && s2perms.overlay && or == '0' && ImpDefBool("Permission fault on EL0 IC_IVAU execution")) then fault.statuscode = Fault_Permission; fault.overlay = TRUE; elsif walkparams.cmow == '1' && s2perms.overlay && ow == '0' then fault.statuscode = Fault_Permission; fault.overlay = TRUE; elsif (!ELUsingAArch32(EL1) && accdesc.el == EL0 && r == '0' && ImpDefBool("Permission fault on EL0 IC_IVAU execution")) then fault.statuscode = Fault_Permission; elsif walkparams.cmow == '1' && w == '0' then fault.statuscode = Fault_Permission; elsif (walkparams.cmow == '1' && walkparams.hd != '1' && walkparams.s2pie == '1' && permissions.s2dirty == '0') then fault.statuscode = Fault_Permission; fault.dirtybit = TRUE; end; elsif accdesc.read && s2perms.overlay && or == '0' then fault.statuscode = Fault_Permission; fault.overlay = TRUE; fault.write = FALSE; elsif accdesc.write && s2perms.overlay && ow == '0' then fault.statuscode = Fault_Permission; fault.overlay = TRUE; fault.write = TRUE; elsif accdesc.read && r == '0' then fault.statuscode = Fault_Permission; fault.write = FALSE; elsif accdesc.write && w == '0' then fault.statuscode = Fault_Permission; fault.write = TRUE; fault.hdbssf = walkparams.hdbss == '1' && !CanAppendToHDBSS() && permissions.dbm == '1'; elsif (IsFeatureImplemented(FEAT_MTE_PERM) && ((accdesc.tagchecked && AArch64_EffectiveTCF(accdesc.el, accdesc.read) != TCFType_Ignore) || accdesc.tagaccess) && ipa.memattrs.tags == MemTag_AllocationTagged && permissions.s2tag_na == '1' && S2DCacheEnabled()) then fault.statuscode = Fault_Permission; fault.tagaccess = TRUE; fault.write = accdesc.tagaccess && accdesc.write; elsif (accdesc.write && (walkparams.hd != '1' || (walkparams.hdbss == '1' && accdesc.acctype != (walkparams.hd != '1' || (walkparams.hdbss == '1' && ! AccessType_AT && !CanAppendToHDBSS())) && walkparams.s2pie == '1' && permissions.s2dirty == '0') then fault.statuscode = Fault_Permission; fault.dirtybit = TRUE; fault.write = TRUE; fault.hdbssf = (walkparams.hdbss == '1' && accdesc.acctype != AccessType_AT && !; fault.dirtybit = TRUE; fault.write = TRUE; fault.hdbssf = walkparams.hdbss == '1' && !CanAppendToHDBSS()); (); end; // MRO* allows only RCW and MMU writes var mro : boolean; if s2perms.overlay then mro = (s2perms.[w,w_rcw,w_mmu] AND s2perms.[ow,ow_rcw,ow_mmu]) == '011'; else mro = s2perms.[w,w_rcw,w_mmu] == '011'; end; return (fault, mro); end;

Library pseudocode for aarch64/translation/vmsa_faults/AArch64_S2DirectBasePermissions

// AArch64_S2DirectBasePermissions() // ================================= // Computes the stage 2 direct base permissions. func AArch64_S2DirectBasePermissions(permissions : Permissions, accdesc : AccessDescriptor, walkparams : S2TTWParams) => S2AccessControls begin var s2perms : S2AccessControls; var w : bit; let r : bit = permissions.s2ap[0]; if permissions.s2ap[1] == '1' then w = '1'; // Descriptors marked with DBM set have the effective value of S2AP[1] set. // This implies no Permission faults caused by lack of write permissions are // reported, and the Dirty bit can be set. elsif permissions.dbm == '1' && walkparams.hd == '1' then // An update occurs here, conditional to being able to append to HDBSS if (walkparams.hdbss == '1' && accdesc.acctype IN !{ if walkparams.hdbss == '1' then w = ifAccessType_DC, AccessType_IC, AccessType_AT}) then w = if CanAppendToHDBSS() then '1' else '0'; else w = '1'; end; else w = '0'; end; var px, ux : bit; case (permissions.s2xn::permissions.s2xnx) of when '00' => (px,ux) = ('1','1'); when '01' => (px,ux) = ('0','1'); when '10' => (px,ux) = ('0','0'); when '11' => (px,ux) = ('1','0'); end; let x : bit = if accdesc.el == EL0 then ux else px; s2perms.r = r; s2perms.w = w; s2perms.x = x; s2perms.r_rcw = r; s2perms.w_rcw = w; s2perms.r_mmu = r; s2perms.w_mmu = w; s2perms.toplevel0 = '0'; s2perms.toplevel1 = '0'; s2perms.overlay = FALSE; return s2perms; end;

Library pseudocode for aarch64/translation/vmsa_translation/AArch64_S1DisabledOutput

// AArch64_S1DisabledOutput() // ========================== // Map the VA to IPA/PA and assign default memory attributes func AArch64_S1DisabledOutput(fault_in : FaultRecord, regime : Regime, va_in : bits(64), accdesc : AccessDescriptor, aligned : boolean) => (FaultRecord, AddressDescriptor) begin var va : bits(64) = va_in; let walkparams : S1TTWParams = AArch64_GetS1TTWParams(regime, accdesc.el, accdesc.ss, va); var fault : FaultRecord = fault_in; if accdesc.acctype == // No memory page is guarded when stage 1 address translation is disabled AccessType_IFETCH then // No memory page is guarded when stage 1 address translation is disabled SetInGuardedPage(FALSE); end; // Output Address var oa : FullAddress; oa.address = va[NUM_PABITS-1:0]; case accdesc.ss of when SS_Secure => oa.paspace = PAS_Secure; when SS_NonSecure => oa.paspace = PAS_NonSecure; when SS_Root => oa.paspace = PAS_Root; when SS_Realm => oa.paspace = PAS_Realm; end; var memattrs : MemoryAttributes; if regime == Regime_EL10 && EL2Enabled() && walkparams.dc == '1' then var default_cacheability : MemAttrHints; default_cacheability.attrs = MemAttr_WB; default_cacheability.hints = MemHint_RWA; default_cacheability.transient = FALSE; memattrs.memtype = MemType_Normal; memattrs.outer = default_cacheability; memattrs.inner = default_cacheability; memattrs.shareability = Shareability_NSH; if walkparams.dct == '1' then memattrs.tags = MemTag_AllocationTagged; elsif IsFeatureImplemented(FEAT_MTE_CANONICAL_TAGS) && walkparams.mtx == '1' then memattrs.tags = MemTag_CanonicallyTagged; else memattrs.tags = MemTag_Untagged; end; memattrs.xs = '0'; elsif accdesc.acctype == AccessType_IFETCH then var i_cache_attr : MemAttrHints; if AArch64_S1ICacheEnabled(regime) then i_cache_attr.attrs = MemAttr_WT; i_cache_attr.hints = MemHint_RA; i_cache_attr.transient = FALSE; else i_cache_attr.attrs = MemAttr_NC; end; memattrs.memtype = MemType_Normal; memattrs.outer = i_cache_attr; memattrs.inner = i_cache_attr; memattrs.shareability = Shareability_OSH; memattrs.tags = MemTag_Untagged; memattrs.xs = '1'; elsif accdesc.acctype == AccessType_SPE && EffectivePMBLIMITR_EL1_nVM() == '1' then memattrs = S1DecodeMemAttrs(PMBMAR_EL1().Attr, PMBMAR_EL1().SH, TRUE, walkparams, accdesc.acctype); elsif accdesc.acctype == AccessType_TRBE && EffectiveTRBLIMITR_EL1_nVM() == '1' then memattrs = S1DecodeMemAttrs(TRBMAR_EL1().Attr, TRBMAR_EL1().SH, TRUE, walkparams, accdesc.acctype); else memattrs.memtype = MemType_Device; memattrs.device = DeviceType_nGnRnE; memattrs.shareability = Shareability_OSH; if IsFeatureImplemented(FEAT_MTE_CANONICAL_TAGS) && walkparams.mtx == '1' then memattrs.tags = MemTag_CanonicallyTagged; else memattrs.tags = MemTag_Untagged; end; memattrs.xs = '1'; end; memattrs.notagaccess = FALSE; if walkparams.mtx == '1' && walkparams.tbi == '0' && accdesc.acctype != AccessType_IFETCH then // For the purpose of the checks in this function, the MTE tag bits are ignored. va[59:56] = if HasUnprivileged(regime) then Replicate{4}(va[55]) else '0000'; end; fault.level = 0; let addrtop : AddressSize = AArch64_AddrTop(walkparams.tbid, accdesc.acctype, walkparams.tbi); let pamax : AddressSize = AArch64_PAMax(); let oamax : AddressSize = AArch64_OAMax(); var addrchecked : boolean = FALSE; if accdesc.acctype == AccessType_SPE && EffectivePMBLIMITR_EL1_nVM() == '1' then addrchecked = TRUE; if oamax > pamax && !IsZero(va[(oamax-1):pamax])then fault.statuscode = Fault_AddressSize; elsif !IsZero(va[63:oamax]) then if ConstrainUnpredictableBool(Unpredictable_PMBPTR_Fault_AddressSize)then fault.statuscode = Fault_AddressSize; else oa.address = ZeroExtend{NUM_PABITS}(oa.address[oamax-1:0]); end; end; end; if accdesc.acctype == AccessType_TRBE && EffectiveTRBLIMITR_EL1_nVM() == '1' then addrchecked = TRUE; if oamax > pamax && !IsZero(va[(oamax-1):pamax])then fault.statuscode = Fault_AddressSize; elsif !IsZero(va[63:oamax]) then if ConstrainUnpredictableBool(Unpredictable_TRBPTR_Fault_AddressSize)then fault.statuscode = Fault_AddressSize; else oa.address = ZeroExtend{NUM_PABITS}(oa.address[oamax-1:0]); end; end; end; if fault.statuscode == Fault_None then if !addrchecked && addrtop > pamax && !IsZero(va[addrtop:pamax]) then fault.statuscode = Fault_AddressSize; elsif AArch64_S1HasAlignmentFaultDueToMemType(regime, accdesc, aligned, walkparams.ntlsmd, memattrs) then fault.statuscode = Fault_Alignment; elsif ((accdesc.exclusive || accdesc.atomicop) && !(regime == Regime_EL10 && EL2Enabled() && IsFeatureImplemented(FEAT_HCRMAC) && HCR_EL2().DC == '1') && () && HCR_EL2().DC == '1') && ConstrainUnpredictableBool(Unpredictable_Atomic_MMU_IMPDEF_FAULT)) then fault.statuscode = Fault_Exclusive; end; end; if fault.statuscode != Fault_None then return (fault, ARBITRARY : AddressDescriptor); else var ipa : AddressDescriptor = CreateAddressDescriptor(va_in, oa, memattrs, accdesc); ipa.mecid = AArch64_S1DisabledOutputMECID(walkparams, regime, ipa.paddress.paspace); return (fault, ipa); end; end;

Library pseudocode for aarch64/translation/vmsa_walkparams/AArch64_NSS2TTWParams

// AArch64_NSS2TTWParams() // ======================= // Gather walk parameters specific for Non-secure stage 2 translation func AArch64_NSS2TTWParams(s1aarch64 : boolean) => S2TTWParams begin var walkparams : S2TTWParams; if IsFeatureImplemented(FEAT_HCRMAC) then walkparams.vm = HCR_EL2().VM OR HCR_EL2().DC; else walkparams.vm = HCR_EL2().VM; end; walkparams.vm = HCR_EL2().VM OR HCR_EL2().DC; walkparams.tgx = AArch64_S2DecodeTG0(VTCR_EL2().TG0); walkparams.txsz = VTCR_EL2().T0SZ; walkparams.ps = VTCR_EL2().PS; walkparams.irgn = VTCR_EL2().IRGN0; walkparams.orgn = VTCR_EL2().ORGN0; walkparams.sh = VTCR_EL2().SH0; walkparams.ee = SCTLR_EL2().EE; walkparams.d128 = if IsFeatureImplemented(FEAT_D128) then VTCR_EL2().D128 else '0'; if walkparams.d128 == '1' then walkparams.skl = VTTBR_EL2().SKL; else walkparams.sl0 = VTCR_EL2().SL0; end; if HCR_EL2().TGE == '0' then walkparams.ptw = if IsFeatureImplemented(FEAT_HCRMAC) then HCR_EL2().PTW else '1'; else walkparams.ptw = '0'; end; if IsFeatureImplemented(FEAT_S2FWB) then walkparams.fwb = if IsFeatureImplemented(FEAT_HCRMAC) then HCR_EL2().FWB else '1'; else walkparams.fwb = '0'; end; walkparams.ptw = if HCR_EL2().TGE == '0' then HCR_EL2().PTW else '0'; walkparams.fwb = if IsFeatureImplemented(FEAT_S2FWB) then HCR_EL2().FWB else '0'; walkparams.ha = if IsFeatureImplemented(FEAT_HAF) then VTCR_EL2().HA else '0'; if IsFeatureImplemented(FEAT_HAFDBS) && walkparams.ha == '1' then walkparams.hd = VTCR_EL2().HD; else walkparams.hd = '0'; end; if walkparams.tgx IN {TGx_4KB, TGx_16KB} && IsFeatureImplemented(FEAT_LPA2) then walkparams.ds = VTCR_EL2().DS; else walkparams.ds = '0'; end; if walkparams.tgx == TGx_4KB && IsFeatureImplemented(FEAT_LPA2) then walkparams.sl2 = VTCR_EL2().SL2 AND VTCR_EL2().DS; else walkparams.sl2 = '0'; end; walkparams.cmow = (if IsFeatureImplemented(FEAT_CMOW) && IsHCRXEL2Enabled() then HCRX_EL2().CMOW else '0'); if walkparams.d128 == '1' then walkparams.s2pie = '1'; else walkparams.s2pie = if IsFeatureImplemented(FEAT_S2PIE) then VTCR_EL2().S2PIE else '0'; end; if IsFeatureImplemented(FEAT_S2PIE) then if !(HaveEL(EL3) && SCR_EL3().PIEn == '0' && ImpDefBool("SCR_EL3.PIEn forces PIR_ELx or POR_ELx to zero")) then walkparams.s2pir = S2PIR_EL2() as S2PIRType; else walkparams.s2pir = Zeros{64} as S2PIRType; end; end; if IsFeatureImplemented(FEAT_THE) && walkparams.d128 != '1' then walkparams.assuredonly = VTCR_EL2().AssuredOnly; else walkparams.assuredonly = '0'; end; walkparams.tl0 = if IsFeatureImplemented(FEAT_THE) then VTCR_EL2().TL0 else '0'; walkparams.tl1 = if IsFeatureImplemented(FEAT_THE) then VTCR_EL2().TL1 else '0'; if IsFeatureImplemented(FEAT_HAFT) && walkparams.ha == '1' then walkparams.haft = VTCR_EL2().HAFT; else walkparams.haft = '0'; end; if (IsFeatureImplemented(FEAT_HDBSS) && walkparams.hd == '1' && (!HaveEL(EL3) || SCR_EL3().HDBSSEn == '1')) then walkparams.hdbss = VTCR_EL2().HDBSS; else walkparams.hdbss = '0'; end; return walkparams; end;

Library pseudocode for aarch64/translation/vmsa_walkparams/AArch64_S1TTWParamsEL10

// AArch64_S1TTWParamsEL10() // ========================= // Gather stage 1 translation table walk parameters for EL1&0 regime // (with EL2 enabled or disabled) readonly func AArch64_S1TTWParamsEL10(el : bits(2), varange : VARange) => S1TTWParams begin var walkparams : S1TTWParams; if IsFeatureImplemented(FEAT_D128) && IsTCR2EL1Enabled() then walkparams.d128 = TCR2_EL1().D128; else walkparams.d128 = '0'; end; let nvs : bits(3) = EffectiveHCR_EL2_NVx(); walkparams.nv1 = nvs[1] AND nvs[0]; walkparams.nv1 = nvs[1]; if IsFeatureImplemented(FEAT_AIE) then walkparams.mair2 = MAIR2_EL1() as MAIRType; end; walkparams.aie = (if IsFeatureImplemented(FEAT_AIE) && IsTCR2EL1Enabled() then TCR2_EL1().AIE else '0'); if walkparams.d128 == '1' then walkparams.pie = '1'; else walkparams.pie = (if IsFeatureImplemented(FEAT_S1PIE) && IsTCR2EL1Enabled() then TCR2_EL1().PIE else '0'); end; if IsFeatureImplemented(FEAT_S1PIE) then if !(HaveEL(EL3) && SCR_EL3().PIEn == '0' && ImpDefBool("SCR_EL3.PIEn forces PIR_ELx or POR_ELx to zero")) then walkparams.pir = PIR_EL1() as S1PIRType; if walkparams.nv1 == '1' then walkparams.pire0 = Zeros{64} as S1PIRType; else walkparams.pire0 = PIRE0_EL1() as S1PIRType; end; else walkparams.pir = Zeros{64} as S1PIRType; walkparams.pire0 = Zeros{64} as S1PIRType; end; end; if varange == VARange_LOWER then walkparams.tgx = AArch64_S1DecodeTG0(TCR_EL1().TG0); walkparams.txsz = TCR_EL1().T0SZ; walkparams.irgn = TCR_EL1().IRGN0; walkparams.orgn = TCR_EL1().ORGN0; walkparams.sh = TCR_EL1().SH0; walkparams.tbi = TCR_EL1().TBI0; walkparams.nfd = if IsFeatureImplemented(FEAT_SVE) then TCR_EL1().NFD0 else '0'; walkparams.tbid = if IsFeatureImplemented(FEAT_PAuth) then TCR_EL1().TBID0 else '0'; walkparams.e0pd = if IsFeatureImplemented(FEAT_E0PD) then TCR_EL1().E0PD0 else '0'; walkparams.hpd = if IsFeatureImplemented(FEAT_HPDS) then TCR_EL1().HPD0 else '0'; if walkparams.hpd == '0' then if walkparams.aie == '1' then walkparams.hpd = '1'; end; if walkparams.pie == '1' then walkparams.hpd = '1'; end; if (AArch64_S1POEnabled(Regime_EL10) || AArch64_S1E0POEnabled(Regime_EL10, walkparams.nv1)) then walkparams.hpd = '1'; end; end; if (IsFeatureImplemented(FEAT_MTE_NO_ADDRESS_TAGS) || IsFeatureImplemented(FEAT_MTE_CANONICAL_TAGS)) then walkparams.mtx = TCR_EL1().MTX0; else walkparams.mtx = '0'; end; walkparams.skl = if walkparams.d128 == '1' then TTBR0_EL1().SKL else '00'; walkparams.disch = if walkparams.d128 == '1' then TCR2_EL1().DisCH0 else '0'; if IsFeatureImplemented(FEAT_ASID2) && IsTCR2EL1Enabled() then walkparams.fng = TCR2_EL1().FNG0; else walkparams.fng = '0'; end; if IsFeatureImplemented(FEAT_THE) && IsTCR2EL1Enabled() then walkparams.fngna = TCR2_EL1().FNGNA0; else walkparams.fngna = '0'; end; else walkparams.tgx = AArch64_S1DecodeTG1(TCR_EL1().TG1); walkparams.txsz = TCR_EL1().T1SZ; walkparams.irgn = TCR_EL1().IRGN1; walkparams.orgn = TCR_EL1().ORGN1; walkparams.sh = TCR_EL1().SH1; walkparams.tbi = TCR_EL1().TBI1; walkparams.nfd = if IsFeatureImplemented(FEAT_SVE) then TCR_EL1().NFD1 else '0'; walkparams.tbid = if IsFeatureImplemented(FEAT_PAuth) then TCR_EL1().TBID1 else '0'; walkparams.e0pd = if IsFeatureImplemented(FEAT_E0PD) then TCR_EL1().E0PD1 else '0'; walkparams.hpd = if IsFeatureImplemented(FEAT_HPDS) then TCR_EL1().HPD1 else '0'; if walkparams.hpd == '0' then if walkparams.aie == '1' then walkparams.hpd = '1'; end; if walkparams.pie == '1' then walkparams.hpd = '1'; end; if (AArch64_S1POEnabled(Regime_EL10) || AArch64_S1E0POEnabled(Regime_EL10, walkparams.nv1)) then walkparams.hpd = '1'; end; end; if (IsFeatureImplemented(FEAT_MTE_NO_ADDRESS_TAGS) || IsFeatureImplemented(FEAT_MTE_CANONICAL_TAGS)) then walkparams.mtx = TCR_EL1().MTX1; else walkparams.mtx = '0'; end; walkparams.skl = if walkparams.d128 == '1' then TTBR1_EL1().SKL else '00'; walkparams.disch = if walkparams.d128 == '1' then TCR2_EL1().DisCH1 else '0'; if IsFeatureImplemented(FEAT_ASID2) && IsTCR2EL1Enabled() then walkparams.fng = TCR2_EL1().FNG1; else walkparams.fng = '0'; end; if IsFeatureImplemented(FEAT_THE) && IsTCR2EL1Enabled() then walkparams.fngna = TCR2_EL1().FNGNA1; else walkparams.fngna = '0'; end; end; walkparams.mair = MAIR_EL1() as MAIRType; walkparams.wxn = SCTLR_EL1().WXN; walkparams.ps = TCR_EL1().IPS; walkparams.ee = SCTLR_EL1().EE; if (HaveEL(EL3) && (!IsFeatureImplemented(FEAT_RME) || IsFeatureImplemented(FEAT_SEL2))) then walkparams.sif = SCR_EL3().SIF; else walkparams.sif = '0'; end; if EL2Enabled() then walkparams.dc = if IsFeatureImplemented(FEAT_HCRMAC) then HCR_EL2().DC else '0'; if IsFeatureImplemented(FEAT_MTE2) && IsFeatureImplemented(FEAT_HCRMAC) then walkparams.dct = HCR_EL2().DCT; else walkparams.dct = '0'; end; walkparams.dc = HCR_EL2().DC; walkparams.dct = if IsFeatureImplemented(FEAT_MTE2) then HCR_EL2().DCT else '0'; end; if IsFeatureImplemented(FEAT_LSMAOC) then walkparams.ntlsmd = SCTLR_EL1().nTLSMD; else walkparams.ntlsmd = '1'; end; walkparams.cmow = if IsFeatureImplemented(FEAT_CMOW) then SCTLR_EL1().CMOW else '0'; walkparams.ha = if IsFeatureImplemented(FEAT_HAF) then TCR_EL1().HA else '0'; if IsFeatureImplemented(FEAT_HAFDBS) && walkparams.ha == '1' then walkparams.hd = TCR_EL1().HD; else walkparams.hd = '0'; end; if (walkparams.tgx IN {TGx_4KB, TGx_16KB} && IsFeatureImplemented(FEAT_LPA2) && walkparams.d128 == '0') then walkparams.ds = TCR_EL1().DS; else walkparams.ds = '0'; end; if IsFeatureImplemented(FEAT_PAN3) then walkparams.epan = if walkparams.pie == '0' then SCTLR_EL1().EPAN else '1'; else walkparams.epan = '0'; end; if IsFeatureImplemented(FEAT_THE) && walkparams.d128 == '0' && IsTCR2EL1Enabled() then walkparams.pnch = TCR2_EL1().PnCH; else walkparams.pnch = '0'; end; if IsFeatureImplemented(FEAT_HAFT) && walkparams.ha == '1' && IsTCR2EL1Enabled() then walkparams.haft = TCR2_EL1().HAFT; else walkparams.haft = '0'; end; walkparams.emec = (if IsFeatureImplemented(FEAT_MEC) && IsSCTLR2EL2Enabled() then SCTLR2_EL2().EMEC else '0'); return walkparams; end;

Library pseudocode for aarch64/translation/vmsa_walkparams/AArch64_S1TTWParamsEL2

// AArch64_S1TTWParamsEL2() // ======================== // Gather stage 1 translation table walk parameters for EL2 regime readonly func AArch64_S1TTWParamsEL2(ss : SecurityState) => S1TTWParams begin var walkparams : S1TTWParams; walkparams.tgx = AArch64_S1DecodeTG0(TCR_EL2().TG0); walkparams.txsz = TCR_EL2().T0SZ; walkparams.ps = TCR_EL2().PS; walkparams.irgn = TCR_EL2().IRGN0; walkparams.orgn = TCR_EL2().ORGN0; walkparams.sh = TCR_EL2().SH0; walkparams.tbi = TCR_EL2().TBI; walkparams.mair = MAIR_EL2() as MAIRType; walkparams.pie = (if IsFeatureImplemented(FEAT_S1PIE) && IsTCR2EL2Enabled() then TCR2_EL2().PIE else '0'); if IsFeatureImplemented(FEAT_S1PIE) then if !(HaveEL(EL3) && SCR_EL3().PIEn == '0' && ImpDefBool("SCR_EL3.PIEn forces PIR_ELx or POR_ELx to zero")) then walkparams.pir = PIR_EL2() as S1PIRType; else walkparams.pir = Zeros{64} as S1PIRType; end; end; if IsFeatureImplemented(FEAT_AIE) then walkparams.mair2 = MAIR2_EL2() as MAIRType; end; walkparams.aie = (if IsFeatureImplemented(FEAT_AIE) && IsTCR2EL2Enabled() then TCR2_EL2().AIE else '0'); walkparams.wxn = SCTLR_EL2().WXN; walkparams.ee = SCTLR_EL2().EE; if (HaveEL(EL3) && (!IsFeatureImplemented(FEAT_RME) || IsFeatureImplemented(FEAT_SEL2))) then walkparams.sif = SCR_EL3().SIF; else walkparams.sif = '0'; end; walkparams.tbid = if IsFeatureImplemented(FEAT_PAuth) then TCR_EL2().TBID else '0'; walkparams.hpd = if IsFeatureImplemented(FEAT_HPDS) then TCR_EL2().HPD else '0'; if walkparams.hpd == '0' then if walkparams.aie == '1' then walkparams.hpd = '1'; end; if walkparams.pie == '1' then walkparams.hpd = '1'; end; if AArch64_S1POEnabled(Regime_EL2) then walkparams.hpd = '1'; end; end; walkparams.ha = if IsFeatureImplemented(FEAT_HAF) then TCR_EL2().E2H0.HA else '0'; walkparams.ha = if IsFeatureImplemented(FEAT_HAF) then TCR_EL2().HA else '0'; if IsFeatureImplemented(FEAT_HAFDBS) && walkparams.ha == '1' then walkparams.hd = TCR_EL2().E2H0.HD; walkparams.hd = TCR_EL2().HD; else walkparams.hd = '0'; end; if walkparams.tgx IN {TGx_4KB, TGx_16KB} && IsFeatureImplemented(FEAT_LPA2) then walkparams.ds = TCR_EL2().E2H0.DS; walkparams.ds = TCR_EL2().DS; else walkparams.ds = '0'; end; if (IsFeatureImplemented(FEAT_MTE_NO_ADDRESS_TAGS) || IsFeatureImplemented(FEAT_MTE_CANONICAL_TAGS)) then walkparams.mtx = TCR_EL2().MTX; else walkparams.mtx = '0'; end; walkparams.pnch = (if IsFeatureImplemented(FEAT_THE) && IsTCR2EL2Enabled() then TCR2_EL2().PnCH else '0'); if IsFeatureImplemented(FEAT_HAFT) && walkparams.ha == '1' && IsTCR2EL2Enabled() then walkparams.haft = TCR2_EL2().HAFT; else walkparams.haft = '0'; end; walkparams.emec = (if IsFeatureImplemented(FEAT_MEC) && IsSCTLR2EL2Enabled() then SCTLR2_EL2().EMEC else '0'); if IsFeatureImplemented(FEAT_MEC) && ss == SS_Realm && IsTCR2EL2Enabled() then walkparams.amec = TCR2_EL2().AMEC0; else walkparams.amec = '0'; end; return walkparams; end;

Library pseudocode for aarch64/translation/vmsa_walkparams/AArch64_S1TTWParamsEL20

// AArch64_S1TTWParamsEL20() // ========================= // Gather stage 1 translation table walk parameters for EL2&0 regime readonly func AArch64_S1TTWParamsEL20(el : bits(2), ss : SecurityState, varange : VARange) => S1TTWParams begin var walkparams : S1TTWParams; if IsFeatureImplemented(FEAT_D128) && IsTCR2EL2Enabled() then walkparams.d128 = TCR2_EL2().D128; else walkparams.d128 = '0'; end; if walkparams.d128 == '1' then walkparams.pie = '1'; else walkparams.pie = (if IsFeatureImplemented(FEAT_S1PIE) && IsTCR2EL2Enabled() then TCR2_EL2().PIE else '0'); end; if IsFeatureImplemented(FEAT_S1PIE) then if !(HaveEL(EL3) && SCR_EL3().PIEn == '0' && ImpDefBool("SCR_EL3.PIEn forces PIR_ELx or POR_ELx to zero")) then walkparams.pir = PIR_EL2() as S1PIRType; walkparams.pire0 = PIRE0_EL2() as S1PIRType; else walkparams.pir = Zeros{64} as S1PIRType; walkparams.pire0 = Zeros{64} as S1PIRType; end; end; if IsFeatureImplemented(FEAT_AIE) then walkparams.mair2 = MAIR2_EL2() as MAIRType; end; walkparams.aie = (if IsFeatureImplemented(FEAT_AIE) && IsTCR2EL2Enabled() then TCR2_EL2().AIE else '0'); if varange == VARange_LOWER then walkparams.tgx = AArch64_S1DecodeTG0(TCR_EL2().TG0); walkparams.txsz = TCR_EL2().T0SZ; walkparams.irgn = TCR_EL2().IRGN0; walkparams.orgn = TCR_EL2().ORGN0; walkparams.sh = TCR_EL2().SH0; walkparams.tbi = TCR_EL2().TBI0; walkparams.nfd = if IsFeatureImplemented(FEAT_SVE) then TCR_EL2().NFD0 else '0'; walkparams.tbid = if IsFeatureImplemented(FEAT_PAuth) then TCR_EL2().TBID0 else '0'; walkparams.e0pd = if IsFeatureImplemented(FEAT_E0PD) then TCR_EL2().E0PD0 else '0'; walkparams.hpd = if IsFeatureImplemented(FEAT_HPDS) then TCR_EL2().HPD0 else '0'; if walkparams.hpd == '0' then if walkparams.aie == '1' then walkparams.hpd = '1'; end; if walkparams.pie == '1' then walkparams.hpd = '1'; end; if AArch64_S1POEnabled(Regime_EL20) || AArch64_S1E0POEnabled(Regime_EL20, '0') then walkparams.hpd = '1'; end; end; if (IsFeatureImplemented(FEAT_MTE_NO_ADDRESS_TAGS) || IsFeatureImplemented(FEAT_MTE_CANONICAL_TAGS)) then walkparams.mtx = TCR_EL2().MTX0; else walkparams.mtx = '0'; end; walkparams.skl = if walkparams.d128 == '1' then TTBR0_EL2().SKL else '00'; walkparams.disch = if walkparams.d128 == '1' then TCR2_EL2().DisCH0 else '0'; if IsFeatureImplemented(FEAT_ASID2) && IsTCR2EL2Enabled() then walkparams.fng = TCR2_EL2().FNG0; else walkparams.fng = '0'; end; else walkparams.tgx = AArch64_S1DecodeTG1(TCR_EL2().TG1); walkparams.txsz = TCR_EL2().T1SZ; walkparams.irgn = TCR_EL2().IRGN1; walkparams.orgn = TCR_EL2().ORGN1; walkparams.sh = TCR_EL2().SH1; walkparams.tbi = TCR_EL2().TBI1; walkparams.nfd = if IsFeatureImplemented(FEAT_SVE) then TCR_EL2().NFD1 else '0'; walkparams.tbid = if IsFeatureImplemented(FEAT_PAuth) then TCR_EL2().TBID1 else '0'; walkparams.e0pd = if IsFeatureImplemented(FEAT_E0PD) then TCR_EL2().E0PD1 else '0'; walkparams.hpd = if IsFeatureImplemented(FEAT_HPDS) then TCR_EL2().HPD1 else '0'; if walkparams.hpd == '0' then if walkparams.aie == '1' then walkparams.hpd = '1'; end; if walkparams.pie == '1' then walkparams.hpd = '1'; end; if AArch64_S1POEnabled(Regime_EL20) || AArch64_S1E0POEnabled(Regime_EL20, '0') then walkparams.hpd = '1'; end; end; if (IsFeatureImplemented(FEAT_MTE_NO_ADDRESS_TAGS) || IsFeatureImplemented(FEAT_MTE_CANONICAL_TAGS)) then walkparams.mtx = TCR_EL2().MTX1; else walkparams.mtx = '0'; end; walkparams.skl = if walkparams.d128 == '1' then TTBR1_EL2().SKL else '00'; walkparams.disch = if walkparams.d128 == '1' then TCR2_EL2().DisCH1 else '0'; if IsFeatureImplemented(FEAT_ASID2) && IsTCR2EL2Enabled() then walkparams.fng = TCR2_EL2().FNG1; else walkparams.fng = '0'; end; end; walkparams.mair = MAIR_EL2() as MAIRType; walkparams.wxn = SCTLR_EL2().WXN; walkparams.ps = TCR_EL2().IPS; walkparams.ee = SCTLR_EL2().EE; if (HaveEL(EL3) && (!IsFeatureImplemented(FEAT_RME) || IsFeatureImplemented(FEAT_SEL2))) then walkparams.sif = SCR_EL3().SIF; else walkparams.sif = '0'; end; if IsFeatureImplemented(FEAT_LSMAOC) then walkparams.ntlsmd = SCTLR_EL2().nTLSMD; else walkparams.ntlsmd = '1'; end; walkparams.cmow = if IsFeatureImplemented(FEAT_CMOW) then SCTLR_EL2().CMOW else '0'; walkparams.ha = if IsFeatureImplemented(FEAT_HAF) then TCR_EL2().E2H1.HA else '0'; walkparams.ha = if IsFeatureImplemented(FEAT_HAF) then TCR_EL2().HA else '0'; if IsFeatureImplemented(FEAT_HAFDBS) && walkparams.ha == '1' then walkparams.hd = TCR_EL2().E2H1.HD; walkparams.hd = TCR_EL2().HD; else walkparams.hd = '0'; end; if (walkparams.tgx IN {TGx_4KB, TGx_16KB} && IsFeatureImplemented(FEAT_LPA2) && walkparams.d128 == '0') then walkparams.ds = TCR_EL2().E2H1.DS; walkparams.ds = TCR_EL2().DS; else walkparams.ds = '0'; end; if IsFeatureImplemented(FEAT_PAN3) then walkparams.epan = if walkparams.pie == '0' then SCTLR_EL2().EPAN else '1'; else walkparams.epan = '0'; end; if IsFeatureImplemented(FEAT_THE) && walkparams.d128 == '0' && IsTCR2EL2Enabled() then walkparams.pnch = TCR2_EL2().PnCH; else walkparams.pnch = '0'; end; if IsFeatureImplemented(FEAT_HAFT) && walkparams.ha == '1' && IsTCR2EL2Enabled() then walkparams.haft = TCR2_EL2().HAFT; else walkparams.haft = '0'; end; walkparams.emec = (if IsFeatureImplemented(FEAT_MEC) && IsSCTLR2EL2Enabled() then SCTLR2_EL2().EMEC else '0'); if IsFeatureImplemented(FEAT_MEC) && ss == SS_Realm && IsTCR2EL2Enabled() then walkparams.amec = if varange == VARange_LOWER then TCR2_EL2().AMEC0 else TCR2_EL2().AMEC1; else walkparams.amec = '0'; end; return walkparams; end;

Library pseudocode for aarch64/translation/vmsa_walkparams/AArch64_SS2TTWParams

// AArch64_SS2TTWParams() // ====================== // Gather walk parameters specific for secure stage 2 translation func AArch64_SS2TTWParams(ipaspace : PASpace, s1aarch64 : boolean) => S2TTWParams begin var walkparams : S2TTWParams; walkparams.d128 = if IsFeatureImplemented(FEAT_D128) then VTCR_EL2().D128 else '0'; if ipaspace == PAS_Secure then walkparams.tgx = AArch64_S2DecodeTG0(VSTCR_EL2().TG0); walkparams.txsz = VSTCR_EL2().T0SZ; if walkparams.d128 == '1' then walkparams.skl = VSTTBR_EL2().SKL; else walkparams.sl0 = VSTCR_EL2().SL0; end; if walkparams.tgx == TGx_4KB && IsFeatureImplemented(FEAT_LPA2) then walkparams.sl2 = VSTCR_EL2().SL2 AND VTCR_EL2().DS; else walkparams.sl2 = '0'; end; elsif ipaspace == PAS_NonSecure then walkparams.tgx = AArch64_S2DecodeTG0(VTCR_EL2().TG0); walkparams.txsz = VTCR_EL2().T0SZ; if walkparams.d128 == '1' then walkparams.skl = VTTBR_EL2().SKL; else walkparams.sl0 = VTCR_EL2().SL0; end; if walkparams.tgx == TGx_4KB && IsFeatureImplemented(FEAT_LPA2) then walkparams.sl2 = VTCR_EL2().SL2 AND VTCR_EL2().DS; else walkparams.sl2 = '0'; end; else unreachable; end; walkparams.sw = VSTCR_EL2().SW; walkparams.nsw = VTCR_EL2().NSW; walkparams.sa = VSTCR_EL2().SA; walkparams.nsa = VTCR_EL2().NSA; if IsFeatureImplemented(FEAT_HCRMAC) then walkparams.vm = HCR_EL2().VM OR HCR_EL2().DC; else walkparams.vm = HCR_EL2().VM; end; walkparams.vm = HCR_EL2().VM OR HCR_EL2().DC; walkparams.ps = VTCR_EL2().PS; walkparams.irgn = VTCR_EL2().IRGN0; walkparams.orgn = VTCR_EL2().ORGN0; walkparams.sh = VTCR_EL2().SH0; walkparams.ee = SCTLR_EL2().EE; if HCR_EL2().TGE == '0' then walkparams.ptw = if IsFeatureImplemented(FEAT_HCRMAC) then HCR_EL2().PTW else '1'; else walkparams.ptw = '0'; end; if IsFeatureImplemented(FEAT_S2FWB) then walkparams.fwb = if IsFeatureImplemented(FEAT_HCRMAC) then HCR_EL2().FWB else '1'; else walkparams.fwb = '0'; end; walkparams.ptw = if HCR_EL2().TGE == '0' then HCR_EL2().PTW else '0'; walkparams.fwb = if IsFeatureImplemented(FEAT_S2FWB) then HCR_EL2().FWB else '0'; walkparams.ha = if IsFeatureImplemented(FEAT_HAF) then VTCR_EL2().HA else '0'; if IsFeatureImplemented(FEAT_HAFDBS) && walkparams.ha == '1' then walkparams.hd = VTCR_EL2().HD; else walkparams.hd = '0'; end; if walkparams.tgx IN {TGx_4KB, TGx_16KB} && IsFeatureImplemented(FEAT_LPA2) then walkparams.ds = VTCR_EL2().DS; else walkparams.ds = '0'; end; walkparams.cmow = (if IsFeatureImplemented(FEAT_CMOW) && IsHCRXEL2Enabled() then HCRX_EL2().CMOW else '0'); if walkparams.d128 == '1' then walkparams.s2pie = '1'; else walkparams.s2pie = if IsFeatureImplemented(FEAT_S2PIE) then VTCR_EL2().S2PIE else '0'; end; if IsFeatureImplemented(FEAT_S2PIE) then if !(HaveEL(EL3) && SCR_EL3().PIEn == '0' && ImpDefBool("SCR_EL3.PIEn forces PIR_ELx or POR_ELx to zero")) then walkparams.s2pir = S2PIR_EL2() as S2PIRType; else walkparams.s2pir = Zeros{64} as S2PIRType; end; end; if IsFeatureImplemented(FEAT_THE) && walkparams.d128 != '1' then walkparams.assuredonly = VTCR_EL2().AssuredOnly; else walkparams.assuredonly = '0'; end; walkparams.tl0 = if IsFeatureImplemented(FEAT_THE) then VTCR_EL2().TL0 else '0'; walkparams.tl1 = if IsFeatureImplemented(FEAT_THE) then VTCR_EL2().TL1 else '0'; if IsFeatureImplemented(FEAT_HAFT) && walkparams.ha == '1' then walkparams.haft = VTCR_EL2().HAFT; else walkparams.haft = '0'; end; walkparams.emec = '0'; if (IsFeatureImplemented(FEAT_HDBSS) && walkparams.hd == '1' && (!HaveEL(EL3) || SCR_EL3().HDBSSEn == '1')) then walkparams.hdbss = VTCR_EL2().HDBSS; else walkparams.hdbss = '0'; end; return walkparams; end;

Library pseudocode for aarch64/translation/vmsa_walkparams/S2DCacheEnabled

// S2DCacheEnabled() // ================= // Returns TRUE if Stage 2 Data access cacheability is enabled readonly func S2DCacheEnabled() => boolean begin return !IsFeatureImplemented(FEAT_HCRMAC) || HCR_EL2().CD == '0'; return HCR_EL2().CD == '0'; end;

Library pseudocode for aarch64/translation/vmsa_walkparams/S2ICacheEnabled

// S2ICacheEnabled() // ================= // Returns TRUE if Stage 2 Instruction access cacheability is enabled readonly func S2ICacheEnabled() => boolean begin return !IsFeatureImplemented(FEAT_HCRMAC) || HCR_EL2().ID == '0'; return HCR_EL2().ID == '0'; end;

Library pseudocode for shared/debug/amu/G1ActivityMonitorImplementedMask

// G1ActivityMonitorImplementedMask() // ================================== // Return the implementation-defined G1 activity monitor mask. func G1ActivityMonitorImplementedMask() => bits(16) begin assert NUM_AMU_CG1_MONITORS <= 16; var mask : bits(16) = Zeros{16}; for i = 0 to (NUM_AMU_CG1_MONITORS-1) do mask[i] = if IsG1ActivityMonitorImplemented(i) then '1' else '0'; end; return mask; end;

Library pseudocode for shared/debug/amu/Write_AMCNTENCLR0

// Write_AMCNTENCLR0() // =================== // System register write to AMCNTENCLR0. func Write_AMCNTENCLR0(value_in : bits(32)) begin AMCNTENCLR0().P = AMCNTENCLR0().P AND NOT value_in[0 +: NUM_AMU_CG0_MONITORS]; end;

Library pseudocode for shared/debug/amu/Write_AMCNTENCLR0_EL0

// Write_AMCNTENCLR0_EL0() // ======================= // System register write to AMCNTENCLR0_EL0. func Write_AMCNTENCLR0_EL0(value_in : bits(64)) begin AMCNTENCLR0_EL0().P = AMCNTENCLR0_EL0().P AND NOT value_in[0 +: NUM_AMU_CG0_MONITORS]; end;

Library pseudocode for shared/debug/amu/Write_AMCNTENCLR1

// Write_AMCNTENCLR1() // =================== // System register write to AMCNTENCLR1. func Write_AMCNTENCLR1(value_in : bits(32)) begin assert NUM_AMU_CG1_MONITORS <= 16; let implemented : bits(16) = G1ActivityMonitorImplementedMask(); AMCNTENCLR1().P = (AMCNTENCLR1().P AND NOT (ZeroExtend{16}(value_in[0 +: NUM_AMU_CG1_MONITORS]) AND implemented)); end;

Library pseudocode for shared/debug/amu/Write_AMCNTENCLR1_EL0

// Write_AMCNTENCLR1_EL0() // ======================= // System register write to AMCNTENCLR1_EL0. func Write_AMCNTENCLR1_EL0(value_in : bits(64)) begin assert NUM_AMU_CG1_MONITORS <= 16; let implemented : bits(16) = G1ActivityMonitorImplementedMask(); AMCNTENCLR1_EL0().P = (AMCNTENCLR1_EL0().P AND NOT (ZeroExtend{16}(value_in[0 +: NUM_AMU_CG1_MONITORS]) AND implemented)); end;

Library pseudocode for shared/debug/amu/Write_AMCNTENSET0

// Write_AMCNTENSET0() // =================== // System register write to AMCNTENSET0. func Write_AMCNTENSET0(value_in : bits(32)) begin AMCNTENSET0().P = AMCNTENSET0().P OR value_in[0 +: NUM_AMU_CG0_MONITORS]; end;

Library pseudocode for shared/debug/amu/Write_AMCNTENSET0_EL0

// Write_AMCNTENSET0_EL0() // ======================= // System register write to AMCNTENSET0_EL0. func Write_AMCNTENSET0_EL0(value_in : bits(64)) begin AMCNTENSET0_EL0().P = AMCNTENSET0_EL0().P OR value_in[0 +: NUM_AMU_CG0_MONITORS]; end;

Library pseudocode for shared/debug/amu/Write_AMCNTENSET1

// Write_AMCNTENSET1() // =================== // System register write to AMCNTENSET1. func Write_AMCNTENSET1(value_in : bits(32)) begin assert NUM_AMU_CG1_MONITORS <= 16; let implemented : bits(16) = G1ActivityMonitorImplementedMask(); AMCNTENSET1().P = (AMCNTENSET1().P OR (ZeroExtend{16}(value_in[0 +: NUM_AMU_CG1_MONITORS]) AND implemented)); end;

Library pseudocode for shared/debug/amu/Write_AMCNTENSET1_EL0

// Write_AMCNTENSET1_EL0() // ======================= // System register write to AMCNTENSET1_EL0. func Write_AMCNTENSET1_EL0(value_in : bits(64)) begin assert NUM_AMU_CG1_MONITORS <= 16; let implemented : bits(16) = G1ActivityMonitorImplementedMask(); AMCNTENSET1_EL0().P = (AMCNTENSET1_EL0().P OR (ZeroExtend{16}(value_in[0 +: NUM_AMU_CG1_MONITORS]) AND implemented)); end;

Library pseudocode for shared/debug/claim

var DBGClaimTags : bits(8);

Library pseudocode for shared/debug/claim/Write_DBGCLAIMCLR

// Write_DBGCLAIMCLR() // =================== // System register write to DBGCLAIMCLR. func Write_DBGCLAIMCLR(value_in : bits(32)) begin DBGClaimTags = DBGClaimTags AND NOT value_in[7:0]; end;

Library pseudocode for shared/debug/claim/Write_DBGCLAIMCLR_EL1

// Write_DBGCLAIMCLR_EL1() // ======================= // System register write to DBGCLAIMCLR_EL1. func Write_DBGCLAIMCLR_EL1(value_in : bits(64)) begin DBGClaimTags = DBGClaimTags AND NOT value_in[7:0]; end;

Library pseudocode for shared/debug/claim/Write_DBGCLAIMSET

// Write_DBGCLAIMSET() // =================== // System register write to DBGCLAIMSET. func Write_DBGCLAIMSET(value_in : bits(32)) begin DBGClaimTags = DBGClaimTags OR value_in[7:0]; end;

Library pseudocode for shared/debug/claim/Write_DBGCLAIMSET_EL1

// Write_DBGCLAIMSET_EL1() // ======================= // System register write to DBGCLAIMSET_EL1. func Write_DBGCLAIMSET_EL1(value_in : bits(64)) begin DBGClaimTags = DBGClaimTags OR value_in[7:0]; end;

Library pseudocode for shared/debug/cti/CrossTrigger

// CrossTrigger // ============ type CrossTriggerOut of enumeration {CrossTriggerOut_DebugRequest, CrossTriggerOut_RestartRequest, CrossTriggerOut_IRQ, CrossTriggerOut_RSVD3, CrossTriggerOut_TraceExtIn0, CrossTriggerOut_TraceExtIn1, CrossTriggerOut_TraceExtIn2, CrossTriggerOut_TraceExtIn3}; type CrossTriggerIn of enumeration {CrossTriggerIn_CrossHalt, CrossTriggerIn_PMUOverflow, CrossTriggerIn_SPESample, CrossTriggerIn_RSVD3, CrossTriggerIn_TraceExtOut0, CrossTriggerIn_TraceExtOut1, CrossTriggerIn_TraceExtOut2, CrossTriggerIn_TraceExtOut3, CrossTriggerIn_TRBEStop, CrossTriggerIn_TRBEMgmt, CrossTriggerIn_TRBEWrap}; varCrossTriggerIn_TRBEWrap}; CTIClaimTags : bits(32);

Library pseudocode for shared/debug/pmu/Write_PMCNTENCLR

// Write_PMCNTENCLR() // ================== // System register write to PMCNTENCLR. func Write_PMCNTENCLR(value_in : bits(32)) begin let write_mask : bits(32) = GetPMUWriteMask(FALSE)[31:0]; PMCNTENCLR() = PMCNTENCLR() AND NOT (value_in AND write_mask); end;

Library pseudocode for shared/debug/pmu/Write_PMCNTENCLR_EL0

// Write_PMCNTENCLR_EL0() // ====================== // System register write to PMCNTENCLR_EL0. func Write_PMCNTENCLR_EL0(value_in : bits(64)) begin let write_mask : bits(64) = GetPMUWriteMask(FALSE); PMCNTENCLR_EL0() = PMCNTENCLR_EL0() AND NOT (value_in AND write_mask); end;

Library pseudocode for shared/debug/pmu/Write_PMCNTENSET

// Write_PMCNTENSET() // ================== // System register write to PMCNTENSET. func Write_PMCNTENSET(value_in : bits(32)) begin let write_mask : bits(32) = GetPMUWriteMask(FALSE)[31:0]; PMCNTENSET() = PMCNTENSET() OR (value_in AND write_mask); end;

Library pseudocode for shared/debug/pmu/Write_PMCNTENSET_EL0

// Write_PMCNTENSET_EL0() // ====================== // System register write to PMCNTENSET_EL0. func Write_PMCNTENSET_EL0(value_in : bits(64)) begin let write_mask : bits(64) = GetPMUWriteMask(FALSE); PMCNTENSET_EL0() = PMCNTENSET_EL0() OR (value_in AND write_mask); end;

Library pseudocode for shared/debug/pmu/Write_PMINTENCLR

// Write_PMINTENCLR() // ================== // System register write to PMINTENCLR. func Write_PMINTENCLR(value_in : bits(32)) begin let write_mask : bits(32) = GetPMUWriteMask(FALSE)[31:0]; PMINTENCLR() = PMINTENCLR() AND NOT (value_in AND write_mask); end;

Library pseudocode for shared/debug/pmu/Write_PMINTENCLR_EL1

// Write_PMINTENCLR_EL1() // ====================== // System register write to PMINTENCLR_EL1. func Write_PMINTENCLR_EL1(value_in : bits(64)) begin let write_mask : bits(64) = GetPMUWriteMask(FALSE); PMINTENCLR_EL1() = PMINTENCLR_EL1() AND NOT (value_in AND write_mask); end;

Library pseudocode for shared/debug/pmu/Write_PMINTENSET

// Write_PMINTENSET() // ================== // System register write to PMINTENSET. func Write_PMINTENSET(value_in : bits(32)) begin let write_mask : bits(32) = GetPMUWriteMask(FALSE)[31:0]; PMINTENSET() = PMINTENSET() OR (value_in AND write_mask); end;

Library pseudocode for shared/debug/pmu/Write_PMINTENSET_EL1

// Write_PMINTENSET_EL1() // ====================== // System register write to PMINTENSET_EL1. func Write_PMINTENSET_EL1(value_in : bits(64)) begin let write_mask : bits(64) = GetPMUWriteMask(FALSE); PMINTENSET_EL1() = PMINTENSET_EL1() OR (value_in AND write_mask); end;

Library pseudocode for shared/debug/pmu/Write_PMOVSCLR_EL0

// Write_PMOVSCLR_EL0() // ==================== // System register write to PMOVSCLR_EL0. func Write_PMOVSCLR_EL0(value_in : bits(64)) begin let write_mask : bits(64) = GetPMUWriteMask(FALSE); PMOVSCLR_EL0() = PMOVSCLR_EL0() AND NOT (value_in AND write_mask); end;

Library pseudocode for shared/debug/pmu/Write_PMOVSR

// Write_PMOVSR() // ============== // System register write to PMOVSR. func Write_PMOVSR(value_in : bits(32)) begin let write_mask : bits(32) = GetPMUWriteMask(FALSE)[31:0]; PMOVSR() = PMOVSR() AND NOT (value_in AND write_mask); end;

Library pseudocode for shared/debug/pmu/Write_PMOVSSET

// Write_PMOVSSET() // ================ // System register write to PMOVSSET. func Write_PMOVSSET(value_in : bits(32)) begin let write_mask : bits(32) = GetPMUWriteMask(FALSE)[31:0]; PMOVSSET() = PMOVSSET() OR (value_in AND write_mask); end;

Library pseudocode for shared/debug/pmu/Write_PMOVSSET_EL0

// Write_PMOVSSET_EL0() // ==================== // System register write to PMOVSSET_EL0. func Write_PMOVSSET_EL0(value_in : bits(64)) begin let write_mask : bits(64) = GetPMUWriteMask(FALSE); PMOVSSET_EL0() = PMOVSSET_EL0() OR (value_in AND write_mask); end;

Library pseudocode for shared/debug/samplebasedprofiling/Read_EDPCSRlo

// Read_EDPCSRlo() // =============== func Read_EDPCSRlo(memory_mapped : boolean) => bits(32) begin // The Software lock is OPTIONAL. let update : boolean = !memory_mapped || EDLSR().SLK == '0';// Software locked: no side-effects var sample : bits(32); if pc_sample.valid then sample = pc_sample.pc[31:0]; if update then if IsFeatureImplemented(FEAT_VHE) && EDSCR().SC2 == '1' then EDPCSR().SC2_1.EDPCSRhi = (if EDPCSRhi.PC = (if pc_sample.rw == '0' then Zeros{24} else pc_sample.pc[55:32]); EDPCSR().EL = EDPCSRhi.EL = pc_sample.el; EDPCSR().NS = (if EDPCSRhi.NS = (if pc_sample.ss == SS_Secure then '0' else '1'); else EDPCSR().SC2_0.EDPCSRhi = (if EDPCSRhi = (if pc_sample.rw == '0' then Zeros{32} else pc_sample.pc[63:32]); end; EDCIDSR() = pc_sample.contextidr; if ((IsFeatureImplemented(FEAT_VHE) || IsFeatureImplemented(FEAT_Debugv8p2)) && EDSCR().SC2 == '1') then EDVIDSR() = (if pc_sample.has_el2 then pc_sample.contextidr_el2 else ARBITRARY : bits(32)); else EDVIDSR().VMID = (if pc_sample.has_el2 && pc_sample.el IN {EL1,EL0} then pc_sample.vmid else Zeros{NUM_VMIDBITS}); EDVIDSR().NS = (if pc_sample.ss == SS_Secure then '0' else '1'); EDVIDSR().E2 = (if pc_sample.el == EL2 then '1' else '0'); EDVIDSR().E3 = (if pc_sample.el == EL3 then '1' else '0') AND pc_sample.rw; // The conditions for setting HV are not specified if PCSRhi is zero. // An example implementation may be "pc_sample.rw". EDVIDSR().HV = (if !IsZero(EDPCSR().SC2_0.EDPCSRhi) then '1' EDVIDSR().HV = (if !IsZero(EDPCSRhi) then '1' else ImpDefBit("0 or 1")); end; end; else sample = Ones{32}; if update then EDPCSR()[63:32] = ARBITRARY : bits(32); EDPCSRhi = ARBITRARY : bits(32); EDCIDSR() = ARBITRARY : bits(32); EDVIDSR() = ARBITRARY : bits(32); end; end; return sample; end;

Library pseudocode for shared/exceptions/aborts/EffectiveNMEA

// EffectiveNMEA() // =============== // Returns the Effective value of SCR_EL3.NMEA or SCTLR2_ELx.NMEA. // Return the Effective value of SCR_EL3.NMEA or SCTLR2_ELx.NMEA. func EffectiveNMEA(el : bits(2)) => bit EffectiveNMEA() => bit begin if IsFeatureImplemented(FEAT_DoubleFault2) then if el == if PSTATE.EL == EL3 && !ELUsingAArch32UsingAArch32(() then return SCR_EL3().NMEA; elsif (EL3PSTATE) then return.EL == EffectiveSCR_EL3_NMEA(); elsif (el == EL2 || (el ==|| EL0IsInHost &&()) && ! ELIsInHost(el))) && !ELUsingAArch32(EL2) then return (if IsSCTLR2EL2Enabled() then SCTLR2_EL2().NMEA else '0'); elsif (el == elsif ! EL1 || (el == EL0 && !ELIsInHost(el))) && !ELUsingAArch32(EL1) then return (if IsSCTLR2EL1Enabled() then SCTLR2_EL1().NMEA else '0'); else return '0'; end; end; if IsFeatureImplemented(FEAT_DoubleFault) && el == elsif IsFeatureImplemented(FEAT_DoubleFault) && PSTATE.EL == EL3 && !ELUsingAArch32UsingAArch32(() then return SCR_EL3().NMEA ANDEL3EffectiveEA) then return EffectiveSCR_EL3_NMEA(); else return '0'; end; end;

Library pseudocode for shared/exceptions/aborts/PhysicalSErrorTarget

// PhysicalSErrorTarget() // ====================== // Returns a tuple of whether SError exception can be taken and, if so, the // target Exception level. // If EL3 is implemented and using AArch32, then a target Exception level of // EL1 means Abort mode, and EL3 means Monitor mode, including in Secure // state when Abort mode is part of EL3. func PhysicalSErrorTarget() => (boolean, bits(2)) begin if Halted() then return (TRUE, ARBITRARY : bits(2)); end; let effective_ea : bit = EffectiveEA(); let effective_amo : bit = EffectiveHCR_AMO(); let effective_tge : bit = EffectiveTGE(); let effective_nmea : bit = EffectiveNMEA((); // When EL3 is implemented and using AArch32, the SCR.AW bit can allow PSTATE.A // to mask SError exceptions in Non-secure state when SCR.EA is 1 and the Effective // value of HCR.AMO is 0. var effective_aw : bit; if (PSTATE.EL); // When EL3 is implemented and using AArch32, the SCR.AW bit can allow PSTATE.A // to mask SError exceptions in Non-secure state when SCR.EA is 1 and the Effective // value of HCR.AMO is 0. var effective_aw : bit; if (ELUsingAArch32(EL3) && effective_ea == '1' && CurrentSecurityState() == SS_NonSecure && effective_amo == '0') then effective_aw = SCR().AW; else effective_aw = '0'; end; // The exception is masked by software. var masked : boolean; case PSTATE.EL of when EL3 => masked = (!UsingAArch32() && effective_ea == '0') || PSTATE.A == '1'; when EL2 => masked = ((effective_ea == '0' || effective_aw == '1') && ((!UsingAArch32() && effective_tge == '0' && effective_amo == '0') || PSTATE.A == '1')); when EL1, EL0 => masked = ((effective_ea == '0' || effective_aw == '1') && effective_amo == '0' && PSTATE.A == '1'); end; // When FEAT_DoubleFault or FEAT_DoubleFault2 is implemented, the mask might be overridden. masked = (masked && effective_nmea == '0'); // External debug might disable the exception in the current Security state. // This is not relevant at EL3. let intdis : boolean = PSTATE.EL != EL3 && ExternalDebugInterruptsDisabled(EL1); var target_el : bits(2) = ARBITRARY : bits(2); if effective_ea == '1' || (PSTATE.EL == EL3 && !ELUsingAArch32(EL3)) then if !masked then target_el = EL3; end; elsif EL2Enabled() && effective_amo == '1' && !intdis && PSTATE.EL IN {EL0, EL1} then target_el = EL2; masked = FALSE; elsif (EffectiveHCRX_EL2_TMEA() == '1' && !intdis && ((PSTATE.EL == EL1 && PSTATE.A == '1') || (PSTATE.EL == EL0 && masked && !IsInHost()))) then target_el = EL2; masked = FALSE; elsif (EffectiveSCR_EL3_TMEA() == '1' && ((PSTATE.EL IN {EL2, EL1} && PSTATE.A == '1') || (PSTATE.EL IN {EL2, EL0} && masked) || intdis)) then target_el = EL3; masked = FALSE; elsif PSTATE.EL == EL2 || IsInHost() then if !masked then target_el = EL2; end; else assert (PSTATE.EL == EL1 || (PSTATE.EL == EL3 && ELUsingAArch32(EL3)) || (PSTATE.EL == EL0 && !IsInHost())); if !masked then target_el = EL1; end; end; // External debug might disable the exception for the target Exception level. if !masked && ExternalDebugInterruptsDisabled(target_el) then masked = TRUE; target_el = ARBITRARY : bits(2); end; return (masked, target_el); end;

Library pseudocode for shared/exceptions/exceptions/Exception

// Exception // ========= // Classes of exception. type Exception of enumeration { Exception_Uncategorized, // Uncategorized or unknown reason Exception_WFxTrap, // Trapped WFI or WFE instruction Exception_CP15RTTrap, // Trapped AArch32 MCR or MRC access, coproc=0b111 Exception_CP15RRTTrap, // Trapped AArch32 MCRR or MRRC access, coproc=0b1111 Exception_CP14RTTrap, // Trapped AArch32 MCR or MRC access, coproc=0b1110 Exception_CP14DTTrap, // Trapped AArch32 LDC or STC access, coproc=0b1110 Exception_CP14RRTTrap, // Trapped AArch32 MRRC access, coproc=0b1110 Exception_AdvSIMDFPAccessTrap, // HCPTR-trapped access to SIMD or FP Exception_FPIDTrap, // Trapped access to SIMD or FP ID register Exception_OtherTrap, // Trapped access to other instructions // Trapped BXJ instruction not supported in Armv8 Exception_PACTrap, // Trapped invalid PAC use Exception_IllegalState, // Illegal Execution state Exception_SupervisorCall, // Supervisor Call Exception_HypervisorCall, // Hypervisor Call Exception_MonitorCall, // Monitor Call or Trapped SMC instruction Exception_SystemRegisterTrap, // Trapped MRS or MSR System register access Exception_ERetTrap, // Trapped invalid ERET use Exception_InstructionAbort, // Instruction Abort or Prefetch Abort Exception_PCAlignment, // PC alignment fault Exception_DataAbort, // Data Abort Exception_NV2DataAbort, // Data abort at EL1 reported as being from EL2 Exception_PACFail, // PAC Authentication failure Exception_SPAlignment, // SP alignment fault Exception_FPTrappedException, // IEEE trapped FP exception Exception_SError, // SError interrupt Exception_Breakpoint, // (Hardware) Breakpoint Exception_SoftwareStep, // Software Step Exception_Watchpoint, // Watchpoint Exception_NV2Watchpoint, // Watchpoint at EL1 reported as being from EL2 Exception_SoftwareBreakpoint, // Software Breakpoint Instruction Exception_VectorCatch, // AArch32 Vector Catch Exception_IRQ, // IRQ interrupt Exception_SVEAccessTrap, // HCPTR trapped access to SVE Exception_SMEAccessTrap, // HCPTR trapped access to SME Exception_GPC, // Granule protection check Exception_BranchTarget, // Branch Target Identification Exception_MemCpyMemSet, // Exception from a CPY* or SET* instruction Exception_GCSFail, // GCS Exceptions Exception_Profiling, // Profiling exception Exception_SystemRegister128Trap, // Trapped MRRS or MSRR System register or SYSP access Exception_ConditionalFault, // Exception due to a CFLT instructionException_FIQ}; // FIQ interrupt Exception_FIQ}; // FIQ interrupt

Library pseudocode for shared/functions/common/IsZeroBit

// IsZeroBit() // =========== pure func IsZeroBit{N}(x : bits(N)) => bit begin return if IsZero(x) then '1' else '0'; end;funcIsZeroBit{N}(x : bits(N)) => bit begin return if IsZero(x) then '1' else '0'; end;

Library pseudocode for shared/functions/common/NormalizeReal

// NormalizeReal // ============= // Normalizes x to the form 1.xxx... x 2^y and returns (mantissa, exponent) pure func NormalizeReal(x : real) => (real, integer) begin let exponent : integer = ILog2(x); let mantissa : real = x / (2.0 ^ exponent); return (mantissa, exponent); end;funcNormalizeReal(x : real) => (real, integer) begin let exponent : integer = ILog2(x); let mantissa : real = x / (2.0 ^ exponent); return (mantissa, exponent); end;

Library pseudocode for shared/functions/common/RShr

// RShr() // ====== // Shift integer value right with rounding pure func RShr(value : integer, shift : integer, round : boolean) => integer begin assert shift > 0; if round then return (value + (1 << (shift - 1))) >> shift; else return value >> shift; end; end;funcRShr(value : integer, shift : integer, round : boolean) => integer begin assert shift > 0; if round then return (value + (1 << (shift - 1))) >> shift; else return value >> shift; end; end;

Library pseudocode for shared/functions/float/fpexceptrapsenabled/FPExcepTrapsEnabled

// FPExcepTrapsEnabled() // ===================== func FPExcepTrapsEnabled() => boolean begin return (ImpDefBool("IMPLEMENTED_trapping of Input Denormal floating-point exceptions") || ImpDefBool("IMPLEMENTED_trapping of Inexact floating-point exceptions") || ImpDefBool("IMPLEMENTED_trapping of Underflow floating-point exceptions") || ImpDefBool("IMPLEMENTED_trapping of Overflow floating-point exceptions") || ImpDefBool("IMPLEMENTED_trapping of Divide by Zero floating-point exceptions") || ImpDefBool("IMPLEMENTED_trapping of Invalid Operation floating-point exceptions")); end;

Library pseudocode for shared/functions/float/fpprocessexception/FPProcessExceptionLibrary pseudocode for shared/functions/float/fpprocessdenorms/FPProcessDenorms4

// FPProcessException() // ==================== // // The 'fpcr' argument supplies FPCR control bits. Status information is // updated directly in the FPSR where appropriate. // FPProcessDenorms4() // =================== // Handles denormal input in case of single-precision or double-precision // when using alternative floating-point mode. func FPProcessException(except :FPProcessDenorms4(type1 : FPExcFPType, fpcr : FPCR_Type) begin var cumul : integer; // Determine the cumulative exception bit number case except of when, type2 : FPExc_InvalidOpFPType => cumul = 0; when, type3 : FPExc_DivideByZeroFPType => cumul = 1; when, type4 : FPExc_OverflowFPType => cumul = 2; when, N : integer, fpcr : FPCR_Type) begin let altfp : boolean = IsFeatureImplemented(FEAT_AFP) && ! FPExc_UnderflowUsingAArch32 => cumul = 3; when() && fpcr.AH == '1'; if altfp && N != 16 && (type1 == FPExc_InexactFPType_Denormal => cumul = 4; when|| type2 == FPExc_InputDenormFPType_Denormal => cumul = 7; end; // When FEAT_TRAPFPE is implemented, the control bits FPCR.{IDE, IXE, UFE, OFE, DZE, IOE} // can be independently set to 1. // Otherwise when FEAT_TRAPFPE is not implemented, bits FPCR.{IDE, IXE, UFE, OFE, DZE, IOE} // are RAZ/WI. let enable : integer = cumul + 8; if (fpcr[enable] == '1' && (!IsFeatureImplemented(FEAT_SME) |||| type3 == PSTATEFPType_Denormal.SM == '0' |||| type4 == IsFullA64EnabledFPType_Denormal())) then // Trapping of the exception enabled. // It is IMPLEMENTATION DEFINED how exceptions and in what order that they may be // accumulated before calling FPTrappedException(). var accumulated_exceptions : bits(8) =) then GetAccumulatedFPExceptionsFPProcessException(); accumulated_exceptions[cumul] = '1'; if !ImpDefBool("Accumulate floating-point exceptions before trapping") then if( UsingAArch32FPExc_InputDenorm() then AArch32_FPTrappedException(accumulated_exceptions); else let is_ase : boolean = IsASEInstruction(); AArch64_FPTrappedException(is_ase, accumulated_exceptions); end; else // The exceptions generated by this instruction are accumulated by the PE and // FPTrappedException is called later during its execution, before the next // instruction is executed. This field is cleared at the start of each FP instruction. SetAccumulatedFPExceptions(accumulated_exceptions); end; elsif UsingAArch32() then // Set the cumulative exception bit FPSCR()[cumul] = '1'; else // Set the cumulative exception bit FPSR()[cumul] = '1'; , fpcr); end; return; end;

Library pseudocode for shared/functions/float/fpprocessexception/FPProcessException

// FPProcessException() // ==================== // // The 'fpcr' argument supplies FPCR control bits. Status information is // updated directly in the FPSR where appropriate. func FPProcessException(except : FPExc, fpcr : FPCR_Type) begin var cumul : integer; // Determine the cumulative exception bit number case except of when FPExc_InvalidOp => cumul = 0; when FPExc_DivideByZero => cumul = 1; when FPExc_Overflow => cumul = 2; when FPExc_Underflow => cumul = 3; when FPExc_Inexact => cumul = 4; when FPExc_InputDenorm => cumul = 7; end; let enable : integer = cumul + 8; if (fpcr[enable] == '1' && (!IsFeatureImplemented(FEAT_SME) || PSTATE.SM == '0' || IsFullA64Enabled())) then // Trapping of the exception enabled. // It is IMPLEMENTATION DEFINED whether the enable bit may be set at all, // and if so then how exceptions and in what order that they may be // accumulated before calling FPTrappedException(). var accumulated_exceptions : bits(8) = GetAccumulatedFPExceptions(); accumulated_exceptions[cumul] = '1'; if ImpDefBool("Support trapping of floating-point exceptions") then if UsingAArch32() then AArch32_FPTrappedException(accumulated_exceptions); else let is_ase : boolean = IsASEInstruction(); AArch64_FPTrappedException(is_ase, accumulated_exceptions); end; else // The exceptions generated by this instruction are accumulated by the PE and // FPTrappedException is called later during its execution, before the next // instruction is executed. This field is cleared at the start of each FP instruction. SetAccumulatedFPExceptions(accumulated_exceptions); end; elsif UsingAArch32() then // Set the cumulative exception bit FPSCR()[cumul] = '1'; else // Set the cumulative exception bit FPSR()[cumul] = '1'; end; return; end;

Library pseudocode for shared/functions/float/fpunpack/FPUnpackBase

// FPUnpackBase() // ============== func FPUnpackBase{N}(fpval : bits(N), fpcr : FPCR_Type, fpexc : boolean) => (FPType, bit, real) begin let isbfloat16 : boolean = FALSE; let (fp_type, sign, value) = FPUnpackBase{N}(fpval, fpcr, fpexc, isbfloat16); return (fp_type, sign, value); end; // FPUnpackBase() // ============== // // Unpack a floating-point number into its type, sign bit and the real number // that it represents. The real number result has the correct sign for numbers // and infinities, is very large in magnitude for infinities, and is 0.0 for // NaNs. (These values are chosen to simplify the description of comparisons // and conversions.) // // The 'fpcr_in' argument supplies FPCR control bits, 'fpexc' controls the // generation of floating-point exceptions and 'isbfloat16' determines whether // N=16 signifies BFloat16 or half-precision type. Status information is updated // directly in the FPSR where appropriate. func FPUnpackBase{N}(fpval : bits(N), fpcr_in : FPCR_Type, fpexc : boolean, isbfloat16 : boolean) => (FPType, bit, real) begin assert N IN {16,32,64}; let fpcr : FPCR_Type = fpcr_in; let altfp : boolean = IsFeatureImplemented(FEAT_AFP) && !UsingAArch32(); let fiz : boolean = altfp && fpcr.FIZ == '1'; let fz : boolean = fpcr.FZ == '1' && !(altfp && fpcr.AH == '1'); var value : real; var sign : bit; var fptype : FPType; if N == 16 && !isbfloat16 then sign = fpval[15]; let exp16 : bits(5) = fpval[14:10]; let frac16 : bits(10) = fpval[9:0]; if IsZero(exp16) then if IsZero(frac16) || fpcr.FZ16 == '1' then fptype = FPType_Zero; value = 0.0; else fptype = FPType_Denormal; value = 2.0^-14 * (Real(UInt(frac16)) * 2.0^-10); end; elsif IsOnes(exp16) && fpcr.AHP == '0' then // Infinity or NaN in IEEE format if IsZero(frac16) then fptype = FPType_Infinity; value = 2.0^1000000; else fptype = if frac16[9] == '1' then FPType_QNaN else FPType_SNaN; value = 0.0; end; else fptype = FPType_Nonzero; value = 2.0^(UInt(exp16)-15) * (1.0 + Real(UInt(frac16)) * 2.0^-10); end; elsif N == 32 || isbfloat16 then var exp32 : bits(8); var frac32 : bits(23); if isbfloat16 then sign = fpval[15]; exp32 = fpval[14:7]; frac32 = fpval[6:0] :: Zeros{16}; else sign = fpval[31]; exp32 = fpval[30:23]; frac32 = fpval[22:0]; end; if IsZero(exp32) then if IsZero(frac32) then // Produce zero if value is zero. fptype = FPType_Zero; value = 0.0; elsif fz || fiz then // Flush-to-zero if FIZ==1 or AH,FZ==01 fptype = FPType_Zero; value = 0.0; // Check whether to generate Input Denormal floating-point exception. // fpcr.FIZ==1 does not generate Input Denormal exception. // Check whether to raise Input Denormal floating-point exception. // fpcr.FIZ==1 does not raise Input Denormal exception. if fz then // Denormalized input flushed to zero if fpexc then FPProcessException(FPExc_InputDenorm, fpcr); end; end; else fptype = FPType_Denormal; value = 2.0^-126 * (Real(UInt(frac32)) * 2.0^-23); end; elsif IsOnes(exp32) then if IsZero(frac32) then fptype = FPType_Infinity; value = 2.0^1000000; else fptype = if frac32[22] == '1' then FPType_QNaN else FPType_SNaN; value = 0.0; end; else fptype = FPType_Nonzero; value = 2.0^(UInt(exp32)-127) * (1.0 + Real(UInt(frac32)) * 2.0^-23); end; else // N == 64 sign = fpval[63]; let exp64 : bits(11) = fpval[62:52]; let frac64 : bits(52) = fpval[51:0]; if IsZero(exp64) then if IsZero(frac64) then // Produce zero if value is zero. fptype = FPType_Zero; value = 0.0; elsif fz || fiz then // Flush-to-zero if FIZ==1 or AH,FZ==01 fptype = FPType_Zero; value = 0.0; // Check whether to generate Input Denormal floating-point exception. // fpcr.FIZ==1 does not generate Input Denormal exception. // Check whether to raise Input Denormal floating-point exception. // fpcr.FIZ==1 does not raise Input Denormal exception. if fz then // Denormalized input flushed to zero if fpexc then FPProcessException(FPExc_InputDenorm, fpcr); end; end; else fptype = FPType_Denormal; value = 2.0^-1022 * (Real(UInt(frac64)) * 2.0^-52); end; elsif IsOnes(exp64) then if IsZero(frac64) then fptype = FPType_Infinity; value = 2.0^1000000; else fptype = if frac64[51] == '1' then FPType_QNaN else FPType_SNaN; value = 0.0; end; else fptype = FPType_Nonzero; value = 2.0^(UInt(exp64)-1023) * (1.0 + Real(UInt(frac64)) * 2.0^-52); end; end; if sign == '1' then value = -value; end; return (fptype, sign, value); end;

Library pseudocode for shared/functions/impdef/ImpDef

// ImpDef() // ======== // IMPLEMENTATION DEFINED behavior identified by the string parameter. impdef func ImpDef(x : string) begin return; end;

Library pseudocode for shared/functions/impdef/ImpDefBit

// ImpDefBit() // =========== // Return an IMPLEMENTATION DEFINED bit value identified by the string parameter. readonly impdef func ImpDefBit(x : string) => bit begin return ARBITRARY : bit; end;

Library pseudocode for shared/functions/impdef/ImpDefBits

// ImpDefBits() // ============ // Return an IMPLEMENTATION DEFINED value of bits identified by the string parameter. readonly impdef func ImpDefBits{N}(x : string) => bits(N) begin return ARBITRARY : bits(N); end;

Library pseudocode for shared/functions/impdef/ImpDefBool

// ImpDefBool() // ============ // Return an IMPLEMENTATION DEFINED boolean value identified by the string parameter. readonly impdef func ImpDefBool(x : string) => boolean begin return ARBITRARY : boolean; end;

Library pseudocode for shared/functions/impdef/ImpDefInt

// ImpDefInt() // =========== // Return an IMPLEMENTATION DEFINED integer value identified by the string parameter. readonly impdef func ImpDefInt(x : string) => integer begin return ARBITRARY : integer; end; type UnimplementedException of exception{-};

Library pseudocode for shared/functions/impdef/Unimplemented

// Unimplemented() // =============== // Behavior that is not implemented by this pseudocode. noreturn impdef func Unimplemented() begin throw UnimplementedException{-}; end;

Library pseudocode for shared/functions/memory/CreateAccDescLS64

// CreateAccDescLS64() // =================== // Access descriptor for accelerator-supporting memory accesses func CreateAccDescLS64(memop : MemOp, withstatus : boolean, acqrel : boolean, , withstatus : boolean, tagchecked : boolean) => AccessDescriptor begin var accdesc : AccessDescriptor = NewAccDesc(AccessType_GPR); accdesc.read = memop == MemOp_LOAD; accdesc.write = memop == MemOp_STORE; accdesc.acqsc = memop == accdesc.pan = TRUE; accdesc.ls64 = TRUE; accdesc.withstatus = withstatus; accdesc.tagchecked = tagchecked; return accdesc; end; MemOp_LOAD && acqrel; accdesc.relsc = memop == MemOp_STORE && acqrel; accdesc.pan = TRUE; accdesc.ls64 = TRUE; accdesc.withstatus = withstatus; accdesc.tagchecked = tagchecked; return accdesc; end;

Library pseudocode for shared/functions/mpam/GenMPAMTRBE

// GenMPAMTRBE() // ============= // Returns MPAMinfo for Trace Buffer Unit in external mode. func GenMPAMTRBE() => MPAMinfo begin assert !SelfHostedTraceEnabled(); var pspace : PARTIDSpaceType; if IsFeatureImplemented(FEAT_MPAMv2) then if !IsFeatureImplemented(FEAT_TRBE_MPAM) || TRBMPAM_EL1().EN == '0' then return DefaultMPAMInfo(); end; else case TRBMAR_EL1().PAS of when '00' => pspace = PIDSpace_Secure; when '01' => pspace = PIDSpace_NonSecure; when '10' => pspace = PIDSpace_Root; when '11' => pspace = PIDSpace_Realm; end; if !IsFeatureImplemented(FEAT_TRBE_MPAM) || TRBMPAM_EL1().EN == '0' then return DefaultMPAMInfo(pspace); end; end; assert IsFeatureImplemented(FEAT_TRBE_MPAM); var mpaminfo : MPAMinfo; if !IsFeatureImplemented(FEAT_MPAMv2) then mpaminfo.mpam_sp = pspace; end; mpaminfo.partid = (if IsFeatureImplemented(FEAT_MPAMv2) then TRBMPAM_EL1().MPAMv2.PARTID else TRBMPAM_EL1().MPAMv0or1px.PARTID); mpaminfo.partid = TRBMPAM_EL1().PARTID; var partid_out_of_range : boolean = FALSE; // When the PARTID is out-of-range, the behavior is a CONSTRAINED UNPREDICTABLE choice of: // - Replace the out-of-range PARTID with any in-range PARTID // - Replace the out-of-range PARTID with the default PARTID let partid_max : integer = if UInt(mpaminfo.partid) > UInt(MPAMIDR_EL1().PARTID_MAX) then partid_out_of_range = TRUE; var c : GetMPAM_PARTID_MAX(); if UInt(mpaminfo.partid) > partid_max then partid_out_of_range = TRUE; var c : Constraint; var partid : integer; (c, partid) = ConstrainUnpredictableInteger(0, partid_max,(0, UInt(MPAMIDR_EL1().PARTID_MAX), Unpredictable_OUT_OF_RANGE_ID); assert c IN {Constraint_DEFAULT_ID, Constraint_ANY_ID}; case c of when Constraint_DEFAULT_ID => mpaminfo.partid = DEFAULT_PARTID; when Constraint_ANY_ID => mpaminfo.partid = partid[15:0]; end; end; if partid_out_of_range && ConstrainUnpredictableBool(Unpredictable_USE_DEFAULT_PMG) then mpaminfo.pmg = DEFAULT_PMG; else mpaminfo.pmg = (if IsFeatureImplemented(FEAT_MPAMv2) then TRBMPAM_EL1().MPAMv2.PMG else ZeroExtend{16}(TRBMPAM_EL1().MPAMv0or1px.PMG)); end; let pmg_max : integer = GetMPAM_PMG_MAX(); if UInt(mpaminfo.pmg) > pmg_max then ; else mpaminfo.pmg = TRBMPAM_EL1().PMG; end; if UInt(mpaminfo.pmg) > UInt(MPAMIDR_EL1().PMG_MAX) then var c : Constraint; var pmg : integer; (c, pmg) = ConstrainUnpredictableInteger(0, pmg_max,(0, UInt(MPAMIDR_EL1().PMG_MAX), Unpredictable_OUT_OF_RANGE_ID); assert c IN {Constraint_DEFAULT_ID, Constraint_ANY_ID}; case c of when Constraint_DEFAULT_ID => mpaminfo.pmg = DEFAULT_PMG; when Constraint_ANY_ID => mpaminfo.pmg = pmg[15:0]; end; end; return mpaminfo; end;

Library pseudocode for shared/functions/mpam/GenPARTID

// GenPARTID() // =========== // Returns physical PARTID and error boolean for Exception level el. // If mpamdata.sm is TRUE then PARTID is from MPAMSM_EL1. // If mpamdata.ind is TRUE and alternative ID is enabled then PARTID is from MPAMn_ELx.altPARTID. // Otherwise, the PARTID is from MPAMn_ELx. func GenPARTID(el : bits(2), mpamdata : MPAMdata) => (PARTIDType, boolean) begin var partidel : PARTIDType = GetMPAM_PARTID(el, mpamdata); var partid_err : boolean = FALSE; // When the PARTID is out-of-range, the behavior is a CONSTRAINED UNPREDICTABLE choice of: // When the PARTID is out-of-range, the behaviour is a CONSTRAINED UNPREDICTABLE choice of: // - Replace the out-of-range PARTID with any in-range PARTID // - Replace the out-of-range PARTID with the default PARTID if UInt(partidel) > if UInt(partidel) > UInt(MPAMIDR_EL1().PARTID_MAX) then var c : GetMPAM_PARTID_MAX() then var c : Constraint; var partid : integer; partid_err = TRUE; (c, partid) = ConstrainUnpredictableInteger(0, GetMPAM_PARTID_MAX(),(0, UInt(MPAMIDR_EL1().PARTID_MAX), Unpredictable_OUT_OF_RANGE_ID); assert c IN {Constraint_DEFAULT_ID, Constraint_ANY_ID}; case c of when Constraint_DEFAULT_ID => partidel = DEFAULT_PARTID; when Constraint_ANY_ID => partidel = partid[15:0]; end; end; if MPAMIsVirtual(el, mpamdata) then return MAP_vPARTID(partidel, partid_err); else return (partidel, partid_err); end; end;

Library pseudocode for shared/functions/mpam/GenPMG

// GenPMG() // ======== // Returns PMG for Exception level el. // if mpamdata.sm is TRUE then PMG is from MPAMSM_EL1. // If mpamdata.ind is TRUE and alternative id is enabled, then the PMG is from MPAMn_ELx.altPMG. // Otherwise, PMG is from MPAMn_ELx. // If PARTID generation (GenPARTID) encountered an error, GenPMG() should be // called with partid_err as TRUE. func GenPMG(el : bits(2), mpamdata : MPAMdata, partid_err : boolean) => PMGType begin if (!IsFeatureImplemented(FEAT_MPAMv2) && partid_err && ConstrainUnpredictableBool(Unpredictable_USE_DEFAULT_PMG)) then return DEFAULT_PMG; end; let groupel : PMGType = GetMPAM_PMG(el, mpamdata); let pmg_max : integer = if UInt(groupel) <= UInt(MPAMIDR_EL1().PMG_MAX) then return groupel; end; return GetMPAM_PMG_MAX(); if UInt(groupel) <= pmg_max then return groupel; end; return DEFAULT_PMG; end;

Library pseudocode for shared/functions/mpam/GetMPAM_PARTID_MAX

// GetMPAM_PARTID_MAX() // ==================== // Returns the maximum supported PARTID value for the implemented MPAM version. func GetMPAM_PARTID_MAX() => integer begin if IsFeatureImplemented(FEAT_MPAMv2) then return UInt(MPAMIDR_EL1().MPAMv2.PARTID_MAX); end; return UInt(MPAMIDR_EL1().MPAMv0or1px.PARTID_MAX); end;

Library pseudocode for shared/functions/mpam/GetMPAM_PMG_MAXLibrary pseudocode for shared/functions/mpam/MAP_vPARTID

// GetMPAM_PMG_MAX() // ================= // Returns the maximum supported PMG value for the implemented MPAM version. // MAP_vPARTID() // ============= // Performs conversion of virtual PARTID into physical PARTID // Contains all of the error checking and implementation // choices for the conversion. func GetMPAM_PMG_MAX() => integer begin if IsFeatureImplemented(FEAT_MPAMv2) then return UInt(MPAMIDR_EL1().MPAMv2.PMG_MAX); end; return UInt(MPAMIDR_EL1().MPAMv0or1px.PMG_MAX); end;MAP_vPARTID(vpartid :PARTIDType, partid_err : boolean) => (PARTIDType, boolean) begin // should not ever be called if EL2 is not implemented // or is implemented but not enabled in the current // security state. var ret : PARTIDType; var err : boolean = partid_err; var virt : integer = UInt(vpartid); // The largest vpartid supported let vpartid_max : integer = (UInt(MPAMIDR_EL1().VPMR_MAX) << 2) + 3; if virt > vpartid_max then let (c, vid) = ConstrainUnpredictableInteger(0, vpartid_max, Unpredictable_OUT_OF_RANGE_VID); assert c IN {Constraint_DEFAULT_ID, Constraint_ANY_ID}; case c of when Constraint_DEFAULT_ID => virt = UInt(DEFAULT_PARTID); when Constraint_ANY_ID => virt = vid; end; end; // Check for valid mapping entry. if MPAMVPMV_EL2()[virt] == '1' then // vpartid has a valid mapping, access the map. ret = mapvpmw(virt); // Check for default virtual PARTID valid elsif MPAMVPMV_EL2()[0] == '1' then // Use default mapping for vpartid == 0. ret = MPAMVPM0_EL2()[0 +: 16]; // Neither is valid, use default physical PARTID. else ret = DEFAULT_PARTID; err = TRUE; end; // Check that the physical PARTID is in-range. // This physical PARTID came from a virtual mapping entry. let partid_max : integer = UInt(MPAMIDR_EL1().PARTID_MAX); if UInt(ret) > partid_max then // Out of range, so return default physical PARTID ret = DEFAULT_PARTID; err = TRUE; end; return (ret, err); end;

Library pseudocode for shared/functions/mpam/MAP_vPARTID

// MAP_vPARTID() // ============= // Performs conversion of virtual PARTID into physical PARTID // Contains all of the error checking and implementation // choices for the conversion. func MAP_vPARTID(vpartid : PARTIDType, partid_err : boolean) => (PARTIDType, boolean) begin // should not ever be called if EL2 is not implemented // or is implemented but not enabled in the current // security state. var ret : PARTIDType; var err : boolean = partid_err; var virt : integer = UInt(vpartid); // The largest vpartid supported let vpartid_max : integer = (UInt(MPAMIDR_EL1().VPMR_MAX) << 2) + 3; if virt > vpartid_max then let (c, vid) = ConstrainUnpredictableInteger(0, vpartid_max, Unpredictable_OUT_OF_RANGE_VID); assert c IN {Constraint_DEFAULT_ID, Constraint_ANY_ID}; case c of when Constraint_DEFAULT_ID => virt = UInt(DEFAULT_PARTID); when Constraint_ANY_ID => virt = vid; end; end; // Check for valid mapping entry. if MPAMVPMV_EL2()[virt] == '1' then // vpartid has a valid mapping, access the map. ret = mapvpmw(virt); // Check for default virtual PARTID valid elsif MPAMVPMV_EL2()[0] == '1' then // Use default mapping for vpartid == 0. ret = MPAMVPM0_EL2()[0 +: 16]; // Neither is valid, use default physical PARTID. else ret = DEFAULT_PARTID; err = TRUE; end; // Check that the physical PARTID is in-range. // This physical PARTID came from a virtual mapping entry. let partid_max : integer = GetMPAM_PARTID_MAX(); if UInt(ret) > partid_max then // Out of range, so return default physical PARTID ret = DEFAULT_PARTID; err = TRUE; end; return (ret, err); end;

Library pseudocode for shared/functions/predictionrestrict/ASID

// ASID // ==== // Effective ASID. func ASID() => bits(NUM_ASIDBITS) begin if ELIsInHost(EL0) then var asid : bits(NUM_ASIDBITS); if TCR_EL2().A1 == '1' then asid = TTBR1_EL2().ASID; return TTBR1_EL2().ASID; else asid = TTBR0_EL2().ASID; end; if IsFeatureImplemented(FEAT_ASID16) && TCR_EL2().AS == '1' then return asid; else return ZeroExtend{NUM_ASIDBITS}(asid[7:0]); return TTBR0_EL2().ASID; end; end; if !ELUsingAArch32(EL1) then var asid : bits(NUM_ASIDBITS); if TCR_EL1().A1 == '1' then asid = TTBR1_EL1().ASID; return TTBR1_EL1().ASID; else asid = TTBR0_EL1().ASID; end; if IsFeatureImplemented(FEAT_ASID16) && TCR_EL1().AS == '1' then return asid; else return ZeroExtend{NUM_ASIDBITS}(asid[7:0]); return TTBR0_EL1().ASID; end; else if TTBCR().EAE == '0' then return ZeroExtend{NUM_ASIDBITS}(CONTEXTIDR().ASID); else if TTBCR().A1 == '1' then return ZeroExtend{NUM_ASIDBITS}(TTBR1().ASID); else return ZeroExtend{NUM_ASIDBITS}(TTBR0().ASID); end; end; end; end;

Library pseudocode for shared/functions/registers/UnimplementedIDRegister

// UnimplementedIDRegister() // ========================= // Trap access to unimplemented encodings in the feature ID register space. func UnimplementedIDRegister() begin if IsFeatureImplemented(FEAT_IDST) then if var target_el : bits(2) = EffectivelyAtEL0InHostPSTATE() ||.EL; if EffectivelyAtEL0NotInHostPSTATE() then.EL == AArch64_SystemAccessTraptoEL1orEL2EL0(0x18); elsethen target_el = if EL2Enabled() && HCR_EL2().TGE == '1' then EL2 else EL1; end; AArch64_SystemAccessTrap(PSTATE.EL, 0x18); end; (target_el, 0x18); end; Undefined(); end;

Library pseudocode for shared/functions/system/EffectiveHCR_EL2_TERRLibrary pseudocode for shared/functions/system/EffectiveSCR_EL3_ADEn

// EffectiveHCR_EL2_TERR() // EffectiveSCR_EL3_ADEn() // ======================= // Returns the Effective value of HCR_EL2().TERR. // Returns the Effective value of SCR_EL3().ADEn. readonly func EffectiveHCR_EL2_TERR() => bit EffectiveSCR_EL3_ADEn() => bit begin assert IsFeatureImplemented(FEAT_RAS); if ! assert !EL2Enabled() then return '0'; end; assert !ELUsingAArch32(); assert IsFeatureImplemented(FEAT_LS64_ACCDATA); if !HaveEL(EL3EL2EL3); ) then return '1'; end; if (NUM_ERROR_RECORDS == 0 && ImpDefBool("HCR_EL2.TERR,SCR_EL3.TERR/TWERR=0 when ERRIDR_EL1.NUM==0")) then return '0'; end; return HCR_EL2().TERR; return SCR_EL3().ADEn; end;

Library pseudocode for shared/functions/system/EffectiveIESBLibrary pseudocode for shared/functions/system/EffectiveSCR_EL3_AIEn

// EffectiveIESB() // =============== // Returns the Effective value of SCTLR_ELx().IESB. // EffectiveSCR_EL3_AIEn() // ======================= // Returns the Effective value of SCR_EL3().AIEn. funcreadonly func EffectiveIESB(target_el : bits(2)) => bit EffectiveSCR_EL3_AIEn() => bit begin if assert ! EffectiveNMEAELUsingAArch32(target_el) == '1' then return '1'; end; return( ); assert IsFeatureImplemented(FEAT_AIE); if !HaveEL(EL3SCTLR_ELEL3(target_el).IESB; ) then return '1'; end; return SCR_EL3().AIEn; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_ADEnLibrary pseudocode for shared/functions/system/EffectiveSCR_EL3_AMVOFFEN

// EffectiveSCR_EL3_ADEn() // ======================= // Returns the Effective value of SCR_EL3().ADEn. // EffectiveSCR_EL3_AMVOFFEN() // =========================== // Returns the Effective value of SCR_EL3().AMVOFFEN. readonly func EffectiveSCR_EL3_ADEn() => bit EffectiveSCR_EL3_AMVOFFEN() => bit begin assert IsFeatureImplemented(FEAT_LS64_ACCDATA); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert IsFeatureImplemented(FEAT_AMUv1p1); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().ADEn; return SCR_EL3().AMVOFFEN; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_AIEnLibrary pseudocode for shared/functions/system/EffectiveSCR_EL3_API

// EffectiveSCR_EL3_AIEn() // ======================= // Returns the Effective value of SCR_EL3().AIEn. // EffectiveSCR_EL3_API() // ====================== // Returns the Effective value of SCR_EL3().API. readonly func EffectiveSCR_EL3_AIEn() => bit EffectiveSCR_EL3_API() => bit begin assert IsFeatureImplemented(FEAT_AIE); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert IsFeatureImplemented(FEAT_PAuth); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().AIEn; return SCR_EL3().API; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_AMVOFFENLibrary pseudocode for shared/functions/system/EffectiveSCR_EL3_APK

// EffectiveSCR_EL3_AMVOFFEN() // =========================== // Returns the Effective value of SCR_EL3().AMVOFFEN. // EffectiveSCR_EL3_APK() // ====================== // Returns the Effective value of SCR_EL3().APK. readonly func EffectiveSCR_EL3_AMVOFFEN() => bit EffectiveSCR_EL3_APK() => bit begin assert IsFeatureImplemented(FEAT_AMUv1p1); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert IsFeatureImplemented(FEAT_PAuth); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().AMVOFFEN; return SCR_EL3().APK; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_APILibrary pseudocode for shared/functions/system/EffectiveSCR_EL3_ATA

// EffectiveSCR_EL3_API() // EffectiveSCR_EL3_ATA() // ====================== // Returns the Effective value of SCR_EL3().API. // Returns the Effective value of SCR_EL3().ATA. readonly func EffectiveSCR_EL3_API() => bit EffectiveSCR_EL3_ATA() => bit begin assert IsFeatureImplemented(FEAT_PAuth); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert IsFeatureImplemented(FEAT_MTE2); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().API; return SCR_EL3().ATA; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_APK

// EffectiveSCR_EL3_APK() // ====================== // Returns the Effective value of SCR_EL3().APK. readonly func EffectiveSCR_EL3_APK() => bit begin assert IsFeatureImplemented(FEAT_PAuth); if !HaveEL(EL3) then return '1'; end; assert !ELUsingAArch32(EL3); return SCR_EL3().APK; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_ATA

// EffectiveSCR_EL3_ATA() // ====================== // Returns the Effective value of SCR_EL3().ATA. readonly func EffectiveSCR_EL3_ATA() => bit begin assert IsFeatureImplemented(FEAT_MTE2); if !HaveEL(EL3) then return '1'; end; assert !ELUsingAArch32(EL3); return SCR_EL3().ATA; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_DSE

// EffectiveSCR_EL3_DSE() // ====================== // Returns the Effective value of SCR_EL3().DSE. readonly func EffectiveSCR_EL3_DSE() => bit begin assert IsFeatureImplemented(FEAT_E3DSE); if ! assert !HaveELELUsingAArch32(EL3) then return '0'; end; assert !); assert IsFeatureImplemented(FEAT_E3DSE); if !ELUsingAArch32HaveEL(EL3); ) then return '0'; end; if EffectiveSCR_EL3_EnDSE() == '0' then return '0'; end; return SCR_EL3().DSE; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_EA

// EffectiveSCR_EL3_EA() // ===================== // Returns the Effective value of SCR_EL3().EA. readonly func EffectiveSCR_EL3_EA() => bit begin if ! assert !HaveELELUsingAArch32(EL3) then return '0'; end; assert !); if !ELUsingAArch32HaveEL(EL3); ) then return '0'; end; return SCR_EL3().EA; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_EASE

// EffectiveSCR_EL3_EASE() // ======================= // Returns the Effective value of SCR_EL3().EASE. readonly func EffectiveSCR_EL3_EASE() => bit begin assert IsFeatureImplemented(FEAT_DoubleFault); assert assert ! HaveELELUsingAArch32(EL3); assert ! assert IsFeatureImplemented(FEAT_DoubleFault); assertELUsingAArch32HaveEL(EL3); return SCR_EL3().EASE; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_ECVEn

// EffectiveSCR_EL3_ECVEn() // ======================== // Returns the Effective value of SCR_EL3().ECVEn. readonly func EffectiveSCR_EL3_ECVEn() => bit begin assert IsFeatureImplemented(FEAT_ECV_POFF); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert IsFeatureImplemented(FEAT_ECV_POFF); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().ECVEn; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_EEL2

// EffectiveSCR_EL3_EEL2() // ======================= // Returns the Effective value of SCR_EL3().EEL2. readonly func EffectiveSCR_EL3_EEL2() => bit begin assert IsFeatureImplemented(FEAT_SEL2); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert IsFeatureImplemented(FEAT_SEL2); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().EEL2; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_EnAS0

// EffectiveSCR_EL3_EnAS0() // ======================== // Returns the Effective value of SCR_EL3().EnAS0. readonly func EffectiveSCR_EL3_EnAS0() => bit begin assert IsFeatureImplemented(FEAT_LS64_ACCDATA); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert IsFeatureImplemented(FEAT_LS64_ACCDATA); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().EnAS0; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_EnDSE

// EffectiveSCR_EL3_EnDSE() // ======================== // Returns the Effective value of SCR_EL3().EnDSE. readonly func EffectiveSCR_EL3_EnDSE() => bit begin assert IsFeatureImplemented(FEAT_E3DSE); assert !ELUsingAArch32(EL3); assert IsFeatureImplemented(FEAT_E3DSE); if SCR_EL3().EA == '0' && EffectiveSCR_EL3_TMEA() == '0' then return '0'; end; return SCR_EL3().EnDSE; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_EnSCXT

// EffectiveSCR_EL3_EnSCXT() // ========================= // Returns the Effective value of SCR_EL3().EnSCXT. readonly func EffectiveSCR_EL3_EnSCXT() => bit begin assert (IsFeatureImplemented(FEAT_CSV2_2) || IsFeatureImplemented(FEAT_CSV2_1p2)); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert (IsFeatureImplemented(FEAT_CSV2_2) || IsFeatureImplemented(FEAT_CSV2_1p2)); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().EnSCXT; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_FGTEn

// EffectiveSCR_EL3_FGTEn() // ======================== // Returns the Effective value of SCR_EL3().FGTEn. readonly func EffectiveSCR_EL3_FGTEn() => bit begin assert IsFeatureImplemented(FEAT_FGT); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert IsFeatureImplemented(FEAT_FGT); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().FGTEn; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_FGTEn2

// EffectiveSCR_EL3_FGTEn2() // ========================= // Returns the Effective value of SCR_EL3().FGTEn2. readonly func EffectiveSCR_EL3_FGTEn2() => bit begin assert IsFeatureImplemented(FEAT_FGT2); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert IsFeatureImplemented(FEAT_FGT2); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().FGTEn2; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_FIEN

// EffectiveSCR_EL3_FIEN() // ======================= // Returns the Effective value of SCR_EL3().FIEN. readonly func EffectiveSCR_EL3_FIEN() => bit begin assert IsFeatureImplemented(FEAT_RASv1p1); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert IsFeatureImplemented(FEAT_RASv1p1); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().FIEN; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_HCE

// EffectiveSCR_EL3_HCE() // ====================== // Returns the Effective value of SCR_EL3().HCE. readonly func EffectiveSCR_EL3_HCE() => bit begin if ! assert !ELUsingAArch32(EL3); if !HaveEL(EL2) then return '0'; end; if !HaveEL(EL3) then return '1'; end; assert !ELUsingAArch32(EL3); ) then return '1'; end; return SCR_EL3().HCE; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_HXEn

// EffectiveSCR_EL3_HXEn() // ======================= // Returns the Effective value of SCR_EL3().HXEn. readonly func EffectiveSCR_EL3_HXEn() => bit begin assert IsFeatureImplemented(FEAT_HCX); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert IsFeatureImplemented(FEAT_HCX); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().HXEn; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_NMEA

// EffectiveSCR_EL3_NMEA() // ======================= // Returns the Effective value of SCR_EL3().NMEA. readonly func EffectiveSCR_EL3_NMEA() => bit begin assert IsFeatureImplemented(FEAT_DoubleFault); if ! assert !HaveELELUsingAArch32(EL3) then return '0'; end; assert !); assert IsFeatureImplemented(FEAT_DoubleFault); if !ELUsingAArch32HaveEL(EL3); ) then return '0'; end; if !IsFeatureImplemented(FEAT_DoubleFault2) && EffectiveSCR_EL3_EA() == '0' then return '0'; end; return SCR_EL3().NMEA; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_PFAREn

// EffectiveSCR_EL3_PFAREn() // ========================= // Returns the Effective value of SCR_EL3().PFAREn. readonly func EffectiveSCR_EL3_PFAREn() => bit begin assert IsFeatureImplemented(FEAT_PFAR); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert IsFeatureImplemented(FEAT_PFAR); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().PFAREn; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_PIEn

// EffectiveSCR_EL3_PIEn() // ======================= // Returns the Effective value of SCR_EL3().PIEn. readonly func EffectiveSCR_EL3_PIEn() => bit begin assert (IsFeatureImplemented(FEAT_S1PIE) || IsFeatureImplemented(FEAT_S2PIE) || IsFeatureImplemented(FEAT_S1POE) || IsFeatureImplemented(FEAT_S2POE)); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert (IsFeatureImplemented(FEAT_S1PIE) || IsFeatureImplemented(FEAT_S2PIE) || IsFeatureImplemented(FEAT_S1POE) || IsFeatureImplemented(FEAT_S2POE)); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().PIEn; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_RCWMASKEn

// EffectiveSCR_EL3_RCWMASKEn() // ============================ // Returns the Effective value of SCR_EL3().RCWMASKEn. readonly func EffectiveSCR_EL3_RCWMASKEn() => bit begin assert IsFeatureImplemented(FEAT_THE); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert IsFeatureImplemented(FEAT_THE); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().RCWMASKEn; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_SCTLR2En

// EffectiveSCR_EL3_SCTLR2En() // =========================== // Returns the Effective value of SCR_EL3().SCTLR2En. readonly func EffectiveSCR_EL3_SCTLR2En() => bit begin assert IsFeatureImplemented(FEAT_SCTLR2); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert IsFeatureImplemented(FEAT_SCTLR2); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().SCTLR2En; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_SIF

// EffectiveSCR_EL3_SIF() // ====================== // Returns the Effective value of SCR_EL3().SIF. readonly func EffectiveSCR_EL3_SIF() => bit begin if ! assert !HaveELELUsingAArch32(EL3) then return '0'; end; assert !); if !ELUsingAArch32HaveEL(EL3); ) then return '0'; end; if IsFeatureImplemented(FEAT_RME) && !IsFeatureImplemented(FEAT_SEL2) then return '0'; end; return SCR_EL3().SIF; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_SMD

// EffectiveSCR_EL3_SMD() // ====================== // Returns the Effective value of SCR_EL3().SMD. readonly func EffectiveSCR_EL3_SMD() => bit begin if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().SMD; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_SRMASKEn

// EffectiveSCR_EL3_SRMASKEn() // =========================== // Returns the Effective value of SCR_EL3().SRMASKEn. readonly func EffectiveSCR_EL3_SRMASKEn() => bit begin assert IsFeatureImplemented(FEAT_SRMASK); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert IsFeatureImplemented(FEAT_SRMASK); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().SRMASKEn; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_ST

// EffectiveSCR_EL3_ST() // ===================== // Returns the Effective value of SCR_EL3().ST. readonly func EffectiveSCR_EL3_ST() => bit begin if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().ST; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TCR2En

// EffectiveSCR_EL3_TCR2En() // ========================= // Returns the Effective value of SCR_EL3().TCR2En. readonly func EffectiveSCR_EL3_TCR2En() => bit begin assert IsFeatureImplemented(FEAT_TCR2); if ! assert !HaveELELUsingAArch32(EL3) then return '1'; end; assert !); assert IsFeatureImplemented(FEAT_TCR2); if !ELUsingAArch32HaveEL(EL3); ) then return '1'; end; return SCR_EL3().TCR2En; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TERR

// EffectiveSCR_EL3_TERR() // ======================= // Returns the Effective value of SCR_EL3().TERR. readonly func EffectiveSCR_EL3_TERR() => bit begin assert IsFeatureImplemented(FEAT_RAS); if ! assert !HaveELELUsingAArch32(EL3) then return '0'; end; assert !); assert IsFeatureImplemented(FEAT_RAS); if !ELUsingAArch32HaveEL(EL3); if (NUM_ERROR_RECORDS == 0 && ImpDefBool("HCR_EL2.TERR,SCR_EL3.TERR/TWERR=0 when ERRIDR_EL1.NUM==0")) then return '0'; end; ) then return '0'; end; return SCR_EL3().TERR; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TID3

// EffectiveSCR_EL3_TID3() // ======================= // Returns the Effective value of SCR_EL3().TID3. readonly func EffectiveSCR_EL3_TID3() => bit begin assert IsFeatureImplemented(FEAT_IDTE3); if ! assert !HaveELELUsingAArch32(EL3) then return '0'; end; assert !); assert IsFeatureImplemented(FEAT_IDTE3); if !ELUsingAArch32HaveEL(EL3); ) then return '0'; end; return SCR_EL3().TID3; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TID5

// EffectiveSCR_EL3_TID5() // ======================= // Returns the Effective value of SCR_EL3().TID5. readonly func EffectiveSCR_EL3_TID5() => bit begin assert IsFeatureImplemented(FEAT_IDTE3); assert IsFeatureImplemented(FEAT_MTE2); if ! assert !HaveELELUsingAArch32(EL3) then return '0'; end; assert !); assert IsFeatureImplemented(FEAT_IDTE3); assert IsFeatureImplemented(FEAT_MTE2); if !ELUsingAArch32HaveEL(EL3); ) then return '0'; end; return SCR_EL3().TID5; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TLOR

// EffectiveSCR_EL3_TLOR() // ======================= // Returns the Effective value of SCR_EL3().TLOR. readonly func EffectiveSCR_EL3_TLOR() => bit begin assert IsFeatureImplemented(FEAT_LOR); if ! assert !HaveELELUsingAArch32(EL3) then return '0'; end; assert !); assert IsFeatureImplemented(FEAT_LOR); if !ELUsingAArch32HaveEL(EL3); ) then return '0'; end; return SCR_EL3().TLOR; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TRNDR

// EffectiveSCR_EL3_TRNDR() // ======================== // Returns the Effective value of SCR_EL3().TRNDR. readonly func EffectiveSCR_EL3_TRNDR() => bit begin assert IsFeatureImplemented(FEAT_RNG_TRAP); if ! assert !HaveELELUsingAArch32(EL3) then return '0'; end; assert !); assert IsFeatureImplemented(FEAT_RNG_TRAP); if !ELUsingAArch32HaveEL(EL3); ) then return '0'; end; return SCR_EL3().TRNDR; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TWE

// EffectiveSCR_EL3_TWE() // ====================== // Returns the Effective value of SCR_EL3().TWE. readonly func EffectiveSCR_EL3_TWE() => bit begin if ! assert !HaveELELUsingAArch32(EL3) then return '0'; end; assert !); if !ELUsingAArch32HaveEL(EL3); ) then return '0'; end; return SCR_EL3().TWE; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TWEDEL

// EffectiveSCR_EL3_TWEDEL() // ========================= // Returns the Effective value of SCR_EL3().TWEDEL. readonly func EffectiveSCR_EL3_TWEDEL() => bits(4) begin assert IsFeatureImplemented(FEAT_TWED); if ! assert !HaveELELUsingAArch32(EL3) then return '0000'; end; assert !); assert IsFeatureImplemented(FEAT_TWED); if !ELUsingAArch32HaveEL(EL3); ) then return '0000'; end; return SCR_EL3().TWEDEL; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TWEDEn

// EffectiveSCR_EL3_TWEDEn() // ========================= // Returns the Effective value of SCR_EL3().TWEDEn. readonly func EffectiveSCR_EL3_TWEDEn() => bit begin assert IsFeatureImplemented(FEAT_TWED); if ! assert !HaveELELUsingAArch32(EL3) then return '0'; end; assert !); assert IsFeatureImplemented(FEAT_TWED); if !ELUsingAArch32HaveEL(EL3); ) then return '0'; end; return SCR_EL3().TWEDEn; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TWERR

// EffectiveSCR_EL3_TWERR() // ======================== // Returns the Effective value of SCR_EL3().TWERR. readonly func EffectiveSCR_EL3_TWERR() => bit begin assert IsFeatureImplemented(FEAT_RASv2); if ! assert !HaveELELUsingAArch32(EL3) then return '0'; end; assert !); assert IsFeatureImplemented(FEAT_RASv2); if !ELUsingAArch32HaveEL(EL3); if (NUM_ERROR_RECORDS == 0 && ImpDefBool("HCR_EL2.TERR,SCR_EL3.TERR/TWERR=0 when ERRIDR_EL1.NUM==0")) then return '0'; end; ) then return '0'; end; return SCR_EL3().TWERR; end;

Library pseudocode for shared/functions/system/EffectiveSCR_EL3_TWI

// EffectiveSCR_EL3_TWI() // ====================== // Returns the Effective value of SCR_EL3().TWI. readonly func EffectiveSCR_EL3_TWI() => bit begin if ! assert !HaveELELUsingAArch32(EL3) then return '0'; end; assert !); if !ELUsingAArch32HaveEL(EL3); ) then return '0'; end; return SCR_EL3().TWI; end;

Library pseudocode for shared/functions/system/EffectivelyAtEL0InHost

// EffectivelyAtEL0InHost() // ======================== // ==================== // Accesses from EL0 when the Effective value of HCR_EL2().[E2H, TGE] is {1, 1} will be trapped // or Undefined. func EffectivelyAtEL0InHost() => boolean begin return (PSTATE.EL == EL0 && ELIsInHost(EL0)); end;

Library pseudocode for shared/functions/system/EffectivelyAtEL0NotInHost

// EffectivelyAtEL0NotInHost() // =========================== // ======================= // Accesses from EL0 when the Effective value of HCR_EL2().[E2H, TGE] is not {1, 1} will be // trapped or Undefined. func EffectivelyAtEL0NotInHost() => boolean begin return (PSTATE.EL == EL0 && !ELIsInHost(EL0)); end;

Library pseudocode for shared/functions/system/HaveELUsingSecurityState

// HaveELUsingSecurityState() // ========================== // Returns TRUE if Exception level 'el' with Security state 'ss' is supported, FALSE otherwise. // Returns TRUE if Exception level 'el' with Security state 'secure' is supported, // FALSE otherwise. readonly func HaveELUsingSecurityState(el : bits(2), ss :HaveELUsingSecurityState(el : bits(2), secure : boolean) => boolean begin case el of when SecurityStateEL3) => boolean begin if !=> assert secure; returnHaveEL(el) then return FALSE; end; case el of when( EL3 => if IsFeatureImplemented(FEAT_RME) then return ss ==); when SS_RootEL2; end; return ss ===> if secure then return SS_SecureHaveEL; when( EL2 => case ss of when) && IsFeatureImplemented(FEAT_SEL2); else return SS_RealmHaveEL => return IsFeatureImplemented(FEAT_RME); when( SS_NonSecureEL2 => return !); end; otherwise => return (SecureOnlyImplementationHaveEL(); when( SS_SecureEL3 => return IsFeatureImplemented(FEAT_SEL2); otherwise => return FALSE; end; when EL1 => case ss of when SS_Realm => return IsFeatureImplemented(FEAT_RME); when SS_NonSecure => return !SecureOnlyImplementation(); when SS_Secure => return IsFeatureImplemented(FEAT_Secure) && HaveAArch64(); otherwise => return FALSE; end; when EL0 => case ss of when SS_Realm => return IsFeatureImplemented(FEAT_RME); when SS_NonSecure => return !SecureOnlyImplementation(); when SS_Secure => return IsFeatureImplemented(FEAT_Secure); otherwise => return FALSE; end; otherwise => unreachable; ) || (secure == ImpDefBool("Secure-only implementation"))); end; end;

Library pseudocode for shared/functions/system/HaveSecureState

// HaveSecureState() // ================= // Return TRUE if Secure State is supported. readonly func HaveSecureState() => boolean begin return IsFeatureImplemented(FEAT_Secure); end; if !HaveEL(EL3) then return SecureOnlyImplementation(); end; if IsFeatureImplemented(FEAT_RME) && !IsFeatureImplemented(FEAT_SEL2) then return FALSE; end; return TRUE; end;

Library pseudocode for shared/functions/system/Hint_ScopeRelease

// Hint_ScopeRelease() // =================== // Signals to the memory system that if the next instruction in program order has Release semantics // or is a Data Memory Barrier that defines a Barrier scope with a preceding Scoped Release // Boundary, then these instructions do not create a Barrier-ordered-before relationship between // any Effect in program order before the Scoped Release Boundary and the Effect with Release // semantics or any Effect in program order after the DMB Effect. impdef func Hint_ScopeRelease(stshstrm : boolean) begin return; end;

Library pseudocode for shared/functions/system/Hint_ScopedReleaseBoundary

// Hint_ScopedReleaseBoundary() // ============================ // Signals to the memory system that a corresponding instruction with Release semantics or Data // Memory Barrier will subsequently occur in program order, and if that corresponding instruction // defines a Barrier scope with the Scoped Release Boundary, then these instructions do not create // a Barrier-ordered-before relationship between any Effect in program order before the Scoped // Release Boundary and the Effect with Release semantics or any Effect in program order after the // DMB Effect. impdef func Hint_ScopedReleaseBoundary() begin return; end;

Library pseudocode for shared/functions/system/IsSecureBelowEL3

// IsSecureBelowEL3() // ================== // Return TRUE if an Exception level below EL3 is in Secure state // or would be following an exception return to that level. // // That is, if at AArch64 EL3 or in AArch32 Monitor mode, whether an // exception return would pass to Secure or Non-secure state. readonly func IsSecureBelowEL3() => boolean begin if HaveEL(EL3) then return if !HaveAArch64() then SCR().NS == '0' else SCR_EL3().NS == '0'; elsif HaveEL(EL2) && (!IsFeatureImplemented(FEAT_SEL2) || !HaveAArch64()) then // If Secure EL2 is not an architecture option then we must be Non-secure. return FALSE; else // TRUE if PE is Secure or FALSE if Non-secure. return return ImpDefBool("Secure-only implementation"); end; end; SecureOnlyImplementation(); end; end;

Library pseudocode for shared/functions/system/NonSecureOnlyImplementation

// NonSecureOnlyImplementation() // ============================= // Returns TRUE if the security state is always Non-secure for this implementation. readonly funcfunc NonSecureOnlyImplementation() => boolean begin return !IsFeatureImplemented(FEAT_Secure) && ! return ImpDefBool("Non-secure only implementation"); end;HaveEL(EL3); end;

Library pseudocode for shared/functions/system/SecureOnlyImplementation

// SecureOnlyImplementation() // ========================== // Returns TRUE if the security state is always Secure for this implementation. readonly func SecureOnlyImplementation() => boolean begin return IsFeatureImplemented(FEAT_Secure) && ! return ImpDefBool("Secure-only implementation"); end;HaveEL(EL3); end;

Library pseudocode for shared/functions/system/SmallestTranslationGranule

// SmallestTranslationGranule() // ============================ // Smallest implemented translation granule. func SmallestTranslationGranule() => integer begin if IsFeatureImplemented(FEAT_TGran4K) then return 12; end; if IsFeatureImplemented(FEAT_TGran16K) then return 14; end; if IsFeatureImplemented(FEAT_TGran64K) then return 16; end; unreachable; end;

Library pseudocode for shared/functions/system/WatchpointRelatedSyndrome

// WatchpointRelatedSyndrome() // =========================== // Update common Watchpoint related fields. func WatchpointRelatedSyndrome(fault : FaultRecord) => bits(24) begin var syndrome : bits(24) = Zeros{}; if fault.watchptinfo.maybe_false_match then syndrome[16] = '1'; // WPF elsif IsFeatureImplemented(FEAT_Debugv8p2) then syndrome[16] = ImpDefBit("WPF value on TRUE Watchpoint match"); end; if IsRelaxedWatchpointAccess(fault.accessdesc) then if HaltOnBreakpointOrWatchpoint() then if ImpDefBool("EDWAR is not valid on watchpoint debug event") then syndrome[10] = '1'; // FnV end; else if ImpDefBool("FAR is not valid on watchpoint exception") then syndrome[10] = '1'; // FnV end; end; else if WatchpointFARNotPrecise(fault) then syndrome[15] = '1'; // FnP end; end; // Watchpoint number is valid if FEAT_Debugv8p9 is implemented or // if Feat_Debugv8p2 is implemented and below set of conditions are satisfied: // - Any of FnV = 1 or FnP = 1 or WPF = 1. // - Either FnV = 1 or FnP = 1. // - If the address recorded in FAR is not within a naturally-aligned block of memory. // Otherwise, it is IMPLEMENTATION DEFINED if watchpoint number is valid. if IsFeatureImplemented(FEAT_Debugv8p9) then syndrome[17] = '1'; // WPTV syndrome[23:18] = fault.watchptinfo.watchpt_num[5:0]; // WPT elsif IsFeatureImplemented(FEAT_Debugv8p2) then if syndrome[15] == '1' || syndrome[10] == '1' || syndrome[16] == '1' then if syndrome[15] == '1' || syndrome[10] == '1' then // Either of FnP or FnV is 1 syndrome[17] = '1'; // WPTV elsif !AddressInNaturallyAlignedBlock(fault.vaddress, fault.watchptinfo.vaddress) then syndrome[17] = '1'; // WPTV elsif ImpDefBool("WPTV field is valid") then syndrome[17] = '1'; end; if syndrome[17] == '1' then syndrome[23:18] = fault.watchptinfo.watchpt_num[5:0]; // WPT else syndrome[23:18] = ARBITRARY : bits(6); end; end; return syndrome; end;

Library pseudocode for shared/functions/unpredictable/Unpredictable

// Unpredictable // ============= // List of Constrained Unpredictable situations. type Unpredictable of enumeration { // VMSR on MVFR Unpredictable_VMSR, // Writeback/transfer register overlap (load) Unpredictable_WBOVERLAPLD, // Writeback/transfer register overlap (store) Unpredictable_WBOVERLAPST, // Load Pair transfer register overlap Unpredictable_LDPOVERLAP, // Store-exclusive base/status register overlap Unpredictable_BASEOVERLAP, // Store-exclusive data/status register overlap Unpredictable_DATAOVERLAP, // Load-store alignment checks Unpredictable_DEVPAGE2, // Instruction fetch from Device memory Unpredictable_INSTRDEVICE, // Reserved CPACR value Unpredictable_RESCPACR, // Reserved MAIR value Unpredictable_RESMAIR, // Effect of SCTLR_ELx.C on Tagged attribute Unpredictable_S1CTAGGED, // Reserved Stage 2 MemAttr value Unpredictable_S2RESMEMATTR, // Reserved TEX::C::B value Unpredictable_RESTEXCB, // Reserved PRRR value Unpredictable_RESPRRR, // Reserved DACR field Unpredictable_RESDACR, // Reserved VTCR.S value Unpredictable_RESVTCRS, // Reserved or out-of-range TCR.TnSZ value Unpredictable_RESTnSZ, // Reserved SCTLR_ELx.TCF value Unpredictable_RESTCF, // Tag stored to Device memory Unpredictable_DEVICETAGSTORE, // Syndrome for a known-passing conditional A32 instruction Unpredictable_ESRCONDPASS, // Illegal State exception: zero PSTATE.IT Unpredictable_ILZEROIT, // Illegal State exception: zero PSTATE.T Unpredictable_ILZEROT, // Debug: prioritization of Vector Catch Unpredictable_BPVECTORCATCHPRI, // Debug Vector Catch: match on 2nd halfword Unpredictable_VCMATCHHALF, // Debug Vector Catch: match on Data Abort // or Prefetch abort Unpredictable_VCMATCHDAPA, // Debug watchpoints: nonzero MASK and non-ones BAS Unpredictable_WPMASKANDBAS, // Debug watchpoints: non-contiguous BAS Unpredictable_WPBASCONTIGUOUS, // Debug watchpoints: reserved MASK Unpredictable_RESWPMASK, // Debug watchpoints: nonzero MASKed bits of address Unpredictable_WPMASKEDBITS, // Debug breakpoints and watchpoints: reserved control bits Unpredictable_RESBPWPCTRL, // Debug breakpoints: not implemented Unpredictable_BPNOTIMPL, // Debug breakpoints: reserved type Unpredictable_RESBPTYPE, // Debug breakpoints and watchpoints: reserved MDSELR_EL1.BANK Unpredictable_RESMDSELR, // Debug breakpoints: not-context-aware breakpoint Unpredictable_BPNOTCTXCMP, // Debug breakpoints: match on 2nd halfword of instruction Unpredictable_BPMATCHHALF, // Debug breakpoints: mismatch on 2nd halfword of instruction Unpredictable_BPMISMATCHHALF, // Debug breakpoints: a breakpoint is linked to that is not // programmed with linking enabled Unpredictable_BPLINKINGDISABLED, // Debug breakpoints: reserved MASK Unpredictable_RESBPMASK, // Debug breakpoints: MASK is set for a Context matching // breakpoint or when DBGBCR_EL1(n).BAS != '1111' Unpredictable_BPMASK, // Debug breakpoints: nonzero MASKed bits of address Unpredictable_BPMASKEDBITS, // Debug breakpoints: A linked breakpoint is // linked to an address matching breakpoint Unpredictable_BPLINKEDADDRMATCH, // Debug: restart to a misaligned AArch32 PC value Unpredictable_RESTARTALIGNPC, // Debug: restart to a not-zero-extended AArch32 PC value Unpredictable_RESTARTZEROUPPERPC, // Zero top 32 bits of X registers in AArch32 state Unpredictable_ZEROUPPER, // Zero top 32 bits of PC on illegal return to // AArch32 state Unpredictable_ERETZEROUPPERPC, // Force address to be aligned when interworking // branch to A32 state Unpredictable_A32FORCEALIGNPC, // SMC disabled Unpredictable_SMD, // FF speculation Unpredictable_NONFAULT, // Zero top bits of Z registers in EL change Unpredictable_SVEZEROUPPER, // Load mem data in NF loads Unpredictable_SVELDNFDATA, // Write zeros in NF loads Unpredictable_SVELDNFZERO, // SP alignment fault when predicate is all zero Unpredictable_CHECKSPNONEACTIVE, // Zero top bits of ZA registers in EL change Unpredictable_SMEZEROUPPER, // Watchpoint match of last rounded up memory access in case of // 16 byte rounding Unpredictable_16BYTEROUNDEDUPACCESS, // Watchpoint match of first rounded down memory access in case of // 16 byte rounding Unpredictable_16BYTEROUNDEDDOWNACCESS, // HCR_EL2.[NV,NV1] == '01' Unpredictable_NVNV1, // Upper bits of a BADDR are not RESS Unpredictable_BADDR_RESS, // Reserved shareability encoding Unpredictable_Shareability, // Access Flag Update by HW Unpredictable_AFUPDATE, // Dirty Bit State Update by HW Unpredictable_DBUPDATE, // Unsupported memory attributes for HW update Unpredictable_Unsupported_Atomic_HW_Update, // Consider SCTLR_ELx().IESB in Debug state Unpredictable_IESBinDebug, // Bad settings for PMSFCR_EL1/PMSEVFR_EL1/PMSLATFR_EL1 // The HCR_EL2.TERR / HCR2.TERR and SCR_EL3.TERR / SCR.TERR // trap control can be treated as RES0. Unpredictable_BADPMSFCR, // Zero saved BType value in SPSR_ELx/DPSR_EL0Unpredictable_MINIMALRASv2, // Bad settings for PMSFCR_EL1/PMSEVFR_EL1/PMSLATFR_EL1 Unpredictable_ZEROBTYPE, // Timestamp constrained to virtual or physicalUnpredictable_BADPMSFCR, // Zero saved BType value in SPSR_ELx/DPSR_EL0 Unpredictable_EL2TIMESTAMP,Unpredictable_ZEROBTYPE, // Timestamp constrained to virtual or physical Unpredictable_EL1TIMESTAMP, // Reserved MDCR_EL3.[NSTBE,NSTB] or MDCR_EL3.[NSPBE,NSPB] valueUnpredictable_EL2TIMESTAMP, Unpredictable_RESERVEDNSxB,Unpredictable_EL1TIMESTAMP, // Reserved MDCR_EL3.[NSTBE,NSTB] or MDCR_EL3.[NSPBE,NSPB] value Unpredictable_RESERVEDNSxB_Trap, // WFET or WFIT instruction in Debug stateUnpredictable_RESERVEDNSxB, Unpredictable_WFxTDEBUG, // Address does not support LS64 instructionsUnpredictable_RESERVEDNSxB_Trap, // WFET or WFIT instruction in Debug state Unpredictable_LS64UNSUPPORTED, // Unaligned exclusives, atomics, acquire/release // to a region that is not to Normal inner write-back // outer write-back shareable generate an Alignment fault.Unpredictable_WFxTDEBUG, // Address does not support LS64 instructions Unpredictable_LSE2_ALIGNMENT_FAULT, // 128-bit Atomic or 128-bit RCW{S} transfer register overlapUnpredictable_LS64UNSUPPORTED, // Unaligned exclusives, atomics, acquire/release // to a region that is not to Normal inner write-back // outer write-back shareable generate an Alignment fault. Unpredictable_LSE128OVERLAP, // Clearing DCC/ITR sticky flags when instruction is in flightUnpredictable_LSE2_ALIGNMENT_FAULT, // 128-bit Atomic or 128-bit RCW{S} transfer register overlap Unpredictable_CLEARERRITEZERO, // ALUEXCEPTIONRETURN when in user/system mode in // A32 instructionsUnpredictable_LSE128OVERLAP, // Clearing DCC/ITR sticky flags when instruction is in flight Unpredictable_ALUEXCEPTIONRETURN, // Trap to register in debug state are ignoredUnpredictable_CLEARERRITEZERO, // ALUEXCEPTIONRETURN when in user/system mode in // A32 instructions Unpredictable_IGNORETRAPINDEBUG, // Compare DBGBVR.RESS for BP/WPUnpredictable_ALUEXCEPTIONRETURN, // Trap to register in debug state are ignored Unpredictable_DBGxVR_RESS, // Inaccessible event counterUnpredictable_IGNORETRAPINDEBUG, // Compare DBGBVR.RESS for BP/WP Unpredictable_PMUEVENTCOUNTER, // Reserved PMSCR.PCT behaviorUnpredictable_DBGxVR_RESS, // Inaccessible event counter Unpredictable_PMSCR_PCT, // MDCR_EL2.HPMN or HDCR.HPMN is larger than PMCR.N or // FEAT_HPMN0 is not implemented and HPMN is 0.Unpredictable_PMUEVENTCOUNTER, // Reserved PMSCR.PCT behavior Unpredictable_RES_HPMN, // Chained PMU counters idx and idx+1 are not in same rangeUnpredictable_PMSCR_PCT, // MDCR_EL2.HPMN or HDCR.HPMN is larger than PMCR.N or // FEAT_HPMN0 is not implemented and HPMN is 0. Unpredictable_COUNT_CHAIN, // PMCCR.EPMN is larger than PMCR.NUnpredictable_RES_HPMN, // Chained PMU counters idx and idx+1 are not in same range Unpredictable_RES_EPMN, // Generate BRB_FILTRATE event on BRB injectionUnpredictable_COUNT_CHAIN, // PMCCR.EPMN is larger than PMCR.N Unpredictable_BRBFILTRATE, // Generate PMU_SNAPSHOT event in Debug stateUnpredictable_RES_EPMN, // Generate BRB_FILTRATE event on BRB injection Unpredictable_PMUSNAPSHOTEVENT, // Reserved MDCR_EL3.EPMSSAD valueUnpredictable_BRBFILTRATE, // Generate PMU_SNAPSHOT event in Debug state Unpredictable_RESEPMSSAD, // Reserved PMECR_EL1.SSE valueUnpredictable_PMUSNAPSHOTEVENT, // Reserved MDCR_EL3.EPMSSAD value Unpredictable_RESPMSSE, // Enable for PMU Profiling exception and PMUIRQUnpredictable_RESEPMSSAD, // Reserved PMECR_EL1.SSE value Unpredictable_RESPMEE, // Enables for SPE Profiling exceptions and PMSIRQUnpredictable_RESPMSSE, // Enable for PMU Profiling exception and PMUIRQ Unpredictable_RESPMSEE, // Enables for TRBE Profiling exceptions and PMSIRQUnpredictable_RESPMEE, // Enables for SPE Profiling exceptions and PMSIRQ Unpredictable_RESTRFEE, // NonZero TRBPTR_EL1[63:(OAMax)]Unpredictable_RESPMSEE, // Enables for TRBE Profiling exceptions and PMSIRQ Unpredictable_TRBPTR_Fault_AddressSize, // Operands for CPY*/SET* instructions overlapUnpredictable_RESTRFEE, // NonZero TRBPTR_EL1[63:(OAMax)] Unpredictable_MOPSOVERLAP, // Operands for CPY*/SET* instructions use 0b11111 // as a register specifierUnpredictable_TRBPTR_Fault_AddressSize, // Operands for CPY*/SET* instructions overlap Unpredictable_MOPS_R31, // PMBPTR_EL1[63:(OAMax)] NonZero causes Address Size faultUnpredictable_MOPSOVERLAP, // Operands for CPY*/SET* instructions use 0b11111 // as a register specifier Unpredictable_PMBPTR_Fault_AddressSize, // Chooses which value to return in a non failed Atomic Compare and SwapUnpredictable_MOPS_R31, // PMBPTR_EL1[63:(OAMax)] NonZero causes Address Size fault Unpredictable_CASRETURNOLDVALUE, // Enables write of the newvalue in a failed Atomic Compare and SwapUnpredictable_PMBPTR_Fault_AddressSize, // Chooses which value to return in a non failed Atomic Compare and Swap Unpredictable_WRITEFAILEDCAS, // Enables write of the newvalue in a failed Atomic Compare and Swap // or failed RCW{S}Unpredictable_CASRETURNOLDVALUE, // Enables write of the newvalue in a failed Atomic Compare and Swap Unpredictable_WRITEFAILEDRCWCAS, // Store-only Tag checking on a failed Atomic Compare and SwapUnpredictable_WRITEFAILEDCAS, // Enables write of the newvalue in a failed Atomic Compare and Swap // or failed RCW{S} Unpredictable_STRONLYTAGCHECKEDCAS, // Store-only Tag checking on a failed RCW(S) checks // or RCW(S) Atomic Compare and SwapUnpredictable_WRITEFAILEDRCWCAS, // Store-only Tag checking on a failed Atomic Compare and Swap Unpredictable_STRONLYTAGCHECKEDRCWSCAS, // Reserved MDCR_EL3.ETBAD valueUnpredictable_STRONLYTAGCHECKEDCAS, // Store-only Tag checking on a failed RCW(S) checks // or RCW(S) Atomic Compare and Swap Unpredictable_RES_ETBAD, // Invalid Streaming Mode filter bitsUnpredictable_STRONLYTAGCHECKEDRCWSCAS, // Reserved MDCR_EL3.ETBAD value Unpredictable_RES_PMU_VS, // Apply Checked Pointer Arithmetic on a sequential access to bytes // that cross the 0xXXFF_FFFF_FFFF_FFFF boundary.Unpredictable_RES_ETBAD, // Invalid Streaming Mode filter bits Unpredictable_CPACHECK, // Reserved PMEVTYPER_EL0(n).[TC,TE,TLC] valuesUnpredictable_RES_PMU_VS, // Apply Checked Pointer Arithmetic on a sequential access to bytes // that cross the 0xXXFF_FFFF_FFFF_FFFF boundary. Unpredictable_RESTC, // When FEAT_MTE is implemented, if Memory access mode is enabled // and PSTATE.TCO is 0, Reads and writes to the external debug // interface DTR registers are CONSTRAINED UNPREDICTABLE for tagcheckUnpredictable_CPACHECK, // Reserved PMEVTYPER_EL0(n).[TC,TE,TLC] values Unpredictable_NODTRTAGCHK, // Use the default PMG when the default PARTID is generated // due to MPAM errorUnpredictable_RESTC, // When FEAT_MTE is implemented, if Memory access mode is enabled // and PSTATE.TCO is 0, Reads and writes to the external debug // interface DTR registers are CONSTRAINED UNPREDICTABLE for tagcheck Unpredictable_USE_DEFAULT_PMG, // MPAM PARTID/PMG exceeding PARTID_MAX/PMG_MAXUnpredictable_NODTRTAGCHK, // Use the default PMG when the default PARTID is generated // due to MPAM error Unpredictable_OUT_OF_RANGE_ID, // MPAM vPARTID exceeding (VPMR_MAX << 2) + 3Unpredictable_USE_DEFAULT_PMG, // MPAM PARTID/PMG exceeding PARTID_MAX/PMG_MAX Unpredictable_OUT_OF_RANGE_VID, // If the atomic instructions are not atomic in regard to other // agents that access memory, then the instruction can have one or // more of the following effectsUnpredictable_OUT_OF_RANGE_ID, // MPAM vPARTID exceeding (VPMR_MAX << 2) + 3 Unpredictable_Atomic_SYNC_ABORT,Unpredictable_OUT_OF_RANGE_VID, // If the atomic instructions are not atomic in regard to other // agents that access memory, then the instruction can have one or // more of the following effects Unpredictable_Atomic_SERROR,Unpredictable_Atomic_SYNC_ABORT, Unpredictable_Atomic_NOP,Unpredictable_Atomic_SERROR, Unpredictable_Atomic_MMU_IMPDEF_FAULT, // Truncate virtual identifier to bottom 12 bits if it exceeds 2^12Unpredictable_Atomic_NOP, Unpredictable_MPAM_TRUNCATE_VID, // Accessing DBGDSCRint via MRC in debug stateUnpredictable_Atomic_MMU_IMPDEF_FAULT, // Truncate virtual identifier to bottom 12 bits if it exceeds 2^12 Unpredictable_MRC_APSR_TARGET, // Accessing Banked register not accessible from the PE modeUnpredictable_MPAM_TRUNCATE_VID, // Accessing DBGDSCRint via MRC in debug state Unpredictable_BankedRegister, // Accessing unimplemented Banked registerUnpredictable_MRC_APSR_TARGET, // Accessing Banked register not accessible from the PE mode Unpredictable_UnimplementedRegister, // Reserved ERRACR.{RLRA,SRA,NSRA} valuesUnpredictable_BankedRegister, // Accessing unimplemented Banked register Unpredictable_RES_RA, // Linked target does not support linkingUnpredictable_UnimplementedRegister, // Reserved ERRACR.{RLRA,SRA,NSRA} values Unpredictable_BPNOTLINKING };Unpredictable_RES_RA, // Linked target does not support linkingUnpredictable_BPNOTLINKING };

Library pseudocode for shared/trace/Common/DebugWriteFault

// DebugWriteFault() // ================= // Populate the syndrome register for a fault caused by a call of DebugMemWrite(). func DebugWriteFault(vaddress : bits(64), fault : FaultRecord) begin var ec : bits(6); if (IsFeatureImplemented(FEAT_RME) && fault.gpcf.gpf != GPCF_None && fault.gpcf.gpf != GPCF_Fail) then ec = '011110'; else ec = if fault.secondstage then '100101' else '100100'; end; var mss2 : bits(24) = Zeros{}; var mss : bits(16) = Zeros{}; if fault.gpcf.gpf IN { if fault.statuscode ==Fault_Permission then mss2[8] = if fault.toplevel then '1' else '0'; // TopLevel bit mss2[7] = if fault.assuredonly then '1' else '0'; // AssuredOnly bit mss2[6] = if fault.overlay then '1' else '0'; // Overlay bit mss2[5] = if fault.dirtybit then '1' else '0'; // DirtyBit end; var mss : bits(16) = Zeros{}; if !(IsFeatureImplemented(FEAT_RME) && fault.gpcf.gpf != GPCF_None,&& fault.gpcf.gpf != GPCF_Fail} then mss2[11] = if fault.hdbssf then '1' else '0'; // HDBSSF mss2[8] = if fault.toplevel then '1' else '0'; // TopLevel bit mss2[7] = if fault.assuredonly then '1' else '0'; // AssuredOnly bit mss2[6] = if fault.overlay then '1' else '0'; // Overlay bit mss2[5] = if fault.dirtybit then '1' else '0'; // DirtyBit ) then mss[5:0] = EncodeLDFSC(fault.statuscode, fault.level); // FSC bits if fault.s2fs1walk then if (IsFeatureImplemented(FEAT_SPE_EXC) && fault.accessdesc.acctype == AccessType_SPE) then mss[7] = '1'; // S1PTW bit end; if (IsFeatureImplemented(FEAT_TRBE_EXC) && fault.accessdesc.acctype == AccessType_TRBE) then mss[7] = '1'; // S1PTW bit end; end; (fault.statuscode, fault.level); // FSC bits end; // Generate a buffer management event, modifying the existing syndrome. var target_el : bits(2); var syndrome : bits(64); case fault.accessdesc.acctype of when AccessType_SPE => target_el = ReportSPEEvent(ec, mss[5:0]); syndrome = PMBSR_EL(target_el); when AccessType_TRBE => target_el = ReportTRBEEvent(ec, mss[5:0]); syndrome = TRBSR_EL(target_el); otherwise => unreachable; end; // The following values are not modified if a previous buffer management event // has not been handled. Note that in this simple sequential model, this test // will never fail. if syndrome[17] == '0' then // Check previous 'S' bit. syndrome[55:32] = mss2; // MSS2 bits syndrome[31:26] = ec; // EC bits if fault.accessdesc.acctype == AccessType_TRBE then syndrome[22] = '1'; // IRQ bit (TRBE only) end; syndrome[17] = '1'; // S bit syndrome[15:0] = mss; // MSS bits end; // For SPE, PMBPTR_EL1 points to the address that generated the fault, and writing // to memory never started. Therefore, there isno data loss and DL is unchanged. case fault.accessdesc.acctype of when AccessType_SPE => PMBSR_EL(target_el) = syndrome; when AccessType_TRBE => TRBSR_EL(target_el) = syndrome; otherwise => unreachable; end; return; end;

Library pseudocode for shared/trace/claim

var TRCClaimTags : bits(32);

Library pseudocode for shared/trace/claim/Write_TRCCLAIMCLR

// Write_TRCCLAIMCLR() // =================== // System register write to TRCCLAIMCLR. func Write_TRCCLAIMCLR(value_in : bits(64)) begin assert NUM_TRC_CLAIM_TAGS <= 32; TRCClaimTags = TRCClaimTags AND NOT ZeroExtend{32}(value_in[0 +: NUM_TRC_CLAIM_TAGS]); end;

Library pseudocode for shared/trace/claim/Write_TRCCLAIMSET

// Write_TRCCLAIMSET() // =================== // System register write to TRCCLAIMSET. func Write_TRCCLAIMSET(value_in : bits(64)) begin assert NUM_TRC_CLAIM_TAGS <= 32; TRCClaimTags = TRCClaimTags OR ZeroExtend{32}(value_in[0 +: NUM_TRC_CLAIM_TAGS]); end;


2026-09_rel2026-06_diff_tag 2026-09-212026-09-08 1409:2244:3801

Copyright © 2010-2026 Arm Limited or its affiliates. All rights reserved. This document is Non-Confidential.

(old) htmldiff from-(new)