summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Mujawar <sami.mujawar@arm.com>2023-05-19 11:33:39 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-06-01 15:52:01 +0000
commitded1d5414b5a0161de8fcf234b7fb200fb59fb2c (patch)
tree0c10e4a7161ec5f4440a4b618eda79dd8b6f273a
parent8bcddbcce2fa9eaa2e2e1ee2bb469189f76b7cbd (diff)
downloadedk2-ded1d5414b5a0161de8fcf234b7fb200fb59fb2c.tar.gz
edk2-ded1d5414b5a0161de8fcf234b7fb200fb59fb2c.tar.bz2
edk2-ded1d5414b5a0161de8fcf234b7fb200fb59fb2c.zip
ArmPkg: Fix ArmGicAcknowledgeInterrupt () for GICv3
The ArmGicAcknowledgeInterrupt () returns the value returned by the Interrupt Acknowledge Register and the InterruptID separately in an out parameter. The function documents the following: 'InterruptId is returned separately from the register value because in the GICv2 the register value contains the CpuId and InterruptId while in the GICv3 the register value is only the InterruptId.' This function skips setting the InterruptId in the out parameter for GICv3. Although the return value from the function is the InterruptId for GICv3, this breaks the function usage model as the caller expects the InterruptId in the out parameter for the function. e.g. The caller may end up using the InterruptID which could potentially be an uninitialised variable value. Therefore, set the InterruptID in the function out parameter for GICv3 as well. Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
-rw-r--r--ArmPkg/Drivers/ArmGic/ArmGicLib.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.c b/ArmPkg/Drivers/ArmGic/ArmGicLib.c
index 8f3315d76f..7f4bb248fc 100644
--- a/ArmPkg/Drivers/ArmGic/ArmGicLib.c
+++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.c
@@ -176,19 +176,17 @@ ArmGicAcknowledgeInterrupt (
)
{
UINTN Value;
+ UINTN IntId;
ARM_GIC_ARCH_REVISION Revision;
+ ASSERT (InterruptId != NULL);
Revision = ArmGicGetSupportedArchRevision ();
if (Revision == ARM_GIC_ARCH_REVISION_2) {
Value = ArmGicV2AcknowledgeInterrupt (GicInterruptInterfaceBase);
- // InterruptId is required for the caller to know if a valid or spurious
- // interrupt has been read
- ASSERT (InterruptId != NULL);
- if (InterruptId != NULL) {
- *InterruptId = Value & ARM_GIC_ICCIAR_ACKINTID;
- }
+ IntId = Value & ARM_GIC_ICCIAR_ACKINTID;
} else if (Revision == ARM_GIC_ARCH_REVISION_3) {
Value = ArmGicV3AcknowledgeInterrupt ();
+ IntId = Value;
} else {
ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
// Report Spurious interrupt which is what the above controllers would
@@ -196,6 +194,12 @@ ArmGicAcknowledgeInterrupt (
Value = 1023;
}
+ if (InterruptId != NULL) {
+ // InterruptId is required for the caller to know if a valid or spurious
+ // interrupt has been read
+ *InterruptId = IntId;
+ }
+
return Value;
}