ArmPkg: CpuDxe: fix AArch64 interrupt read masks

The AArch64 DAIF bits are different for reading (mrs) versus writing
(msr). The bitmask definitions assumed they were the same causing
incorrect results when trying to determine the current interrupt
state through ArmGetInterruptState.

The logic for interpreting the DAIF read data using the csel instruction
was also incorrect and is fixed.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eugene Cohen <eugene@hp.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
This commit is contained in:
Cohen, Eugene
2016-02-22 23:08:27 +00:00
committed by Ard Biesheuvel
parent 2ba36b2f0e
commit 4af3dd80ab
2 changed files with 23 additions and 25 deletions

View File

@@ -42,8 +42,8 @@ GCC_ASM_EXPORT (ArmWriteCpuActlr)
#------------------------------------------------------------------------------
.set DAIF_FIQ_BIT, (1 << 0)
.set DAIF_IRQ_BIT, (1 << 1)
.set DAIF_RD_FIQ_BIT, (1 << 6)
.set DAIF_RD_IRQ_BIT, (1 << 7)
ASM_PFX(ArmReadMidr):
mrs x0, midr_el1 // Read from Main ID Register (MIDR)
@@ -55,18 +55,14 @@ ASM_PFX(ArmCacheInfo):
ASM_PFX(ArmGetInterruptState):
mrs x0, daif
tst w0, #DAIF_IRQ_BIT // Check if IRQ is enabled. Enabled if 0.
mov w0, #0
mov w1, #1
csel w0, w1, w0, ne
tst w0, #DAIF_RD_IRQ_BIT // Check if IRQ is enabled. Enabled if 0 (Z=1)
cset w0, eq // if Z=1 return 1, else 0
ret
ASM_PFX(ArmGetFiqState):
mrs x0, daif
tst w0, #DAIF_FIQ_BIT // Check if FIQ is enabled. Enabled if 0.
mov w0, #0
mov w1, #1
csel w0, w1, w0, ne
tst w0, #DAIF_RD_FIQ_BIT // Check if FIQ is enabled. Enabled if 0 (Z=1)
cset w0, eq // if Z=1 return 1, else 0
ret
ASM_PFX(ArmWriteCpacr):