Shared pseudocode from the offline Arm documentation snapshot. Part 18 of 36.
if IsFeatureImplemented(FEAT_GCIE) && HaveEL(EL2) then return '1'; end;
return ICC_SRE_EL3().Enable;
end;
## Library pseudocode for aarch64/functions/system/InGuardedPage
// InGuardedPage // ============= // Records whether the currently fetched instruction was retrieved from a guarded page, will be // TRUE if the GP bit in the page or block descriptor for the current instruction fetch was equal // to one.
var InGuardedPage : boolean;
## 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/system/IsHCRXEL2Enabled
// IsHCRXEL2Enabled // ================== // Returns TRUE if access to HCRX_EL2 register is enabled, and FALSE otherwise. // Indirect read of HCRX_EL2 returns 0 when access is not enabled.
readonly func IsHCRXEL2Enabled() => boolean begin if !IsFeatureImplemented(FEAT_HCX) then return FALSE; end; if ELUsingAArch32(EL2) then return FALSE; end; if HaveEL(EL3) && SCR_EL3().HXEn == '0' then return FALSE; end;
return EL2Enabled();
end;
## Library pseudocode for aarch64/functions/system/IsMTEEnabled
// IsMTEEnabled // ============== // Returns TRUE if the currently selected MTE mechanism is enabled, and FALSE otherwise.
readonly func IsMTEEnabled(el : bits(2)) => boolean begin let regime : Regime = TranslationRegime(el); var selected : boolean = FALSE;
if IsPMTESelected(el) then if HaveEL(EL3) && SCR_EL3().ATA == '0' && el IN {EL0, EL1, EL2} then return FALSE; end;if EL2Enabled() && (EL0) && HCR_EL2().ATA == '0' && el IN {EL0, EL1} then return FALSE;end;selected = TRUE;end;
if selected then case regime of when Regime_EL3 => return SCTLR_EL3().ATA == '1'; when Regime_EL2 => return SCTLR_EL2().ATA == '1'; when Regime_EL20 => return if el == EL0 then SCTLR_EL2().ATA0 == '1' else SCTLR_EL2().ATA == '1'; when Regime_EL10 => return if el == EL0 then SCTLR_EL1().ATA0 == '1' else SCTLR_EL1().ATA == '1'; otherwise => unreachable; end; end;
return FALSE;
end;
## Library pseudocode for aarch64/functions/system/IsPMTESelected
// IsPMTESelected // ================ // Returns TRUE if Physical MTE is selected for the translation regime // associated with the EL, and FALSE otherwise
readonly func IsPMTESelected(el : bits(2)) => boolean begin if !IsFeatureImplemented(FEAT_MTE2) then return FALSE; end;
return TRUE;
end;
## Library pseudocode for aarch64/functions/system/IsSCTLR2EL1Enabled
// IsSCTLR2EL1Enabled // ==================== // Returns TRUE if access to SCTLR2_EL1 register is enabled, and FALSE otherwise. // Indirect read of SCTLR2_EL1 returns 0 when access is not enabled.
readonly func IsSCTLR2EL1Enabled() => boolean begin if !IsFeatureImplemented(FEAT_SCTLR2) then return FALSE; end; if HaveEL(EL3) && SCR_EL3().SCTLR2En == '0' then return FALSE; elsif (EL2Enabled() && (() || HCRX_EL2().SCTLR2En == '0')) then return FALSE; else return TRUE; end; end;
## Library pseudocode for aarch64/functions/system/IsSCTLR2EL2Enabled
// IsSCTLR2EL2Enabled // ==================== // Returns TRUE if access to SCTLR2_EL2 register is enabled, and FALSE otherwise. // Indirect read of SCTLR2_EL2 returns 0 when access is not enabled.
readonly func IsSCTLR2EL2Enabled() => boolean begin if !IsFeatureImplemented(FEAT_SCTLR2) then return FALSE; end; if HaveEL(EL3) && SCR_EL3().SCTLR2En == '0' then return FALSE; end;
return EL2Enabled();
end;
## Library pseudocode for aarch64/functions/system/IsSystemRegisterMaskingEnabled
// IsSystemRegisterMaskingEnabled // ================================ // Returns TRUE if access to the MASK registers introduced by FEAT_SRMASK is enabled and the // values in the register are not treated as 0.
func IsSystemRegisterMaskingEnabled(el : bits(2)) => boolean begin assert IsFeatureImplemented(FEAT_SRMASK) && el IN {EL1, EL2};
if HaveEL(EL3) && SCR_EL3().SRMASKEn == '0' then return FALSE; end;
return el == EL2 || () || (IsHCRXEL2Enabled() && HCRX_EL2().SRMASKEn == '1');
end;
## Library pseudocode for aarch64/functions/system/IsTCR2EL1Enabled
// IsTCR2EL1Enabled // ================== // Returns TRUE if access to TCR2_EL1 register is enabled, and FALSE otherwise. // Indirect read of TCR2_EL1 returns 0 when access is not enabled.
readonly func IsTCR2EL1Enabled() => boolean begin if !IsFeatureImplemented(FEAT_TCR2) then return FALSE; end; if HaveEL(EL3) && SCR_EL3().TCR2En == '0' then return FALSE; elsif (EL2Enabled() && (() || HCRX_EL2().TCR2En == '0')) then return FALSE; else return TRUE; end; end;
## Library pseudocode for aarch64/functions/system/IsTCR2EL2Enabled
// IsTCR2EL2Enabled // ================== // Returns TRUE if access to TCR2_EL2 register is enabled, and FALSE otherwise. // Indirect read of TCR2_EL2 returns 0 when access is not enabled.
readonly func IsTCR2EL2Enabled() => boolean begin if !IsFeatureImplemented(FEAT_TCR2) then return FALSE; end; if HaveEL(EL3) && SCR_EL3().TCR2En == '0' then return FALSE; end;
return EL2Enabled();
end;
## Library pseudocode for aarch64/functions/system/PACInstType
// PACInstType // =========== type PACInstType of enumeration { PACIxSP, PACIxSPPC, };
## Library pseudocode for aarch64/functions/system/SetBTypeCompatible
// SetBTypeCompatible // ==================== // Sets the value of BTypeCompatible global variable used by BTI
func SetBTypeCompatible(x : boolean) begin BTypeCompatible = x; end;
## Library pseudocode for aarch64/functions/system/SetBTypeNext
// SetBTypeNext // ============== // Set the value of BTypeNext global variable used by BTI
func SetBTypeNext(x : bits(2)) begin BTypeNext = x; end;
## Library pseudocode for aarch64/functions/system/SetInGuardedPage
// SetInGuardedPage // ================== // Global state updated to denote if memory access is from a guarded page.
func SetInGuardedPage(guardedpage : boolean) begin InGuardedPage = guardedpage; end;
## Library pseudocode for aarch64/functions/system128/AArch64\_SysInstr128
// AArch64_SysInstr128 // ===================== // Execute a system instruction with write (2 64-bit source operands).
impdef func AArch64_SysInstr128(op0 : bits(2), op1 : bits(3), crn : bits(4), crm : bits(4), op2 : bits(3), t : integer, t2 : integer) begin Unimplemented(); end;
## Library pseudocode for aarch64/functions/system128/AArch64\_SysRegRead128
// AArch64_SysRegRead128 // ======================= // Read from a 128-bit System register and write the contents of the register to X[t] and X[t2].
impdef func AArch64_SysRegRead128(op0 : bits(2), op1 : bits(3), crn : bits(4), crm : bits(4), op2 : bits(3), t : integer, t2 : integer) begin Unimplemented(); end;
## Library pseudocode for aarch64/functions/system128/AArch64\_SysRegWrite128
// AArch64_SysRegWrite128 // ======================== // Read the contents of X[t] and X[t2] and write the contents to a 128-bit System register.
impdef func AArch64_SysRegWrite128(op0 : bits(2), op1 : bits(3), crn : bits(4), crm : bits(4), op2 : bits(3), t : integer, t2 : integer) begin Unimplemented(); end;
## Library pseudocode for aarch64/functions/tlbi
constant DEFAULT_TLBI_DOMAIN : bits(16) = Zeros{}; // Broadcast to all agents in the // corresponding broadcast domain
## Library pseudocode for aarch64/functions/tlbi/AArch64\_EffectiveBroadcast
// AArch64_EffectiveBroadcast // ============================
func AArch64_EffectiveBroadcast(broadcast_in : Broadcast) => Broadcast begin var broadcast : Broadcast = broadcast_in;
if PSTATE.EL != EL1 then return broadcast; end;if IsFeatureImplemented(FEAT_TLBID) then let fnb : bit = if IsHCRXEL2Enabled() then HCRX_EL2().FNB else '0'; case fnb::HCR_EL2().FB of when '00' => pass; when '01' => if broadcast == Broadcast_NSH then // The operation is broadcast within the Inner Shareable shareability domain. broadcast = Broadcast_ForcedISH; end; when '10' => if broadcast == Broadcast_ISH then // The operation only affects the PE on which the instruction is executed. broadcast = Broadcast_NSH; end; when '11' => if broadcast == Broadcast_ISH then // The operation is broadcast to PEs which would share TLB entries with the // current PE if CnP were 1. broadcast = Broadcast_ISH_CnP; end; end; else if broadcast == Broadcast_NSH && EL2Enabled() && HCR_EL2().FB == '1' then broadcast = Broadcast_ForcedISH; end; end;
return broadcast;
end;
## Library pseudocode for aarch64/functions/tlbi/AArch64\_TLBIP\_IPAS2
// AArch64_TLBIP_IPAS2 // ===================== // Invalidate by IPA all stage 2 only TLB entries in the indicated broadcast // domain matching the indicated VMID in the indicated regime with the indicated security state. // Note: stage 1 and stage 2 combined entries are not in the scope of this operation. // IPA and related parameters of the are derived from Xt.
func AArch64_TLBIP_IPAS2(security : SecurityState, regime : Regime, vmid : bits(NUM_VMIDBITS), broadcast_in : Broadcast, level : TLBILevel, attr : TLBIMemAttr, Xt : bits(128)) begin assert PSTATE.EL IN {EL3, EL2}; var broadcast : Broadcast = broadcast_in;
var r : TLBIRecord; r.op = TLBIOp_IPAS2; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.vmid = vmid; r.use_vmid = TRUE; r.level = level; r.attr = attr; r.ttl = Xt[47:44]; r.address = ZeroExtend{64}(Xt[107:64] :: Zeros{12}); if IsFeatureImplemented(FEAT_TLBID) && Xt[32] == '1' then r.d64 = TRUE; r.d128 = r.ttl == '00xx'; else r.d64 = r.ttl == '00xx'; r.d128 = TRUE; end;case security of when SS_NonSecure => r.ipaspace = PAS_NonSecure; when SS_Secure => r.ipaspace = if Xt[63] == '1' then PAS_NonSecure else PAS_Secure; when SS_Realm => r.ipaspace = PAS_Realm; otherwise => // Root security state does not have stage 2 translation unreachable; end;
TLBI(r); let domains : bits(16) = TLBIDomains(broadcast, Xt[15:0]); if (broadcast == Broadcast_OSH && (IsBroadcast_OSHnISH() || OSHDomainExceedsNIS(domains))) then broadcast = Broadcast_OSHnISH; end;
if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r, domains); end;
return;
end;
## Library pseudocode for aarch64/functions/tlbi/AArch64\_TLBIP\_RIPAS2
// AArch64_TLBIP_RIPAS2 // ====================== // Range invalidate by IPA all stage 2 only TLB entries in the indicated // broadcast domain matching the indicated VMID in the indicated regime with the indicated // security state. // Note: stage 1 and stage 2 combined entries are not in the scope of this operation. // The range of IPA and related parameters of the are derived from Xt.
func AArch64_TLBIP_RIPAS2(security : SecurityState, regime : Regime, vmid : bits(NUM_VMIDBITS), broadcast_in : Broadcast, level : TLBILevel, attr : TLBIMemAttr, Xt : bits(128)) begin assert PSTATE.EL IN {EL3, EL2}; var broadcast : Broadcast = broadcast_in;
var r : TLBIRecord; r.op = TLBIOp_RIPAS2; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.vmid = vmid; r.use_vmid = TRUE; r.level = level; r.attr = attr; r.ttl[1:0] = Xt[38:37]; if IsFeatureImplemented(FEAT_TLBID) && Xt[32] == '1' then r.d64 = TRUE; r.d128 = r.ttl[1:0] == '00'; else r.d64 = r.ttl[1:0] == '00'; r.d128 = TRUE; end;var valid : boolean; (valid, r.tg, r.address, r.end_address) = TLBIPRange(regime, Xt);
if !valid then return; end;
case security of when SS_NonSecure => r.ipaspace = PAS_NonSecure; when SS_Secure => r.ipaspace = if Xt[63] == '1' then PAS_NonSecure else PAS_Secure; when SS_Realm => r.ipaspace = PAS_Realm; otherwise => // Root security state does not have stage 2 translation unreachable; end;
TLBI(r); let domains : bits(16) = TLBIDomains(broadcast, Xt[15:0]); if (broadcast == Broadcast_OSH && (IsBroadcast_OSHnISH() || OSHDomainExceedsNIS(domains))) then broadcast = Broadcast_OSHnISH; end;
if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r, domains); end;
return;
end;
## Library pseudocode for aarch64/functions/tlbi/AArch64\_TLBIP\_RVA
// AArch64_TLBIP_RVA // =================== // Range invalidate by VA range all stage 1 TLB entries in the indicated // broadcast domain matching the indicated VMID and ASID (where regime // supports VMID, ASID) in the indicated regime with the indicated security state. // ASID, and range related parameters are derived from Xt. // Note: stage 1 and stage 2 combined entries are in the scope of this operation.
func AArch64_TLBIP_RVA(security : SecurityState, regime_in : Regime, vmid_in : bits(NUM_VMIDBITS), broadcast_in : Broadcast, level : TLBILevel, attr_in : TLBIMemAttr, Xt : bits(128)) begin assert PSTATE.EL IN {EL3, EL2, EL1}; var broadcast : Broadcast = AArch64_EffectiveBroadcast(broadcast_in); var attr : TLBIMemAttr = attr_in;
if attr == TLBI_AllAttr && ExcludeXS() then attr = TLBI_ExcludeXS; end;var regime : Regime = regime_in; var vmid : bits(NUM_VMIDBITS) = vmid_in;
if ELIsInHost(EL0) then regime = Regime_EL20; vmid = VMID_NONE; elsif regime == Regime_EL2 && ELIsInHost(EL2) then regime = Regime_EL20; end;
var r : TLBIRecord; r.op = TLBIOp_RVA; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.vmid = vmid; r.use_vmid = UseVMID(regime); r.level = level; r.attr = attr; r.asid = Xt[63:48]; r.ttl[1:0] = Xt[38:37]; if IsFeatureImplemented(FEAT_TLBID) && Xt[32] == '1' then r.d64 = TRUE; r.d128 = r.ttl[1:0] == '00'; else r.d64 = r.ttl[1:0] == '00'; r.d128 = TRUE; end;
var valid : boolean; (valid, r.tg, r.address, r.end_address) = TLBIPRange(regime, Xt);
if !valid then return; end;
TLBI(r); let domains : bits(16) = TLBIDomains(broadcast, Xt[15:0]); if (broadcast == Broadcast_OSH && (IsBroadcast_OSHnISH() || OSHDomainExceedsNIS(domains))) then broadcast = Broadcast_OSHnISH; end;
if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r, domains); end; return;
end;
## Library pseudocode for aarch64/functions/tlbi/AArch64\_TLBIP\_RVAA
// AArch64_TLBIP_RVAA // ==================== // Range invalidate by VA range all stage 1 TLB entries in the indicated // broadcast domain matching the indicated VMID (where regimesupports VMID) // and all ASID in the indicated regime with the indicated security state. // VA range related parameters are derived from Xt. // Note: stage 1 and stage 2 combined entries are in the scope of this operation.
func AArch64_TLBIP_RVAA(security : SecurityState, regime_in : Regime, vmid_in : bits(NUM_VMIDBITS), broadcast_in : Broadcast, level : TLBILevel, attr_in : TLBIMemAttr, Xt : bits(128)) begin assert PSTATE.EL IN {EL3, EL2, EL1}; var broadcast : Broadcast = AArch64_EffectiveBroadcast(broadcast_in); var attr : TLBIMemAttr = attr_in;
if attr == TLBI_AllAttr && ExcludeXS() then attr = TLBI_ExcludeXS; end;var regime : Regime = regime_in; var vmid : bits(NUM_VMIDBITS) = vmid_in;
if ELIsInHost(EL0) then regime = Regime_EL20; vmid = VMID_NONE; end;
var r : TLBIRecord; r.op = TLBIOp_RVAA; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.vmid = vmid; r.use_vmid = UseVMID(regime); r.level = level; r.attr = attr; r.ttl[1:0] = Xt[38:37]; if IsFeatureImplemented(FEAT_TLBID) && Xt[32] == '1' then r.d64 = TRUE; r.d128 = r.ttl[1:0] == '00'; else r.d64 = r.ttl[1:0] == '00'; r.d128 = TRUE; end;
var valid : boolean; (valid, r.tg, r.address, r.end_address) = TLBIPRange(regime, Xt);
if !valid then return; end;
TLBI(r); let domains : bits(16) = TLBIDomains(broadcast, Xt[15:0]); if (broadcast == Broadcast_OSH && (IsBroadcast_OSHnISH() || OSHDomainExceedsNIS(domains))) then broadcast = Broadcast_OSHnISH; end;
if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r, domains); end;
return;
end;
## Library pseudocode for aarch64/functions/tlbi/AArch64\_TLBIP\_VA
// AArch64_TLBIP_VA // ================== // Invalidate by VA all stage 1 TLB entries in the indicated broadcast domain // matching the indicated VMID and ASID (where regime supports VMID, ASID) in the indicated regime // with the indicated security state. // ASID, VA and related parameters are derived from Xt. // Note: stage 1 and stage 2 combined entries are in the scope of this operation.
func AArch64_TLBIP_VA(security : SecurityState, regime_in : Regime, vmid_in : bits(NUM_VMIDBITS), broadcast_in : Broadcast, level : TLBILevel, attr_in : TLBIMemAttr, Xt : bits(128)) begin assert PSTATE.EL IN {EL3, EL2, EL1}; var broadcast : Broadcast = AArch64_EffectiveBroadcast(broadcast_in); var attr : TLBIMemAttr = attr_in;
if attr == TLBI_AllAttr && ExcludeXS() then attr = TLBI_ExcludeXS; end;var regime : Regime = regime_in; var vmid : bits(NUM_VMIDBITS) = vmid_in;
if regime == Regime_EL10 && ELIsInHost(EL0) then regime = Regime_EL20; vmid = VMID_NONE; elsif regime == Regime_EL2 && ELIsInHost(EL2) then regime = Regime_EL20; end;
var r : TLBIRecord; r.op = TLBIOp_VA; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.vmid = vmid; r.use_vmid = UseVMID(regime); r.level = level; r.attr = attr; r.asid = Xt[63:48]; r.ttl = Xt[47:44]; r.address = ZeroExtend{64}(Xt[107:64] :: Zeros{12}); if IsFeatureImplemented(FEAT_TLBID) && Xt[32] == '1' then r.d64 = TRUE; r.d128 = r.ttl == '00xx'; else r.d64 = r.ttl == '00xx'; r.d128 = TRUE; end;
TLBI(r); let domains : bits(16) = TLBIDomains(broadcast, Xt[15:0]); if (broadcast == Broadcast_OSH && (IsBroadcast_OSHnISH() || OSHDomainExceedsNIS(domains))) then broadcast = Broadcast_OSHnISH; end;
if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r, domains); end;
return;
end;
## Library pseudocode for aarch64/functions/tlbi/AArch64\_TLBIP\_VAA
// AArch64_TLBIP_VAA // =================== // Invalidate by VA all stage 1 TLB entries in the indicated broadcast domain // matching the indicated VMID (where regime supports VMID) and all ASID in the indicated regime // with the indicated security state. // VA and related parameters are derived from Xt. // Note: stage 1 and stage 2 combined entries are in the scope of this operation.
func AArch64_TLBIP_VAA(security : SecurityState, regime_in : Regime, vmid_in : bits(NUM_VMIDBITS), broadcast_in : Broadcast, level : TLBILevel, attr_in : TLBIMemAttr, Xt : bits(128)) begin assert PSTATE.EL IN {EL3, EL2, EL1}; var broadcast : Broadcast = AArch64_EffectiveBroadcast(broadcast_in); var attr : TLBIMemAttr = attr_in;
if attr == TLBI_AllAttr && ExcludeXS() then attr = TLBI_ExcludeXS; end;var regime : Regime = regime_in; var vmid : bits(NUM_VMIDBITS) = vmid_in; if ELIsInHost(EL0) then regime = Regime_EL20; vmid = VMID_NONE; end;
var r : TLBIRecord; r.op = TLBIOp_VAA; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.vmid = vmid; r.use_vmid = UseVMID(regime); r.level = level; r.attr = attr; r.ttl = Xt[47:44]; r.address = ZeroExtend{64}(Xt[107:64] :: Zeros{12}); if IsFeatureImplemented(FEAT_TLBID) && Xt[32] == '1' then r.d64 = TRUE; r.d128 = r.ttl == '00xx'; else r.d64 = r.ttl == '00xx'; r.d128 = TRUE; end;
TLBI(r); let domains : bits(16) = TLBIDomains(broadcast, Xt[15:0]); if (broadcast == Broadcast_OSH && (IsBroadcast_OSHnISH() || OSHDomainExceedsNIS(domains))) then broadcast = Broadcast_OSHnISH; end;
if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r, domains); end;
return;
end;
## Library pseudocode for aarch64/functions/tlbi/AArch64\_TLBI\_ALL
// AArch64_TLBI_ALL // ================== // Invalidate all entries for the indicated translation regime with the // the indicated security state for all TLBs within the indicated broadcast domain. // Invalidation applies to all applicable stage 1 and stage 2 entries.
func AArch64_TLBI_ALL(security : SecurityState, regime : Regime, broadcast_in : Broadcast, attr : TLBIMemAttr, Xt : bits(64)) begin assert PSTATE.EL IN {EL3, EL2}; var broadcast : Broadcast = broadcast_in;
var r : TLBIRecord; r.op = TLBIOp_ALL; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.level = TLBILevel_Any; r.attr = attr;TLBI(r); let domains : bits(16) = TLBIDomains(broadcast, Xt[15:0]); if (broadcast == Broadcast_OSH && (IsBroadcast_OSHnISH() || OSHDomainExceedsNIS(domains))) then broadcast = Broadcast_OSHnISH; end;
if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r, domains); end; return;
end;
## Library pseudocode for aarch64/functions/tlbi/AArch64\_TLBI\_ASID
// AArch64_TLBI_ASID // =================== // Invalidate all stage 1 entries matching the indicated VMID (where regime supports) // and ASID in the parameter Xt in the indicated translation regime with the // indicated security state for all TLBs within the indicated broadcast domain. // Note: stage 1 and stage 2 combined entries are in the scope of this operation.
func AArch64_TLBI_ASID(security : SecurityState, regime_in : Regime, vmid_in : bits(NUM_VMIDBITS), broadcast_in : Broadcast, attr_in : TLBIMemAttr, Xt : bits(64)) begin assert PSTATE.EL IN {EL3, EL2, EL1}; var broadcast : Broadcast = AArch64_EffectiveBroadcast(broadcast_in); var attr : TLBIMemAttr = attr_in;
if attr == TLBI_AllAttr && ExcludeXS() then attr = TLBI_ExcludeXS; end;var regime : Regime = regime_in; var vmid : bits(NUM_VMIDBITS) = vmid_in;
if ELIsInHost(EL0) then regime = Regime_EL20; vmid = VMID_NONE; end;
var r : TLBIRecord; r.op = TLBIOp_ASID; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.vmid = vmid; r.use_vmid = UseVMID(regime); r.level = TLBILevel_Any; r.attr = attr; r.asid = Xt[63:48];
TLBI(r); let domains : bits(16) = TLBIDomains(broadcast, Xt[15:0]); if (broadcast == Broadcast_OSH && (IsBroadcast_OSHnISH() || OSHDomainExceedsNIS(domains))) then broadcast = Broadcast_OSHnISH; end;
if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r, domains); end;
return;
end;
## Library pseudocode for aarch64/functions/tlbi/AArch64\_TLBI\_IPAS2
// AArch64_TLBI_IPAS2 // ==================== // Invalidate by IPA all stage 2 only TLB entries in the indicated broadcast // domain matching the indicated VMID in the indicated regime with the indicated security state. // Note: stage 1 and stage 2 combined entries are not in the scope of this operation. // IPA and related parameters of the are derived from Xt.
func AArch64_TLBI_IPAS2(security : SecurityState, regime : Regime, vmid : bits(NUM_VMIDBITS), broadcast_in : Broadcast, level : TLBILevel, attr : TLBIMemAttr, Xt : bits(64)) begin assert PSTATE.EL IN {EL3, EL2}; var broadcast : Broadcast = broadcast_in;
var r : TLBIRecord; r.op = TLBIOp_IPAS2; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.vmid = vmid; r.use_vmid = TRUE; r.level = level; r.attr = attr; r.ttl = Xt[47:44]; r.address = ZeroExtend{64}(Xt[39:0] :: Zeros{12}); r.d64 = TRUE; r.d128 = r.ttl == '00xx';case security of when SS_NonSecure => r.ipaspace = PAS_NonSecure; when SS_Secure => r.ipaspace = if Xt[63] == '1' then PAS_NonSecure else PAS_Secure; when SS_Realm => r.ipaspace = PAS_Realm; otherwise => // Root security state does not have stage 2 translation unreachable; end;
TLBI(r); if broadcast == Broadcast_OSH && IsBroadcast_OSHnISH() then broadcast = Broadcast_OSHnISH; end; if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r); end;
return;
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. // 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\_RIPAS2
// AArch64_TLBI_RIPAS2 // ===================== // Range invalidate by IPA all stage 2 only TLB entries in the indicated // broadcast domain matching the indicated VMID in the indicated regime with the indicated // security state. // Note: stage 1 and stage 2 combined entries are not in the scope of this operation. // The range of IPA and related parameters of the are derived from Xt.
func AArch64_TLBI_RIPAS2(security : SecurityState, regime : Regime, vmid : bits(NUM_VMIDBITS), broadcast_in : Broadcast, level : TLBILevel, attr : TLBIMemAttr, Xt : bits(64)) begin assert PSTATE.EL IN {EL3, EL2}; var broadcast : Broadcast = broadcast_in;
var r : TLBIRecord; r.op = TLBIOp_RIPAS2; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.vmid = vmid; r.use_vmid = TRUE; r.level = level; r.attr = attr; r.ttl[1:0] = Xt[38:37]; r.d64 = TRUE; r.d128 = r.ttl[1:0] == '00';var valid : boolean; (valid, r.tg, r.address, r.end_address) = TLBIRange(regime, Xt);
if !valid then return; end;
case security of when SS_NonSecure => r.ipaspace = PAS_NonSecure; when SS_Secure => r.ipaspace = if Xt[63] == '1' then PAS_NonSecure else PAS_Secure; when SS_Realm => r.ipaspace = PAS_Realm; otherwise => // Root security state does not have stage 2 translation unreachable; end;
TLBI(r); if broadcast == Broadcast_OSH && IsBroadcast_OSHnISH() then broadcast = Broadcast_OSHnISH; end; 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. // 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/AArch64\_TLBI\_RVA
// AArch64_TLBI_RVA // ================== // Range invalidate by VA range all stage 1 TLB entries in the indicated // broadcast domain matching the indicated VMID and ASID (where regime // supports VMID, ASID) in the indicated regime with the indicated security state. // ASID, and range related parameters are derived from Xt. // Note: stage 1 and stage 2 combined entries are in the scope of this operation.
func AArch64_TLBI_RVA(security : SecurityState, regime_in : Regime, vmid_in : bits(NUM_VMIDBITS), broadcast_in : Broadcast, level : TLBILevel, attr_in : TLBIMemAttr, Xt : bits(64)) begin assert PSTATE.EL IN {EL3, EL2, EL1}; var broadcast : Broadcast = AArch64_EffectiveBroadcast(broadcast_in); var attr : TLBIMemAttr = attr_in;
if attr == TLBI_AllAttr && ExcludeXS() then attr = TLBI_ExcludeXS; end;var regime : Regime = regime_in; var vmid : bits(NUM_VMIDBITS) = vmid_in;
if regime == Regime_EL10 && ELIsInHost(EL0) then regime = Regime_EL20; vmid = VMID_NONE; elsif regime == Regime_EL2 && ELIsInHost(EL2) then regime = Regime_EL20; end;
var r : TLBIRecord; r.op = TLBIOp_RVA; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.vmid = vmid; r.use_vmid = UseVMID(regime); r.level = level; r.attr = attr; r.asid = Xt[63:48]; r.ttl[1:0] = Xt[38:37]; r.d64 = TRUE; r.d128 = r.ttl[1:0] == '00';
var valid : boolean; (valid, r.tg, r.address, r.end_address) = TLBIRange(regime, Xt);
if !valid then return; end;
TLBI(r); if broadcast == Broadcast_OSH && IsBroadcast_OSHnISH() then broadcast = Broadcast_OSHnISH; end; if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r); end; return;
end;
## Library pseudocode for aarch64/functions/tlbi/AArch64\_TLBI\_RVAA
// AArch64_TLBI_RVAA // =================== // Range invalidate by VA range all stage 1 TLB entries in the indicated // broadcast domain matching the indicated VMID (where regimesupports VMID) // and all ASID in the indicated regime with the indicated security state. // VA range related parameters are derived from Xt. // Note: stage 1 and stage 2 combined entries are in the scope of this operation.
func AArch64_TLBI_RVAA(security : SecurityState, regime_in : Regime, vmid_in : bits(NUM_VMIDBITS), broadcast_in : Broadcast, level : TLBILevel, attr_in : TLBIMemAttr, Xt : bits(64)) begin assert PSTATE.EL IN {EL3, EL2, EL1}; var broadcast : Broadcast = AArch64_EffectiveBroadcast(broadcast_in); var attr : TLBIMemAttr = attr_in;
if attr == TLBI_AllAttr && ExcludeXS() then attr = TLBI_ExcludeXS; end;var regime : Regime = regime_in; var vmid : bits(NUM_VMIDBITS) = vmid_in;
if ELIsInHost(EL0) then regime = Regime_EL20; vmid = VMID_NONE; end;
var r : TLBIRecord; r.op = TLBIOp_RVAA; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.vmid = vmid; r.use_vmid = UseVMID(regime); r.level = level; r.attr = attr; r.ttl[1:0] = Xt[38:37]; r.d64 = TRUE; r.d128 = r.ttl[1:0] == '00';
var valid : boolean; (valid, r.tg, r.address, r.end_address) = TLBIRange(regime, Xt);
if !valid then return; end;
TLBI(r); if broadcast == Broadcast_OSH && IsBroadcast_OSHnISH() then broadcast = Broadcast_OSHnISH; end;
if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r); end; return;
end;
## Library pseudocode for aarch64/functions/tlbi/AArch64\_TLBI\_VA
// AArch64_TLBI_VA // ================= // Invalidate by VA all stage 1 TLB entries in the indicated broadcast domain // matching the indicated VMID and ASID (where regime supports VMID, ASID) in the indicated regime // with the indicated security state. // ASID, VA and related parameters are derived from Xt. // Note: stage 1 and stage 2 combined entries are in the scope of this operation.
func AArch64_TLBI_VA(security : SecurityState, regime_in : Regime, vmid_in : bits(NUM_VMIDBITS), broadcast_in : Broadcast, level : TLBILevel, attr_in : TLBIMemAttr, Xt : bits(64)) begin assert PSTATE.EL IN {EL3, EL2, EL1}; var broadcast : Broadcast = AArch64_EffectiveBroadcast(broadcast_in); var attr : TLBIMemAttr = attr_in;
if attr == TLBI_AllAttr && ExcludeXS() then attr = TLBI_ExcludeXS; end;var regime : Regime = regime_in; var vmid : bits(NUM_VMIDBITS) = vmid_in; if regime == Regime_EL10 && ELIsInHost(EL0) then regime = Regime_EL20; vmid = VMID_NONE; elsif regime == Regime_EL2 && ELIsInHost(EL2) then regime = Regime_EL20; end;
var r : TLBIRecord; r.op = TLBIOp_VA; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.vmid = vmid; r.use_vmid = UseVMID(regime); r.level = level; r.attr = attr; r.asid = Xt[63:48]; r.ttl = Xt[47:44]; r.address = ZeroExtend{64}(Xt[43:0] :: Zeros{12}); r.d64 = TRUE; r.d128 = r.ttl == '00xx';
TLBI(r); if broadcast == Broadcast_OSH && IsBroadcast_OSHnISH() then broadcast = Broadcast_OSHnISH; end; if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r); end;
return;
end;
## Library pseudocode for aarch64/functions/tlbi/AArch64\_TLBI\_VAA
// AArch64_TLBI_VAA // ================== // Invalidate by VA all stage 1 TLB entries in the indicated broadcast domain // matching the indicated VMID (where regime supports VMID) and all ASID in the indicated regime // with the indicated security state. // VA and related parameters are derived from Xt. // Note: stage 1 and stage 2 combined entries are in the scope of this operation.
func AArch64_TLBI_VAA(security : SecurityState, regime_in : Regime, vmid_in : bits(NUM_VMIDBITS), broadcast_in : Broadcast, level : TLBILevel, attr_in : TLBIMemAttr, Xt : bits(64)) begin assert PSTATE.EL IN {EL3, EL2, EL1}; var broadcast : Broadcast = AArch64_EffectiveBroadcast(broadcast_in); var attr : TLBIMemAttr = attr_in;
if attr == TLBI_AllAttr && ExcludeXS() then attr = TLBI_ExcludeXS; end;var regime : Regime = regime_in; var vmid : bits(NUM_VMIDBITS) = vmid_in; if ELIsInHost(EL0) then regime = Regime_EL20; vmid = VMID_NONE; end;
var r : TLBIRecord; r.op = TLBIOp_VAA; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.vmid = vmid; r.use_vmid = UseVMID(regime); r.level = level; r.attr = attr; r.ttl = Xt[47:44]; r.address = ZeroExtend{64}(Xt[43:0] :: Zeros{12}); r.d64 = TRUE; r.d128 = r.ttl == '00xx';
TLBI(r); if broadcast == Broadcast_OSH && IsBroadcast_OSHnISH() then broadcast = Broadcast_OSHnISH; end; if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r); end;
return;
end;
## Library pseudocode for aarch64/functions/tlbi/AArch64\_TLBI\_VMALL
// AArch64_TLBI_VMALL // ==================== // Invalidate all stage 1 entries for the indicated translation regime with the // the indicated security state for all TLBs within the indicated broadcast // domain that match the indicated VMID (where applicable). // Note: stage 1 and stage 2 combined entries are in the scope of this operation. // Note: stage 2 only entries are not in the scope of this operation.
func AArch64_TLBI_VMALL(security : SecurityState, regime_in : Regime, vmid_in : bits(NUM_VMIDBITS), broadcast_in : Broadcast, attr_in : TLBIMemAttr, Xt : bits(64)) begin assert PSTATE.EL IN {EL3, EL2, EL1}; var broadcast : Broadcast = AArch64_EffectiveBroadcast(broadcast_in); var attr : TLBIMemAttr = attr_in;
if attr == TLBI_AllAttr && ExcludeXS() then attr = TLBI_ExcludeXS; end;var regime : Regime = regime_in; var vmid : bits(NUM_VMIDBITS) = vmid_in;
if ELIsInHost(EL0) then regime = Regime_EL20; vmid = VMID_NONE; end;
var r : TLBIRecord; r.op = TLBIOp_VMALL; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.level = TLBILevel_Any; r.vmid = vmid; r.use_vmid = UseVMID(regime); r.attr = attr;
TLBI(r); let domains : bits(16) = TLBIDomains(broadcast, Xt[15:0]); if (broadcast == Broadcast_OSH && (IsBroadcast_OSHnISH() || OSHDomainExceedsNIS(domains))) then broadcast = Broadcast_OSHnISH; end;
if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r, domains); end;
return;
end;
## Library pseudocode for aarch64/functions/tlbi/AArch64\_TLBI\_VMALLS12
// AArch64_TLBI_VMALLS12 // ======================= // Invalidate all stage 1 and stage 2 entries for the indicated translation // regime with the indicated security state for all TLBs within the indicated // broadcast domain that match the indicated VMID.
func AArch64_TLBI_VMALLS12(security : SecurityState, regime : Regime, vmid : bits(NUM_VMIDBITS), broadcast_in : Broadcast, attr : TLBIMemAttr, Xt : bits(64)) begin assert PSTATE.EL IN {EL3, EL2}; var broadcast : Broadcast = AArch64_EffectiveBroadcast(broadcast_in);
var r : TLBIRecord; r.op = TLBIOp_VMALLS12; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.level = TLBILevel_Any; r.vmid = vmid; r.use_vmid = TRUE; r.attr = attr;TLBI(r); let domains : bits(16) = TLBIDomains(broadcast, Xt[15:0]); if (broadcast == Broadcast_OSH && (IsBroadcast_OSHnISH() || OSHDomainExceedsNIS(domains))) then broadcast = Broadcast_OSHnISH; end;
if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r, domains); end;
return;
end;
## Library pseudocode for aarch64/functions/tlbi/AArch64\_TLBI\_VMALLWS2
// AArch64_TLBI_VMALLWS2 // ======================= // Remove stage 2 dirty state from entries for the indicated translation regime // with the indicated security state for all TLBs within the indicated broadcast // domain that match the indicated VMID.
func AArch64_TLBI_VMALLWS2(security : SecurityState, regime : Regime, vmid : bits(16), broadcast_in : Broadcast, attr : TLBIMemAttr, Xt : bits(64)) begin assert PSTATE.EL IN {EL3, EL2}; assert regime == Regime_EL10;
if security == SS_Secure && HaveEL(EL3) && SCR_EL3().EEL2 == '0' then return; end;var broadcast : Broadcast = broadcast_in;
var r : TLBIRecord; r.op = TLBIOp_VMALLWS2; r.from_aarch64 = TRUE; r.security = security; r.regime = regime; r.level = TLBILevel_Any; r.vmid = vmid; r.use_vmid = TRUE; r.attr = attr;
TLBI(r); let domains : bits(16) = TLBIDomains(broadcast, Xt[15:0]); if (broadcast == Broadcast_OSH && (IsBroadcast_OSHnISH() || OSHDomainExceedsNIS(domains))) then broadcast = Broadcast_OSHnISH; end;
if broadcast != Broadcast_NSH then BroadcastTLBI(broadcast, r, domains); end;
return;
end;
## Library pseudocode for aarch64/functions/tlbi/DecodeTLBITG
// DecodeTLBITG // ============== // Decode translation granule size in TLBI range instructions
func DecodeTLBITG(tg : bits(2)) => TGx begin case tg of when '01' => return TGx_4KB; when '10' => return TGx_16KB; when '11' => return TGx_64KB; end; end;
## Library pseudocode for aarch64/functions/tlbi/GPTTLBIMatch
// GPTTLBIMatch // ============== // Determine whether the GPT TLB entry lies within the scope of invalidation
func GPTTLBIMatch(tlbi : TLBIRecord, gpt_entry : GPTEntry) => boolean begin assert tlbi.op IN {TLBIOp_RPA, TLBIOp_PAALL};
var match : boolean; let entry_size_mask : bits(64) = ZeroExtend{}(Ones{gpt_entry.size}); let entry_end_address : bits(64) = (ZeroExtend{64}(gpt_entry.pa[NUM_PABITS-1:0] OR entry_size_mask[NUM_PABITS-1:0])); let entry_start_address : bits(64) = (ZeroExtend{64}(gpt_entry.pa[NUM_PABITS-1:0] AND NOT entry_size_mask[NUM_PABITS-1:0]));case tlbi.op of when TLBIOp_RPA => match = ((UInt(tlbi.address[NUM_PABITS-1:0]) <= UInt(entry_end_address[NUM_PABITS-1:0])) && (UInt(tlbi.end_address[NUM_PABITS-1:0]) > UInt(entry_start_address[NUM_PABITS-1:0])) && (tlbi.level == TLBILevel_Any || !gpt_entry.istable)); when TLBIOp_PAALL => match = TRUE; end;
return match;
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'; when Regime_EL20 => return TCR_EL2().E2H1.DS == '1'; when Regime_EL10 => return TCR_EL1().DS == '1'; otherwise => unreachable; end; end;
## Library pseudocode for aarch64/functions/tlbi/IsBroadcast\_OSHnISH
// IsBroadcast_OSHnISH // ===================== // Returns TRUE if a TLBI OS instruction affects TLBs in the Outer shareability domain, // but not in the Inner shareability domain.
readonly func IsBroadcast_OSHnISH() => boolean begin case PSTATE.EL of when EL3 => return FALSE; when EL2 => return IsSCTLR2EL2Enabled() && SCTLR2_EL2().TLBOSNIS == '1'; when EL1 => return IsSCTLR2EL1Enabled() && SCTLR2_EL1().TLBOSNIS == '1'; otherwise => unreachable; end; end;
## Library pseudocode for aarch64/functions/tlbi/OSHDomainExceedsNIS
// OSHDomainExceedsNIS // ===================== // Returns TRUE if a TLBI OS instruction affects TLBs in the Outer shareability domain, // but not in the Inner shareability domain.
readonly func OSHDomainExceedsNIS(domains : bits(16)) => boolean begin // If the TLBID value exceeds the supported value in TLBIDIDR_EL1.NIS, then no TLBs in the // Inner Shareable shareability domain are guaranteed to be affected by the TLBI operation. let nis : integer{} = UInt(TLBIDIDR_EL1().NIS); return nis < 16 && !IsZero(domains[15:nis]); end;
## Library pseudocode for aarch64/functions/tlbi/ResTLBIRTTL
// ResTLBIRTTL // ============= // Determine whether the TTL field in TLBI instructions that do apply // to a range of addresses contains a reserved value
func ResTLBIRTTL(tg : bits(2), ttl : bits(2)) => boolean begin case ttl of when '00' => return TRUE; when '01' => return DecodeTLBITG(tg) == TGx_16KB && !IsFeatureImplemented(FEAT_LPA2); otherwise => return FALSE; end; end;
## Library pseudocode for aarch64/functions/tlbi/ResTLBITTL
// ResTLBITTL // ============ // Determine whether the TTL field in TLBI instructions that do not apply // to a range of addresses contains a reserved value
func ResTLBITTL(ttl : bits(4)) => boolean begin case ttl of when '00xx' => return TRUE; when '0100' => return !IsFeatureImplemented(FEAT_LPA2); when '1000' => return TRUE; when '1001' => return !IsFeatureImplemented(FEAT_LPA2); when '1100' => return TRUE; otherwise => return FALSE; end; end;
## Library pseudocode for aarch64/functions/tlbi/TGBits
// TGBits // ======== // Return the number of least-significant address bits within a single Translation Granule.
func TGBits(tg : bits(2)) => AddressSize begin case tg of when '01' => return 12; // 4KB when '10' => return 14; // 16KB when '11' => return 16; // 64KB otherwise => unreachable; end; end;
## Library pseudocode for aarch64/functions/tlbi/TLBIDomains
// TLBIDomains // ============= // Determine the domains the TLBI operation is broadcast to
readonly func TLBIDomains(broadcast_in : Broadcast, tlbid_in : bits(16)) => bits(16) begin assert broadcast_in != Broadcast_OSHnISH;
var broadcast : Broadcast = broadcast_in; var tlbid : bits(16) = tlbid_in;if !IsFeatureImplemented(FEAT_TLBID) then return DEFAULT_TLBI_DOMAIN; end; if broadcast == Broadcast_NSH then return DEFAULT_TLBI_DOMAIN; end; if broadcast == Broadcast_ISH_CnP then return DEFAULT_TLBI_DOMAIN; end; if PSTATE.EL == EL3 then return DEFAULT_TLBI_DOMAIN; end; if PSTATE.EL == EL0 && HCR_EL2().TGE == '1' then return DEFAULT_TLBI_DOMAIN; end;
let nos : integer{} = UInt(TLBIDIDR_EL1().NOS); assert nos <= 16; if broadcast == Broadcast_OSH && nos == 0 then return DEFAULT_TLBI_DOMAIN; end;
let nis : integer{} = UInt(TLBIDIDR_EL1().NIS); assert nis <= 16; if broadcast == Broadcast_ISH && nis == 0 then return DEFAULT_TLBI_DOMAIN; end;
if PSTATE.EL == EL2 then if broadcast == Broadcast_OSH then return ZeroExtend{16}(tlbid[nos-1:0]); else // Broadcast_ISH return ZeroExtend{16}(tlbid[nis-1:0]); end; end;
assert PSTATE.EL == EL1 || (PSTATE.EL == EL0 && HCR_EL2().TGE == '0');
if broadcast == Broadcast_ForcedISH then // For a TLBI instruction without an IS or OS qualifier executed at EL1, if HCR_EL2.FB // is 1 then the process for a TLBI IS instruction is followed as though TLBID is zero. broadcast = Broadcast_ISH; tlbid = Zeros{16}; end;
assert broadcast IN {Broadcast_ISH, Broadcast_OSH};
// If the Effective value of VTLBID(OS)En is 0 the TLBID field is not transformed. if ((HaveEL(EL3) && SCR_EL3().VTLBIDEn == '0') || () || (broadcast == Broadcast_OSH && HCRX_EL2().VTLBIDOSEn == '0') || (broadcast == Broadcast_ISH && HCRX_EL2().VTLBIDEn == '0')) then if broadcast == Broadcast_OSH then return ZeroExtend{16}(tlbid[nos-1:0]); else // Broadcast_ISH return ZeroExtend{16}(tlbid[nis-1:0]); end; end;
if broadcast == Broadcast_OSH then let nvos : integer{} = UInt(TLBIDIDR_EL1().NVOS); assert (nos <= 8 && nvos <= 5) || (nos <= 16 && nvos <= 4);
// If NVOS is 0, the TLBID field is ignored as only VTLBIDOS[n]_EL2.TD0 is implemented.let d : integer{} = if nvos == 0 then 0 else UInt(tlbid[nvos-1:0]);let s : integer{} = if nos <= 8 then 8 else 4;let n : integer = d DIVRM s;let m : integer = d MOD s;var vtlbid : bits(16);if nos <= 8 then vtlbid = ZeroExtend{16}(VTLBIDOS_EL2(n)[8*m+:8]);else vtlbid = VTLBIDOS_EL2(n)[16*m+:16];end;return ZeroExtend{16}(vtlbid[nos-1:0]);else // Broadcast_ISH let nvis : integer{} = UInt(TLBIDIDR_EL1().NVIS); assert (nis <= 8 && nvis <= 5) || (nis <= 16 && nvis <= 4);
// If NVIS is 0, the TLBID field is ignored as only VTLBID[n]_EL2.TD0 is implemented.let d : integer{} = if nvis == 0 then 0 else UInt(tlbid[nvis-1:0]);let s : integer{} = if nis <= 8 then 8 else 4;let n : integer = d DIVRM s;let m : integer = d MOD s;var vtlbid : bits(16);if nis <= 8 then vtlbid = ZeroExtend{16}(VTLBID_EL2(n)[8*m+:8]);else vtlbid = VTLBID_EL2(n)[16*m+:16];end;return ZeroExtend{16}(vtlbid[nis-1:0]);
end;
end;
## Library pseudocode for aarch64/functions/tlbi/TLBIMatch
// TLBIMatch // =========== // Determine whether the TLB entry lies within the scope of invalidation
func TLBIMatch(tlbi : TLBIRecord, tlb_entry : TLBRecord) => boolean begin var match : boolean; let entry_block_mask : bits(64) = ZeroExtend{}(Ones{tlb_entry.blocksize}); var entry_end_address : bits(64) = tlb_entry.context.ia OR entry_block_mask; var entry_start_address : bits(64) = tlb_entry.context.ia AND NOT entry_block_mask; case tlbi.op of when TLBIOp_DALL, TLBIOp_IALL => match = (tlbi.security == tlb_entry.context.ss && tlbi.regime == tlb_entry.context.regime && tlbi.use_vmid == tlb_entry.context.use_vmid && (!tlb_entry.context.use_vmid || tlbi.vmid == tlb_entry.context.vmid)); when TLBIOp_DASID, TLBIOp_IASID => match = (tlb_entry.context.includes_s1 && tlbi.security == tlb_entry.context.ss &&