[Writeup] Shared pseudocode: part 17 of 36 ========================================== Section: Silicon & Architectures Started: 2026-11-28 17:46 UTC by admin Replies: 0, last post 2026-11-28 17:46 UTC Page: 1 of 1 Web: https://romdump.net/t/109 ------------------------------------------------------------------------------ #129 admin, 2026-11-28 17:46 UTC [OP] Source: https://romdump.net/raw/129

Shared pseudocode from the offline Arm documentation snapshot. Part 17 of 36.

        return FALSE;
    end;

    // Check for 'xy00xy00xy00xy00'
    if imm[63:32] == imm[31:0] && imm[31:16] == imm[15:0] then
        return FALSE;
    end;
end;

return TRUE;

end;


## Library pseudocode for aarch64/functions/sve/SetPSTATE\_SM

// SetPSTATE_SM // ==============

func SetPSTATE_SM(value : bit) begin if PSTATE.SM != value then ResetSVEState(); PSTATE.SM = value; end; end;


## Library pseudocode for aarch64/functions/sve/SetPSTATE\_ZA

// SetPSTATE_ZA // ==============

func SetPSTATE_ZA(value : bit) begin if PSTATE.ZA != value then ResetSMEState(value); PSTATE.ZA = value; end; end;


## Library pseudocode for aarch64/functions/sve/SupportedPowerTwoSVL

// SupportedPowerTwoSVL // ====================== // Return an IMPLEMENTATION DEFINED specific value // returns TRUE if SVL is supported and is a power of two, FALSE otherwise

readonly impdef func SupportedPowerTwoSVL(nbits : integer) => boolean begin return IsPow2(nbits) && (nbits <= MAX_VL); end;


## Library pseudocode for aarch64/functions/sve/System

// System Registers // ================

constant MAX_VL : VecLen = 2048; constant MAX_PL : PredLen = 256; constant ZT0_LEN : integer{} = 512; var _Z : array [[32]] of bits(MAX_VL); var _P : array [[16]] of bits(MAX_PL); var _FFR : bits(MAX_PL);


## Library pseudocode for aarch64/functions/sve/VecLen

// VecLen // ======

type VecLen of integer{128, 256, 512, 1024, 2048};


## Library pseudocode for aarch64/functions/sve/Z

// Z - accessor // ============

accessor Z{width}(n : integer) <=> value : bits(width) begin getter assert n >= 0 && n <= 31; assert width == CurrentVL(); return _Z[[n]][width-1:0]; end; setter assert n >= 0 && n <= 31; assert width == CurrentVL(); if ConstrainUnpredictableBool(Unpredictable_SVEZEROUPPER) then _Z[[n]] = ZeroExtend{MAX_VL}(value); else _Z[[n]][width-1:0] = value; end; end; 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_SRLS, SystemHintOp_CSDB };


## Library pseudocode for aarch64/functions/syslop/SysLOp

// SysLOp // ========

func SysLOp(op1 : bits(3), CRn : bits(4), CRm : bits(4), op2 : bits(3)) => SystemLOp begin case op1::CRn::CRm::op2 of when '000 1100 0011 000' => return Sysl_GICR; // CDIA when '000 1100 0011 001' => return Sysl_GICR; // CDNMIA otherwise => return Sysl_SYSL; end; end;


## Library pseudocode for aarch64/functions/syslop/SystemLOp

// SystemLOp // ========= // System instruction with result types.

type SystemLOp of enumeration { Sysl_GICR, Sysl_SYSL };


## Library pseudocode for aarch64/functions/sysop/SysOp

// SysOp // =======

func SysOp(op1 : bits(3), CRn : bits(4), CRm : bits(4), op2 : bits(3)) => SystemOp begin case op1::CRn::CRm::op2 of when '000 0111 1000 000' => return Sys_AT; // S1E1R when '000 0111 1000 001' => return Sys_AT; // S1E1W when '000 0111 1000 010' => return Sys_AT; // S1E0R when '000 0111 1000 011' => return Sys_AT; // S1E0W when '000 0111 1001 000' => return Sys_AT; // S1E1RP when '000 0111 1001 001' => return Sys_AT; // S1E1WP when '000 0111 1001 010' => return Sys_AT; // S1E1A when '100 0111 1000 000' => return Sys_AT; // S1E2R when '100 0111 1000 001' => return Sys_AT; // S1E2W when '100 0111 1001 010' => return Sys_AT; // S1E2A when '100 0111 1000 100' => return Sys_AT; // S12E1R when '100 0111 1000 101' => return Sys_AT; // S12E1W when '100 0111 1000 110' => return Sys_AT; // S12E0R when '100 0111 1000 111' => return Sys_AT; // S12E0W when '110 0111 1000 000' => return Sys_AT; // S1E3R when '110 0111 1000 001' => return Sys_AT; // S1E3W when '110 0111 1001 010' => return Sys_AT; // S1E3A when '001 0111 0010 100' => return Sys_BRB; // IALL when '001 0111 0010 101' => return Sys_BRB; // INJ when '000 0111 0110 001' => return Sys_DC; // IVAC when '000 0111 0110 010' => return Sys_DC; // ISW when '000 0111 0110 011' => return Sys_DC; // IGVAC when '000 0111 0110 100' => return Sys_DC; // IGSW when '000 0111 0110 101' => return Sys_DC; // IGDVAC when '000 0111 0110 110' => return Sys_DC; // IGDSW when '000 0111 1010 010' => return Sys_DC; // CSW when '000 0111 1010 100' => return Sys_DC; // CGSW when '000 0111 1010 110' => return Sys_DC; // CGDSW when '000 0111 1110 010' => return Sys_DC; // CISW when '000 0111 1110 100' => return Sys_DC; // CIGSW when '000 0111 1110 110' => return Sys_DC; // CIGDSW when '011 0111 0100 001' => return Sys_DC; // ZVA when '011 0111 0100 011' => return Sys_DC; // GVA when '011 0111 0100 100' => return Sys_DC; // GZVA when '011 0111 1010 001' => return Sys_DC; // CVAC when '011 0111 1010 011' => return Sys_DC; // CGVAC when '011 0111 1010 101' => return Sys_DC; // CGDVAC when '011 0111 1011 001' => return Sys_DC; // CVAU when '011 0111 1100 001' => return Sys_DC; // CVAP when '011 0111 1100 011' => return Sys_DC; // CGVAP when '011 0111 1100 101' => return Sys_DC; // CGDVAP when '011 0111 1101 001' => return Sys_DC; // CVADP when '011 0111 1101 011' => return Sys_DC; // CGVADP when '011 0111 1101 101' => return Sys_DC; // CGDVADP when '011 0111 1110 001' => return Sys_DC; // CIVAC when '011 0111 1110 011' => return Sys_DC; // CIGVAC when '011 0111 1110 101' => return Sys_DC; // CIGDVAC when '100 0111 1110 000' => return Sys_DC; // CIPAE when '100 0111 1110 111' => return Sys_DC; // CIGDPAE when '110 0111 1110 001' => return Sys_DC; // CIPAPA when '110 0111 1110 101' => return Sys_DC; // CIGDPAPA when '000 0111 1111 001' => return Sys_DC; // CIVAPS when '000 0111 1111 101' => return Sys_DC; // CIGDVAPS when '000 0111 0001 000' => return Sys_IC; // IALLUIS when '000 0111 0101 000' => return Sys_IC; // IALLU when '011 0111 0101 001' => return Sys_IC; // IVAU when '000 1000 0001 000' => return Sys_TLBI; // VMALLE1OS when '000 1000 0001 001' => return Sys_TLBI; // VAE1OS when '000 1000 0001 010' => return Sys_TLBI; // ASIDE1OS when '000 1000 0001 011' => return Sys_TLBI; // VAAE1OS when '000 1000 0001 101' => return Sys_TLBI; // VALE1OS when '000 1000 0001 111' => return Sys_TLBI; // VAALE1OS when '000 1000 0010 001' => return Sys_TLBI; // RVAE1IS when '000 1000 0010 011' => return Sys_TLBI; // RVAAE1IS when '000 1000 0010 101' => return Sys_TLBI; // RVALE1IS when '000 1000 0010 111' => return Sys_TLBI; // RVAALE1IS when '000 1000 0011 000' => return Sys_TLBI; // VMALLE1IS when '000 1000 0011 001' => return Sys_TLBI; // VAE1IS when '000 1000 0011 010' => return Sys_TLBI; // ASIDE1IS when '000 1000 0011 011' => return Sys_TLBI; // VAAE1IS when '000 1000 0011 101' => return Sys_TLBI; // VALE1IS when '000 1000 0011 111' => return Sys_TLBI; // VAALE1IS when '000 1000 0101 001' => return Sys_TLBI; // RVAE1OS when '000 1000 0101 011' => return Sys_TLBI; // RVAAE1OS when '000 1000 0101 101' => return Sys_TLBI; // RVALE1OS when '000 1000 0101 111' => return Sys_TLBI; // RVAALE1OS when '000 1000 0110 001' => return Sys_TLBI; // RVAE1 when '000 1000 0110 011' => return Sys_TLBI; // RVAAE1 when '000 1000 0110 101' => return Sys_TLBI; // RVALE1 when '000 1000 0110 111' => return Sys_TLBI; // RVAALE1 when '000 1000 0111 000' => return Sys_TLBI; // VMALLE1 when '000 1000 0111 001' => return Sys_TLBI; // VAE1 when '000 1000 0111 010' => return Sys_TLBI; // ASIDE1 when '000 1000 0111 011' => return Sys_TLBI; // VAAE1 when '000 1000 0111 101' => return Sys_TLBI; // VALE1 when '000 1000 0111 111' => return Sys_TLBI; // VAALE1 when '000 1001 0001 000' => return Sys_TLBI; // VMALLE1OSNXS when '000 1001 0001 001' => return Sys_TLBI; // VAE1OSNXS when '000 1001 0001 010' => return Sys_TLBI; // ASIDE1OSNXS when '000 1001 0001 011' => return Sys_TLBI; // VAAE1OSNXS when '000 1001 0001 101' => return Sys_TLBI; // VALE1OSNXS when '000 1001 0001 111' => return Sys_TLBI; // VAALE1OSNXS when '000 1001 0010 001' => return Sys_TLBI; // RVAE1ISNXS when '000 1001 0010 011' => return Sys_TLBI; // RVAAE1ISNXS when '000 1001 0010 101' => return Sys_TLBI; // RVALE1ISNXS when '000 1001 0010 111' => return Sys_TLBI; // RVAALE1ISNXS when '000 1001 0011 000' => return Sys_TLBI; // VMALLE1ISNXS when '000 1001 0011 001' => return Sys_TLBI; // VAE1ISNXS when '000 1001 0011 010' => return Sys_TLBI; // ASIDE1ISNXS when '000 1001 0011 011' => return Sys_TLBI; // VAAE1ISNXS when '000 1001 0011 101' => return Sys_TLBI; // VALE1ISNXS when '000 1001 0011 111' => return Sys_TLBI; // VAALE1ISNXS when '000 1001 0101 001' => return Sys_TLBI; // RVAE1OSNXS when '000 1001 0101 011' => return Sys_TLBI; // RVAAE1OSNXS when '000 1001 0101 101' => return Sys_TLBI; // RVALE1OSNXS when '000 1001 0101 111' => return Sys_TLBI; // RVAALE1OSNXS when '000 1001 0110 001' => return Sys_TLBI; // RVAE1NXS when '000 1001 0110 011' => return Sys_TLBI; // RVAAE1NXS when '000 1001 0110 101' => return Sys_TLBI; // RVALE1NXS when '000 1001 0110 111' => return Sys_TLBI; // RVAALE1NXS when '000 1001 0111 000' => return Sys_TLBI; // VMALLE1NXS when '000 1001 0111 001' => return Sys_TLBI; // VAE1NXS when '000 1001 0111 010' => return Sys_TLBI; // ASIDE1NXS when '000 1001 0111 011' => return Sys_TLBI; // VAAE1NXS when '000 1001 0111 101' => return Sys_TLBI; // VALE1NXS when '000 1001 0111 111' => return Sys_TLBI; // VAALE1NXS when '100 1000 0000 001' => return Sys_TLBI; // IPAS2E1IS when '100 1000 0000 010' => return Sys_TLBI; // RIPAS2E1IS when '100 1000 0000 101' => return Sys_TLBI; // IPAS2LE1IS when '100 1000 0000 110' => return Sys_TLBI; // RIPAS2LE1IS when '100 1000 0001 000' => return Sys_TLBI; // ALLE2OS when '100 1000 0001 001' => return Sys_TLBI; // VAE2OS when '100 1000 0001 100' => return Sys_TLBI; // ALLE1OS when '100 1000 0001 101' => return Sys_TLBI; // VALE2OS when '100 1000 0001 110' => return Sys_TLBI; // VMALLS12E1OS when '100 1000 0010 001' => return Sys_TLBI; // RVAE2IS when '100 1000 0010 101' => return Sys_TLBI; // RVALE2IS when '100 1000 0011 000' => return Sys_TLBI; // ALLE2IS when '100 1000 0011 001' => return Sys_TLBI; // VAE2IS when '100 1000 0011 100' => return Sys_TLBI; // ALLE1IS when '100 1000 0011 101' => return Sys_TLBI; // VALE2IS when '100 1000 0011 110' => return Sys_TLBI; // VMALLS12E1IS when '100 1000 0100 000' => return Sys_TLBI; // IPAS2E1OS when '100 1000 0100 001' => return Sys_TLBI; // IPAS2E1 when '100 1000 0100 010' => return Sys_TLBI; // RIPAS2E1 when '100 1000 0100 011' => return Sys_TLBI; // RIPAS2E1OS when '100 1000 0100 100' => return Sys_TLBI; // IPAS2LE1OS when '100 1000 0100 101' => return Sys_TLBI; // IPAS2LE1 when '100 1000 0100 110' => return Sys_TLBI; // RIPAS2LE1 when '100 1000 0100 111' => return Sys_TLBI; // RIPAS2LE1OS when '100 1000 0101 001' => return Sys_TLBI; // RVAE2OS when '100 1000 0101 101' => return Sys_TLBI; // RVALE2OS when '100 1000 0110 001' => return Sys_TLBI; // RVAE2 when '100 1000 0110 101' => return Sys_TLBI; // RVALE2 when '100 1000 0111 000' => return Sys_TLBI; // ALLE2 when '100 1000 0111 001' => return Sys_TLBI; // VAE2 when '100 1000 0111 100' => return Sys_TLBI; // ALLE1 when '100 1000 0111 101' => return Sys_TLBI; // VALE2 when '100 1000 0111 110' => return Sys_TLBI; // VMALLS12E1 when '100 1001 0000 001' => return Sys_TLBI; // IPAS2E1ISNXS when '100 1001 0000 010' => return Sys_TLBI; // RIPAS2E1ISNXS when '100 1001 0000 101' => return Sys_TLBI; // IPAS2LE1ISNXS when '100 1001 0000 110' => return Sys_TLBI; // RIPAS2LE1ISNXS when '100 1001 0001 000' => return Sys_TLBI; // ALLE2OSNXS when '100 1001 0001 001' => return Sys_TLBI; // VAE2OSNXS when '100 1001 0001 100' => return Sys_TLBI; // ALLE1OSNXS when '100 1001 0001 101' => return Sys_TLBI; // VALE2OSNXS when '100 1001 0001 110' => return Sys_TLBI; // VMALLS12E1OSNXS when '100 1001 0010 001' => return Sys_TLBI; // RVAE2ISNXS when '100 1001 0010 101' => return Sys_TLBI; // RVALE2ISNXS when '100 1001 0011 000' => return Sys_TLBI; // ALLE2ISNXS when '100 1001 0011 001' => return Sys_TLBI; // VAE2ISNXS when '100 1001 0011 100' => return Sys_TLBI; // ALLE1ISNXS when '100 1001 0011 101' => return Sys_TLBI; // VALE2ISNXS when '100 1001 0011 110' => return Sys_TLBI; // VMALLS12E1ISNXS when '100 1001 0100 000' => return Sys_TLBI; // IPAS2E1OSNXS when '100 1001 0100 001' => return Sys_TLBI; // IPAS2E1NXS when '100 1001 0100 010' => return Sys_TLBI; // RIPAS2E1NXS when '100 1001 0100 011' => return Sys_TLBI; // RIPAS2E1OSNXS when '100 1001 0100 100' => return Sys_TLBI; // IPAS2LE1OSNXS when '100 1001 0100 101' => return Sys_TLBI; // IPAS2LE1NXS when '100 1001 0100 110' => return Sys_TLBI; // RIPAS2LE1NXS when '100 1001 0100 111' => return Sys_TLBI; // RIPAS2LE1OSNXS when '100 1001 0101 001' => return Sys_TLBI; // RVAE2OSNXS when '100 1001 0101 101' => return Sys_TLBI; // RVALE2OSNXS when '100 1001 0110 001' => return Sys_TLBI; // RVAE2NXS when '100 1001 0110 101' => return Sys_TLBI; // RVALE2NXS when '100 1001 0111 000' => return Sys_TLBI; // ALLE2NXS when '100 1001 0111 001' => return Sys_TLBI; // VAE2NXS when '100 1001 0111 100' => return Sys_TLBI; // ALLE1NXS when '100 1001 0111 101' => return Sys_TLBI; // VALE2NXS when '100 1001 0111 110' => return Sys_TLBI; // VMALLS12E1NXS when '110 1000 0001 000' => return Sys_TLBI; // ALLE3OS when '110 1000 0001 001' => return Sys_TLBI; // VAE3OS when '110 1000 0001 100' => return Sys_TLBI; // PAALLOS when '110 1000 0001 101' => return Sys_TLBI; // VALE3OS when '110 1000 0010 001' => return Sys_TLBI; // RVAE3IS when '110 1000 0010 101' => return Sys_TLBI; // RVALE3IS when '110 1000 0011 000' => return Sys_TLBI; // ALLE3IS when '110 1000 0011 001' => return Sys_TLBI; // VAE3IS when '110 1000 0011 101' => return Sys_TLBI; // VALE3IS when '110 1000 0100 011' => return Sys_TLBI; // RPAOS when '110 1000 0100 111' => return Sys_TLBI; // RPALOS when '110 1000 0101 001' => return Sys_TLBI; // RVAE3OS when '110 1000 0101 101' => return Sys_TLBI; // RVALE3OS when '110 1000 0110 001' => return Sys_TLBI; // RVAE3 when '110 1000 0110 101' => return Sys_TLBI; // RVALE3 when '110 1000 0111 000' => return Sys_TLBI; // ALLE3 when '110 1000 0111 001' => return Sys_TLBI; // VAE3 when '110 1000 0111 100' => return Sys_TLBI; // PAALL when '110 1000 0111 101' => return Sys_TLBI; // VALE3 when '110 1001 0001 000' => return Sys_TLBI; // ALLE3OSNXS when '110 1001 0001 001' => return Sys_TLBI; // VAE3OSNXS when '110 1001 0001 101' => return Sys_TLBI; // VALE3OSNXS when '110 1001 0010 001' => return Sys_TLBI; // RVAE3ISNXS when '110 1001 0010 101' => return Sys_TLBI; // RVALE3ISNXS when '110 1001 0011 000' => return Sys_TLBI; // ALLE3ISNXS when '110 1001 0011 001' => return Sys_TLBI; // VAE3ISNXS when '110 1001 0011 101' => return Sys_TLBI; // VALE3ISNXS when '110 1001 0101 001' => return Sys_TLBI; // RVAE3OSNXS when '110 1001 0101 101' => return Sys_TLBI; // RVALE3OSNXS when '110 1001 0110 001' => return Sys_TLBI; // RVAE3NXS when '110 1001 0110 101' => return Sys_TLBI; // RVALE3NXS when '110 1001 0111 000' => return Sys_TLBI; // ALLE3NXS when '110 1001 0111 001' => return Sys_TLBI; // VAE3NXS when '110 1001 0111 101' => return Sys_TLBI; // VALE3NXS when '000 1100 0000 000' => return Sys_GSB; // SYS when '000 1100 0000 001' => return Sys_GSB; // ACK when '000 1100 0001 000' => return Sys_GIC; // CDDIS when '000 1100 0001 001' => return Sys_GIC; // CDEN when '000 1100 0001 010' => return Sys_GIC; // CDPRI when '000 1100 0001 011' => return Sys_GIC; // CDAFF when '000 1100 0001 100' => return Sys_GIC; // CDPEND when '000 1100 0001 101' => return Sys_GIC; // CDRCFG when '000 1100 0001 111' => return Sys_GIC; // CDEOI when '000 1100 0010 000' => return Sys_GIC; // CDDI when '000 1100 0010 001' => return Sys_GIC; // CDHM when '100 1100 0001 000' => return Sys_GIC; // VDDIS when '100 1100 0001 001' => return Sys_GIC; // VDEN when '100 1100 0001 010' => return Sys_GIC; // VDPRI when '100 1100 0001 011' => return Sys_GIC; // VDAFF when '100 1100 0001 100' => return Sys_GIC; // VDPEND when '100 1100 0001 101' => return Sys_GIC; // VDRCFG when '100 1100 0010 000' => return Sys_GIC; // VDDI when '100 1100 0010 001' => return Sys_GIC; // VDHM when '110 1100 0001 000' => return Sys_GIC; // LDDIS when '110 1100 0001 001' => return Sys_GIC; // LDEN when '110 1100 0001 010' => return Sys_GIC; // LDPRI when '110 1100 0001 011' => return Sys_GIC; // LDAFF when '110 1100 0001 100' => return Sys_GIC; // LDPEND when '110 1100 0001 101' => return Sys_GIC; // LDRCFG when '110 1100 0010 000' => return Sys_GIC; // LDDI when '110 1100 0010 001' => return Sys_GIC; // LDHM otherwise => return Sys_SYS; end; end;


## Library pseudocode for aarch64/functions/sysop/SystemOp

// SystemOp // ======== // System instruction types.

type SystemOp of enumeration { Sys_AT, Sys_BRB, Sys_DC, Sys_GIC, Sys_GSB, Sys_IC, Sys_TLBI, Sys_SYS };


## Library pseudocode for aarch64/functions/sysop\_128/SysOp128

// SysOp128 // ==========

func SysOp128(op1 : bits(3), CRn : bits(4), CRm : bits(4), op2 : bits(3)) => SystemOp128 begin case op1::CRn::CRm::op2 of when '000 1000 0001 001' => return Sys_TLBIP; // VAE1OS when '000 1000 0001 011' => return Sys_TLBIP; // VAAE1OS when '000 1000 0001 101' => return Sys_TLBIP; // VALE1OS when '000 1000 0001 111' => return Sys_TLBIP; // VAALE1OS when '000 1000 0011 001' => return Sys_TLBIP; // VAE1IS when '000 1000 0011 011' => return Sys_TLBIP; // VAAE1IS when '000 1000 0011 101' => return Sys_TLBIP; // VALE1IS when '000 1000 0011 111' => return Sys_TLBIP; // VAALE1IS when '000 1000 0111 001' => return Sys_TLBIP; // VAE1 when '000 1000 0111 011' => return Sys_TLBIP; // VAAE1 when '000 1000 0111 101' => return Sys_TLBIP; // VALE1 when '000 1000 0111 111' => return Sys_TLBIP; // VAALE1 when '000 1001 0001 001' => return Sys_TLBIP; // VAE1OSNXS when '000 1001 0001 011' => return Sys_TLBIP; // VAAE1OSNXS when '000 1001 0001 101' => return Sys_TLBIP; // VALE1OSNXS when '000 1001 0001 111' => return Sys_TLBIP; // VAALE1OSNXS when '000 1001 0011 001' => return Sys_TLBIP; // VAE1ISNXS when '000 1001 0011 011' => return Sys_TLBIP; // VAAE1ISNXS when '000 1001 0011 101' => return Sys_TLBIP; // VALE1ISNXS when '000 1001 0011 111' => return Sys_TLBIP; // VAALE1ISNXS when '000 1001 0111 001' => return Sys_TLBIP; // VAE1NXS when '000 1001 0111 011' => return Sys_TLBIP; // VAAE1NXS when '000 1001 0111 101' => return Sys_TLBIP; // VALE1NXS when '000 1001 0111 111' => return Sys_TLBIP; // VAALE1NXS when '100 1000 0001 001' => return Sys_TLBIP; // VAE2OS when '100 1000 0001 101' => return Sys_TLBIP; // VALE2OS when '100 1000 0011 001' => return Sys_TLBIP; // VAE2IS when '100 1000 0011 101' => return Sys_TLBIP; // VALE2IS when '100 1000 0111 001' => return Sys_TLBIP; // VAE2 when '100 1000 0111 101' => return Sys_TLBIP; // VALE2 when '100 1001 0001 001' => return Sys_TLBIP; // VAE2OSNXS when '100 1001 0001 101' => return Sys_TLBIP; // VALE2OSNXS when '100 1001 0011 001' => return Sys_TLBIP; // VAE2ISNXS when '100 1001 0011 101' => return Sys_TLBIP; // VALE2ISNXS when '100 1001 0111 001' => return Sys_TLBIP; // VAE2NXS when '100 1001 0111 101' => return Sys_TLBIP; // VALE2NXS when '110 1000 0001 001' => return Sys_TLBIP; // VAE3OS when '110 1000 0001 101' => return Sys_TLBIP; // VALE3OS when '110 1000 0011 001' => return Sys_TLBIP; // VAE3IS when '110 1000 0011 101' => return Sys_TLBIP; // VALE3IS when '110 1000 0111 001' => return Sys_TLBIP; // VAE3 when '110 1000 0111 101' => return Sys_TLBIP; // VALE3 when '110 1001 0001 001' => return Sys_TLBIP; // VAE3OSNXS when '110 1001 0001 101' => return Sys_TLBIP; // VALE3OSNXS when '110 1001 0011 001' => return Sys_TLBIP; // VAE3ISNXS when '110 1001 0011 101' => return Sys_TLBIP; // VALE3ISNXS when '110 1001 0111 001' => return Sys_TLBIP; // VAE3NXS when '110 1001 0111 101' => return Sys_TLBIP; // VALE3NXS when '100 1000 0000 001' => return Sys_TLBIP; // IPAS2E1IS when '100 1000 0000 101' => return Sys_TLBIP; // IPAS2LE1IS when '100 1000 0100 000' => return Sys_TLBIP; // IPAS2E1OS when '100 1000 0100 001' => return Sys_TLBIP; // IPAS2E1 when '100 1000 0100 100' => return Sys_TLBIP; // IPAS2LE1OS when '100 1000 0100 101' => return Sys_TLBIP; // IPAS2LE1 when '100 1001 0000 001' => return Sys_TLBIP; // IPAS2E1ISNXS when '100 1001 0000 101' => return Sys_TLBIP; // IPAS2LE1ISNXS when '100 1001 0100 000' => return Sys_TLBIP; // IPAS2E1OSNXS when '100 1001 0100 001' => return Sys_TLBIP; // IPAS2E1NXS when '100 1001 0100 100' => return Sys_TLBIP; // IPAS2LE1OSNXS when '100 1001 0100 101' => return Sys_TLBIP; // IPAS2LE1NXS when '000 1000 0010 001' => return Sys_TLBIP; // RVAE1IS when '000 1000 0010 011' => return Sys_TLBIP; // RVAAE1IS when '000 1000 0010 101' => return Sys_TLBIP; // RVALE1IS when '000 1000 0010 111' => return Sys_TLBIP; // RVAALE1IS when '000 1000 0101 001' => return Sys_TLBIP; // RVAE1OS when '000 1000 0101 011' => return Sys_TLBIP; // RVAAE1OS when '000 1000 0101 101' => return Sys_TLBIP; // RVALE1OS when '000 1000 0101 111' => return Sys_TLBIP; // RVAALE1OS when '000 1000 0110 001' => return Sys_TLBIP; // RVAE1 when '000 1000 0110 011' => return Sys_TLBIP; // RVAAE1 when '000 1000 0110 101' => return Sys_TLBIP; // RVALE1 when '000 1000 0110 111' => return Sys_TLBIP; // RVAALE1 when '000 1001 0010 001' => return Sys_TLBIP; // RVAE1ISNXS when '000 1001 0010 011' => return Sys_TLBIP; // RVAAE1ISNXS when '000 1001 0010 101' => return Sys_TLBIP; // RVALE1ISNXS when '000 1001 0010 111' => return Sys_TLBIP; // RVAALE1ISNXS when '000 1001 0101 001' => return Sys_TLBIP; // RVAE1OSNXS when '000 1001 0101 011' => return Sys_TLBIP; // RVAAE1OSNXS when '000 1001 0101 101' => return Sys_TLBIP; // RVALE1OSNXS when '000 1001 0101 111' => return Sys_TLBIP; // RVAALE1OSNXS when '000 1001 0110 001' => return Sys_TLBIP; // RVAE1NXS when '000 1001 0110 011' => return Sys_TLBIP; // RVAAE1NXS when '000 1001 0110 101' => return Sys_TLBIP; // RVALE1NXS when '000 1001 0110 111' => return Sys_TLBIP; // RVAALE1NXS when '100 1000 0010 001' => return Sys_TLBIP; // RVAE2IS when '100 1000 0010 101' => return Sys_TLBIP; // RVALE2IS when '100 1000 0101 001' => return Sys_TLBIP; // RVAE2OS when '100 1000 0101 101' => return Sys_TLBIP; // RVALE2OS when '100 1000 0110 001' => return Sys_TLBIP; // RVAE2 when '100 1000 0110 101' => return Sys_TLBIP; // RVALE2 when '100 1001 0010 001' => return Sys_TLBIP; // RVAE2ISNXS when '100 1001 0010 101' => return Sys_TLBIP; // RVALE2ISNXS when '100 1001 0101 001' => return Sys_TLBIP; // RVAE2OSNXS when '100 1001 0101 101' => return Sys_TLBIP; // RVALE2OSNXS when '100 1001 0110 001' => return Sys_TLBIP; // RVAE2NXS when '100 1001 0110 101' => return Sys_TLBIP; // RVALE2NXS when '110 1000 0010 001' => return Sys_TLBIP; // RVAE3IS when '110 1000 0010 101' => return Sys_TLBIP; // RVALE3IS when '110 1000 0101 001' => return Sys_TLBIP; // RVAE3OS when '110 1000 0101 101' => return Sys_TLBIP; // RVALE3OS when '110 1000 0110 001' => return Sys_TLBIP; // RVAE3 when '110 1000 0110 101' => return Sys_TLBIP; // RVALE3 when '110 1001 0010 001' => return Sys_TLBIP; // RVAE3ISNXS when '110 1001 0010 101' => return Sys_TLBIP; // RVALE3ISNXS when '110 1001 0101 001' => return Sys_TLBIP; // RVAE3OSNXS when '110 1001 0101 101' => return Sys_TLBIP; // RVALE3OSNXS when '110 1001 0110 001' => return Sys_TLBIP; // RVAE3NXS when '110 1001 0110 101' => return Sys_TLBIP; // RVALE3NXS when '100 1000 0000 010' => return Sys_TLBIP; // RIPAS2E1IS when '100 1000 0000 110' => return Sys_TLBIP; // RIPAS2LE1IS when '100 1000 0100 010' => return Sys_TLBIP; // RIPAS2E1 when '100 1000 0100 011' => return Sys_TLBIP; // RIPAS2E1OS when '100 1000 0100 110' => return Sys_TLBIP; // RIPAS2LE1 when '100 1000 0100 111' => return Sys_TLBIP; // RIPAS2LE1OS when '100 1001 0000 010' => return Sys_TLBIP; // RIPAS2E1ISNXS when '100 1001 0000 110' => return Sys_TLBIP; // RIPAS2LE1ISNXS when '100 1001 0100 010' => return Sys_TLBIP; // RIPAS2E1NXS when '100 1001 0100 011' => return Sys_TLBIP; // RIPAS2E1OSNXS when '100 1001 0100 110' => return Sys_TLBIP; // RIPAS2LE1NXS when '100 1001 0100 111' => return Sys_TLBIP; // RIPAS2LE1OSNXS otherwise => return Sys_SYSP; end; end;


## Library pseudocode for aarch64/functions/sysop\_128/SystemOp128

// SystemOp128 // ============= // System instruction types.

type SystemOp128 of enumeration {Sys_TLBIP, Sys_SYSP};


## Library pseudocode for aarch64/functions/sysregisters/ELR\_EL

// ELR_EL - accessor // =================

accessor ELR_EL(el : bits(2)) <=> value : bits(64) begin getter var r : bits(64); case el of when EL1 => r = ELR_EL1(); when EL2 => r = ELR_EL2(); when EL3 => r = ELR_EL3(); otherwise => unreachable; end; return r; end; setter let r : bits(64) = value; case el of when EL1 => ELR_EL1() = r; when EL2 => ELR_EL2() = r; when EL3 => ELR_EL3() = r; otherwise => unreachable; end; end; end;


## Library pseudocode for aarch64/functions/sysregisters/ELR\_ELx

// ELR_ELx - accessor // ==================

accessor ELR_ELx() <=> value : bits(64) begin getter assert PSTATE.EL != EL0; return ELR_EL(PSTATE.EL); end; setter assert PSTATE.EL != EL0; ELR_EL(PSTATE.EL) = value; end; end;


## Library pseudocode for aarch64/functions/sysregisters/ESR\_EL

// ESR_EL - accessor // =================

accessor ESR_EL(regime : bits(2)) <=> value : ESRType begin readonly getter var r : bits(64); case regime of when EL1 => r = ESR_EL1(); when EL2 => r = ESR_EL2(); when EL3 => r = ESR_EL3(); otherwise => unreachable; end; return r; end; setter let r : bits(64) = value; case regime of when EL1 => ESR_EL1() = r; when EL2 => ESR_EL2() = r; when EL3 => ESR_EL3() = r; otherwise => unreachable; end; end; end;


## Library pseudocode for aarch64/functions/sysregisters/ESR\_ELx

// ESR_ELx - accessor // ==================

accessor ESR_ELx() <=> value : ESRType begin readonly getter return ESR_EL(S1TranslationRegime()); end;

setter
    ESR_EL(S1TranslationRegime()) = value;
end;

end;


## Library pseudocode for aarch64/functions/sysregisters/FAR\_EL

// FAR_EL - accessor // =================

accessor FAR_EL(regime : bits(2)) <=> value : bits(64) begin readonly getter var r : bits(64); case regime of when EL1 => r = FAR_EL1(); when EL2 => r = FAR_EL2(); when EL3 => r = FAR_EL3(); otherwise => unreachable; end; return r; end; setter let r : bits(64) = value; case regime of when EL1 => FAR_EL1() = r; when EL2 => FAR_EL2() = r; when EL3 => FAR_EL3() = r; otherwise => unreachable; end; end; end;


## Library pseudocode for aarch64/functions/sysregisters/FAR\_ELx

// FAR_ELx - accessor // ==================

accessor FAR_ELx() <=> value : bits(64) begin readonly getter return FAR_EL(S1TranslationRegime()); end;

setter
    FAR_EL(S1TranslationRegime()) = value;
end;

end;


## 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/sysregisters/PFAR\_EL

// PFAR_EL - accessor // ==================

accessor PFAR_EL(regime : bits(2)) <=> value : bits(64) begin getter assert (IsFeatureImplemented(FEAT_PFAR) || (regime == EL3 && IsFeatureImplemented(FEAT_RME))); var r : bits(64); case regime of when EL1 => r = PFAR_EL1(); when EL2 => r = PFAR_EL2(); when EL3 => r = MFAR_EL3(); otherwise => unreachable; end; return r; end; setter let r : bits(64) = value; assert (IsFeatureImplemented(FEAT_PFAR) || (IsFeatureImplemented(FEAT_RME) && regime == EL3)); case regime of when EL1 => PFAR_EL1() = r; when EL2 => PFAR_EL2() = r; when EL3 => MFAR_EL3() = r; otherwise => unreachable; end; end; end;


## Library pseudocode for aarch64/functions/sysregisters/PFAR\_ELx

// PFAR_ELx - accessor // ===================

accessor PFAR_ELx() <=> value : bits(64) begin getter return PFAR_EL(S1TranslationRegime()); end;

setter
    PFAR_EL(S1TranslationRegime()) = value;
end;

end;


## Library pseudocode for aarch64/functions/sysregisters/SCTLR\_EL

// SCTLR_EL - accessor // ===================

accessor SCTLR_EL(regime : bits(2)) <=> value : SCTLRType begin getter var r : bits(64); case regime of when EL1 => r = SCTLR_EL1(); when EL2 => r = SCTLR_EL2(); when EL3 => r = SCTLR_EL3(); otherwise => unreachable; end; return r; end; setter let r : bits(64) = value; case regime of when EL1 => SCTLR_EL1() = r; when EL2 => SCTLR_EL2() = r; when EL3 => SCTLR_EL3() = r; otherwise => unreachable; end; end; end;


## Library pseudocode for aarch64/functions/sysregisters/SCTLR\_ELx

// SCTLR_ELx - accessor // ====================

accessor SCTLR_ELx() <=> value : SCTLRType begin getter return SCTLR_EL(S1TranslationRegime()); end; setter SCTLR_EL(S1TranslationRegime()) = value; end; end;


## Library pseudocode for aarch64/functions/sysregisters/VBAR\_EL

// VBAR_EL - accessor // ==================

accessor VBAR_EL(regime : bits(2)) <=> value : bits(64) begin getter var r : bits(64); case regime of when EL1 => r = VBAR_EL1(); when EL2 => r = VBAR_EL2(); when EL3 => r = VBAR_EL3(); otherwise => unreachable; end; return r; end; setter pass; end; end;


## Library pseudocode for aarch64/functions/sysregisters/VBAR\_ELx

// VBAR_ELx - accessor // ===================

accessor VBAR_ELx() <=> value : bits(64) begin getter return VBAR_EL(S1TranslationRegime()); end; setter VBAR_EL(S1TranslationRegime())[63:0] = value; end; 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 {PSTATEField_DAIFSet, PSTATEField_DAIFClr} then if (EffectivelyAtEL0InHost() || (EffectivelyAtEL0NotInHost() && SCTLR_EL1().UMA == '0')) then AArch64_SystemAccessTraptoEL1orEL2(0x18); 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* == '0' then
        bins[[N]] = i[3:0];
        N = N + 1;
    end;
end;

let seed : bits(16) = RGSR_EL1().RRND0.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];

return bins[[lbin]];

end;


## Library pseudocode for
aarch64/functions/system/AArch64\_ChooseNonExcludedTag

// AArch64_ChooseNonExcludedTag // ============================== // Return a tag derived from the start and the offset values, excluding // any tags in the given mask.

func AArch64_ChooseNonExcludedTag(tag_in : bits(4), offset_in : bits(4), exclude : bits(16)) => bits(4) begin var tag : bits(4) = tag_in; var offset : bits(4) = offset_in;

if IsOnes(exclude) then
    return '0000';
end;

if offset == '0000' then
    while exclude[UInt(tag)] == '1' looplimit 16 do
        tag = tag + '0001';
    end;
end;

while offset != '0000' looplimit 16 do
    offset = offset - '0001';
    tag = tag + '0001';
    while exclude[UInt(tag)] == '1' looplimit 16 do
        tag = tag + '0001';
    end;
end;

return tag;

end;


## Library pseudocode for
aarch64/functions/system/AArch64\_ChooseNonExcludedTagOrZero

// AArch64_ChooseNonExcludedTagOrZero // ==================================== // 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\_ChooseTagOrZero

// AArch64_ChooseTagOrZero // ========================= // Return a tag, excluding any tags in the given mask, , or zero if Allocation // Tag access is not enabled.

func AArch64_ChooseTagOrZero(exclude : bits(16)) => bits(4) begin if IsMTEEnabled(PSTATE.EL) then if GCR_EL1().RRND == '1' then if IsOnes(exclude) then return '0000'; else return ChooseRandomNonExcludedTag(exclude); end; else if IsFeatureImplemented(FEAT_MTE_EIRG) then return AArch64_ChooseEIRGNonExcludedTag(exclude); end; let start_tag : bits(4) = RGSR_EL1().TAG; let offset : bits(4) = AArch64_RandomTag();

 RGSR_EL1().TAG = AArch64_ChooseNonExcludedTag(start_tag, offset,
exclude);

        return RGSR_EL1().TAG;
    end;
else
    return '0000';
end;

end;


## Library pseudocode for aarch64/functions/system/AArch64\_ExecutingERETInstr

// AArch64_ExecutingERETInstr // ============================ // Returns TRUE if current instruction is ERET.

func AArch64_ExecutingERETInstr() => boolean begin let instr : bits(32) = ThisInstr(); return instr[31:12] == '11010110100111110000'; end;


## Library pseudocode for aarch64/functions/system/AArch64\_ImpDefSysInstr

// AArch64_ImpDefSysInstr // ======================== // Execute an implementation-defined system instruction with write (source operand).

impdef func AArch64_ImpDefSysInstr(op0 : bits(2), op1 : bits(3), crn : bits(4), crm : bits(4), op2 : bits(3), t : integer) begin Undefined(); end;


## Library pseudocode for aarch64/functions/system/AArch64\_ImpDefSysInstr128

// AArch64_ImpDefSysInstr128 // =========================== // Execute an implementation-defined system instruction with write (128-bit source operand).

impdef func AArch64_ImpDefSysInstr128(op0 : bits(2), op1 : bits(3), crn : bits(4), crm : bits(4), op2 : bits(3), t : integer, t2 : integer) begin Undefined(); end;


## Library pseudocode for
aarch64/functions/system/AArch64\_ImpDefSysInstrWithResult

// AArch64_ImpDefSysInstrWithResult // ================================== // Execute an implementation-defined system instruction with read (result operand).

impdef func AArch64_ImpDefSysInstrWithResult(op0 : bits(2), op1 : bits(3), crn : bits(4), crm : bits(4), op2 : bits(3), t : integer) begin Undefined(); end;


## Library pseudocode for aarch64/functions/system/AArch64\_ImpDefSysRegRead

// AArch64_ImpDefSysRegRead // ========================== // Read from an implementation-defined System register and write the contents of the register // to X[t].

impdef func AArch64_ImpDefSysRegRead(op0 : bits(2), op1 : bits(3), crn : bits(4), crm : bits(4), op2 : bits(3), t : integer) begin Undefined(); end;


## Library pseudocode for
aarch64/functions/system/AArch64\_ImpDefSysRegRead128

// AArch64_ImpDefSysRegRead128 // ============================= // Read from an 128-bit implementation-defined System register // and write the contents of the register to X[t], X[t+1].

impdef func AArch64_ImpDefSysRegRead128(op0 : bits(2), op1 : bits(3), crn : bits(4), crm : bits(4), op2 : bits(3), t : integer, t2 : integer) begin Undefined(); end;


## Library pseudocode for aarch64/functions/system/AArch64\_ImpDefSysRegWrite

// AArch64_ImpDefSysRegWrite // =========================== // Write to an implementation-defined System register.

impdef func AArch64_ImpDefSysRegWrite(op0 : bits(2), op1 : bits(3), crn : bits(4), crm : bits(4), op2 : bits(3), t : integer) begin Undefined(); end;


## Library pseudocode for
aarch64/functions/system/AArch64\_ImpDefSysRegWrite128

// AArch64_ImpDefSysRegWrite128 // ============================== // Write the contents of X[t], X[t+1] to an 128-bit implementation-defined System register.

impdef func AArch64_ImpDefSysRegWrite128(op0 : bits(2), op1 : bits(3), crn : bits(4), crm : bits(4), op2 : bits(3), t : integer, t2 : integer) begin Undefined(); end;


## Library pseudocode for aarch64/functions/system/AArch64\_InterruptPending

// AArch64_InterruptPending // ========================== // Returns TRUE if there are any pending physical, virtual, or delegated // interrupts, and FALSE otherwise.

func AArch64_InterruptPending() => boolean begin let (irq_pending, -) = IRQPending(); let (fiq_pending, -) = FIQPending(); let pending_physical_interrupt : boolean = (irq_pending || fiq_pending || IsPhysicalSErrorPending());

var pending_virtual_interrupt : boolean = FALSE;
if EL2Enabled() && PSTATE.EL IN {EL0, EL1} && HCR_EL2().TGE ==
'0' then
    let virq_pending : boolean = (HCR_EL2().IMO == '1' && (VirtualIRQPending() ||
                                     HCR_EL2().VI == '1'));
    let vfiq_pending : boolean = (HCR_EL2().FMO == '1' && (VirtualFIQPending() ||
                                     HCR_EL2().VF == '1'));
    let vsei_pending : boolean = ((HCR_EL2().AMO == '1' ||
                                   (IsFeatureImplemented(FEAT_DoubleFault2) &&
                                     IsHCRXEL2Enabled() && HCRX_EL2().TMEA == '1')) &&
                                   (IsVirtualSErrorPending() || HCR_EL2().VSE == '1'));

    pending_virtual_interrupt = vsei_pending || virq_pending || vfiq_pending;
end;

let pending_delegated_interrupt : boolean = (PSTATE.EL != EL3 &&
                                             EffectiveSCR_EL3_EnDSE() == '1' &&
                                             SCR_EL3().DSE == '1');

return pending_physical_interrupt || pending_virtual_interrupt ||
pending_delegated_interrupt;

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 top : bit = lfsr[5] XOR lfsr[3] XOR lfsr[2] XOR lfsr[0]; RGSR_EL1().RRND0.SEED[15:0] = top::lfsr[15:1]; return top; end;


## Library pseudocode for aarch64/functions/system/AArch64\_RandomTag

// AArch64_RandomTag // =================== // Generate a random Allocation Tag.

func AArch64_RandomTag() => bits(4) begin var tag : bits(4); for i = 0 to 3 do tag* = AArch64_NextRandomTagBit(); end; return tag; end;


## Library pseudocode for aarch64/functions/system/AArch64\_SysInstr

// AArch64_SysInstr // ================== // Execute a system instruction with write (source operand).

impdef func AArch64_SysInstr(op0 : bits(2), op1 : bits(3), crn : bits(4), crm : bits(4), op2 : bits(3), t : integer) begin Unimplemented(); end;


## Library pseudocode for aarch64/functions/system/AArch64\_SysInstrWithResult

// AArch64_SysInstrWithResult // ============================ // Execute a system instruction with read (result operand). // Writes the result of the instruction to X[t].

impdef func AArch64_SysInstrWithResult(op0 : bits(2), op1 : bits(3), crn : bits(4), crm : bits(4), op2 : bits(3), t : integer) begin Unimplemented(); end;


## Library pseudocode for aarch64/functions/system/AArch64\_SysRegRead

// AArch64_SysRegRead // ==================== // Read from a System register and write the contents of the register to X[t].

impdef func AArch64_SysRegRead(op0 : bits(2), op1 : bits(3), crn : bits(4), crm : bits(4), op2 : bits(3), t : integer) begin Unimplemented(); end;


## Library pseudocode for aarch64/functions/system/AArch64\_SysRegWrite

// AArch64_SysRegWrite // ===================== // Write to a System register.

impdef func AArch64_SysRegWrite(op0 : bits(2), op1 : bits(3), crn : bits(4), crm : bits(4), op2 : bits(3), t : integer) begin Unimplemented(); end;


## Library pseudocode for aarch64/functions/system/BTypeCompatible

// BTypeCompatible // =============== // Records the branch target compatibility. // Returns TRUE if the branch target is compatible with PSTATE.BTYPE, else FALSE.

var BTypeCompatible : boolean;


## Library pseudocode for aarch64/functions/system/BTypeCompatible\_BTI

// BTypeCompatible_BTI // =================== // This function determines whether a given hint encoding is compatible with the current value of // PSTATE.BTYPE. A value of TRUE here indicates a valid Branch Target Identification instruction.

func BTypeCompatible_BTI(hintcode : bits(2)) => boolean begin case hintcode of when '00' => return PSTATE.BTYPE == '00'; when '01' => return PSTATE.BTYPE != '11'; when '10' => return PSTATE.BTYPE != '10'; when '11' => return TRUE; end; end;


## Library pseudocode for aarch64/functions/system/BTypeCompatible\_PAC

// BTypeCompatible_PAC // ===================== // Returns TRUE if PACIxSP or PACIxSPPC instructions are implicitly compatible with PSTATE.BTYPE, // FALSE otherwise.

func BTypeCompatible_PAC(pacinst : PACInstType) => boolean begin // For only PACIxSP instructions, check if BTI behavior should be disabled if IsFeatureImplemented(FEAT_PAuth_EnhCtl) && pacinst == PACIxSP then var btd : bit; case PSTATE.EL of when EL0 => if ELIsInHost(EL0) then btd = if IsSCTLR2EL2Enabled() then SCTLR2_EL2().BTD0 else '0'; else btd = if IsSCTLR2EL1Enabled() then SCTLR2_EL1().BTD0 else '0'; end; when EL1 => btd = if IsSCTLR2EL1Enabled() then SCTLR2_EL1().BTD else '0'; when EL2 => btd = if IsSCTLR2EL2Enabled() then SCTLR2_EL2().BTD else '0'; when EL3 => btd = SCTLR2_EL3().BTD; end; // When BTI compatibility is disabled, // these instructions are not compatible when PSTATE.BTYPE is non-zero if btd == '1' then return IsZero(PSTATE.BTYPE); end; end;

if PSTATE.BTYPE != '11' then
    return TRUE;
else
    let index : integer = if PSTATE.EL == EL0 then 35 else 36;
    return SCTLR_ELx()[index] == '0';
end;

end;


## Library pseudocode for aarch64/functions/system/BTypeCompatible\_PACIXSP

// BTypeCompatible_PACIXSP // ========================= // Returns TRUE if PACIASP or PACIBSP instructions are implicitly compatible with PSTATE.BTYPE, // FALSE otherwise.

func BTypeCompatible_PACIXSP() => boolean begin let pacinst : PACInstType = PACIxSP; return BTypeCompatible_PAC(pacinst); end;


## Library pseudocode for aarch64/functions/system/BTypeNext

// BTypeNext // ========= // Updated every cycle with a value that depends upon the instruction being executed. Assigned to // PSTATE.BTYPE at the end of each cycle and then cleared to zero. Allows SPSR save/restore of // BTYPE for the current instruction being executed.

var BTypeNext : bits(2);


## Library pseudocode for aarch64/functions/system/ChooseRandomNonExcludedTag

// ChooseRandomNonExcludedTag // ============================ // The ChooseRandomNonExcludedTag function is used when GCR_EL1.RRND == '1' to generate random // Allocation Tags. // // The resulting Allocation Tag is selected from the set [0,15], excluding any Allocation Tag where // exclude[tag_value] == 1. If 'exclude' is all Ones, the returned Allocation Tag is '0000'. // // This function is permitted to generate a non-deterministic selection from the set of non-excluded // Allocation Tags. A reasonable implementation should select a tag from a uniform distribution and // avoid common pitfalls such as modulo bias. // // This function can read RGSR_EL1 and/or write RGSR_EL1 to an IMPLEMENTATION DEFINED value. // If it is not capable of writing RGSR_EL1.SEED[15:0] to zero from a previous nonzero // RGSR_EL1.SEED value, it is IMPLEMENTATION DEFINED whether the randomness is significantly // impacted if RGSR_EL1.SEED[15:0] is set to zero.

impdef func ChooseRandomNonExcludedTag(exclude_in : bits(16)) => bits(4) begin return ARBITRARY : bits(4); end;


## Library pseudocode for aarch64/functions/system/EffectiveBADDR

// EffectiveBADDR // ================ // Check if the given VA, held in a register BADDR field, is RESS and apply // CONSTRAINED UNPREDICTABLE behavior if it is not.

func EffectiveBADDR(baddr_in : bits(64), directread : boolean) => bits(64) begin var baddr : bits(64) = baddr_in; // Determine top bit position based on feature support. let n : integer{} = (if IsFeatureImplemented(FEAT_LVA3) then 57 else (if IsFeatureImplemented(FEAT_LVA) then 53 else 49));

// Check if the upper bits of the base address form a valid sign
extension.
if baddr[63:n] != Replicate{64-n}(baddr[n-1]) then
    let c = ConstrainUnpredictable(Unpredictable_BADDR_RESS);
    assert c IN {Constraint_RESS, Constraint_ALLRESS, Constraint_FAULT};
    if c == Constraint_ALLRESS || (!directread && c == Constraint_RESS) then
        baddr[63:n] = Replicate{64-n}(baddr[n-1]);
    end;
    // If c == Constraint_FAULT, baddr will cause an Address Size fault when used.
end;

return baddr;

end;


## Library pseudocode for aarch64/functions/system/EffectiveDIT

// EffectiveDIT // ============== // Returns the Effective value of PSTATE.DIT.

readonly func EffectiveDIT() => bit begin if !IsFeatureImplemented(FEAT_FDIT) then return PSTATE.DIT; end;

if (PSTATE.EL == EL0 &&
      (((EL0) && IsSCTLR2EL1Enabled() && SCTLR2_EL1().FDIT == '1') ||
       ( ELIsInHost(EL0) && IsSCTLR2EL2Enabled() && SCTLR2_EL2().FDIT == '1'))) then
    return '1';
end;

if (((PSTATE.EL == EL0 && (EL0)) || PSTATE.EL == EL1) &&
      IsHCRXEL2Enabled() && HCRX_EL2().FDIT == '1') then
    return '1';
end;

if PSTATE.EL != EL3 && SCR2_EL3().FDIT == '1' then
    return '1';
end;

return PSTATE.DIT;

end;


## Library pseudocode for aarch64/functions/system/EffectiveHCRX\_EL2\_NVTGE

// EffectiveHCRX_EL2_NVTGE // ========================= // Returns the Effective value of HCRX_EL2.NVTGE.

readonly func EffectiveHCRX_EL2_NVTGE() => bit begin if !IsFeatureImplemented(FEAT_NV3) then return '0'; end;

if HaveEL(EL3) && SCR2_EL3().NV3En == '0' then
    return '0';
end;

if EffectiveHCR_EL2_NVx() != '101' then
    return '0';
end;

if () then
    return '0';
end;

return HCRX_EL2().NVTGE;

end;


## Library pseudocode for
aarch64/functions/system/EffectiveICC\_SRE\_EL2\_Enable

// EffectiveICC_SRE_EL2_Enable // ============================= // Returns the Effective value of ICC_SRE_EL2.Enable

func EffectiveICC_SRE_EL2_Enable() => bit begin if IsFeatureImplemented(FEAT_GCIE) then return '1'; end; if (ImpDefBool("Treat ICC_SRE_EL2.SRE as RAO/WI") && ImpDefBool("Treat ICC_SRE_EL2.Enable as RAO/WI")) then return '1'; end; if ICC_SRE_EL2().SRE == '0' then return '1'; end;

return ICC_SRE_EL2().Enable;

end;


## Library pseudocode for
aarch64/functions/system/EffectiveICC\_SRE\_EL3\_Enable

// EffectiveICC_SRE_EL3_Enable // ============================= // Returns the Effective value of ICC_SRE_EL3.Enable

func EffectiveICC_SRE_EL3_Enable() => bit begin

------------------------------------------------------------------------------ Page 1 of 1. End of thread.