Search code examples
arm64

How to read PSTATE in AARCH64


I would like to read if the value of the SError mask bit is set. Previously in case ARMv7 it was easy accessible by CSPR register, however in case of ARMv8-A and aarch64 that is no longer so - from ARMv8-A Programmers Guide:

"AArch64 does not have a direct equivalent of the ARMv7 Current Program Status Register (CPSR). In AArch64, the components of the traditional CPSR are supplied as fields that can be made accessible independently. These are referred to collectively as Processor State (PSTATE)."

so since PSTATE is not an actual register then:

mrs x0, pstate

gives me an error on compilation. So how can I read this PSTATE to get the value of SError that I need?


Solution

  • AArch64 has separate registers for various subsets of PSTATE. For the interrupt masks, this is called daif:

    mrs x0, daif
    

    The D, A, I and F flags are in bits 9, 8, 7 and 6 respectively (mask 0x3c0). The other bits are reserved and should read as zero.