hw/intc/arm_gicv3_cpuif: Fix EOIR write access check logic
commit382c7160d1cd9e815fb94d3889a5ddcf0e1845ab
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 10 May 2021 15:00:16 +0000 (10 16:00 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 25 May 2021 15:01:43 +0000 (25 16:01 +0100)
treecbed20758e906249229f371feb999981778c3dae
parent219729cfbf9e979020bffedac6a790144173ec62
hw/intc/arm_gicv3_cpuif: Fix EOIR write access check logic

In icc_eoir_write() we assume that we can identify the group of the
IRQ being completed based purely on which register is being written
to and the current CPU state, and that "CPU state matches group
indicated by register" is the only necessary access check.

This isn't correct: if the CPU is not in Secure state then EOIR1 will
only complete Group 1 NS IRQs, but if the CPU is in EL3 it can
complete both Group 1 S and Group 1 NS IRQs.  (The pseudocode
ICC_EOIR1_EL1 makes this clear.) We were also missing the logic to
prevent EOIR0 writes completing G0 IRQs when they should not.

Rearrange the logic to first identify the group of the current
highest priority interrupt and then look at whether we should
complete it or ignore the access based on which register was accessed
and the state of the CPU.  The resulting behavioural change is:
 * EL3 can now complete G1NS interrupts
 * G0 interrupt completion is now ignored if the GIC
   and the CPU have the security extension enabled and
   the CPU is not secure

Reported-by: Chan Kim <ckim@etri.re.kr>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20210510150016.24910-1-peter.maydell@linaro.org
hw/intc/arm_gicv3_cpuif.c