From: "Sami Mujawar" <sami.mujawar@arm.com>
To: <devel@edk2.groups.io>
Cc: Sami Mujawar <sami.mujawar@arm.com>, <ardb+tianocore@kernel.org>,
<quic_llindhol@quicinc.com>, <neil.jones@blaize.com>,
<pedro.falcato@gmail.com>, <pierre.gondois@arm.com>,
<Matteo.Carlini@arm.com>, <Akanksha.Jain2@arm.com>,
<Ben.Adderson@arm.com>, <Sibel.Allinson@arm.com>, <nd@arm.com>
Subject: [PATCH v1 12/12] ArmPkg: Fix ArmGicAcknowledgeInterrupt () for GICv3
Date: Tue, 23 May 2023 14:04:21 +0100 [thread overview]
Message-ID: <20230523130421.10804-13-sami.mujawar@arm.com> (raw)
In-Reply-To: <20230523130421.10804-1-sami.mujawar@arm.com>
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>
---
ArmPkg/Drivers/ArmGic/ArmGicLib.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.c b/ArmPkg/Drivers/ArmGic/ArmGicLib.c
index 8f3315d76f6f2b28a551d73400938430ff3e23c7..7f4bb248fc7225bf63f0aea720486092b30ced10 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;
}
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
next prev parent reply other threads:[~2023-05-23 13:04 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-23 13:04 [PATCH v1 00/12] ArmPkg: Arm GIC Library and Driver improvements Sami Mujawar
2023-05-23 13:04 ` [PATCH v1 01/12] ArmPkg: Fix data type used for GicDistributorBase Sami Mujawar
2023-05-23 13:29 ` Ard Biesheuvel
2023-05-23 13:04 ` [PATCH v1 02/12] ArmPkg: Fix data type used for GicInterruptInterfaceBase Sami Mujawar
2023-05-23 13:35 ` Pedro Falcato
2023-05-23 15:16 ` Sami Mujawar
2023-05-23 13:36 ` Ard Biesheuvel
2023-05-23 13:04 ` [PATCH v1 03/12] ArmPkg: Fix ArmGicSendSgiTo() parameters Sami Mujawar
2023-05-23 13:04 ` [PATCH v1 04/12] ArmPkg: Fix Non-Boolean comparison in ArmGicEnableDistributor Sami Mujawar
2023-05-23 13:32 ` Ard Biesheuvel
2023-05-23 15:16 ` Sami Mujawar
2023-05-23 13:04 ` [PATCH v1 05/12] ArmPkg: Fix return type for ArmGicGetInterfaceIdentification Sami Mujawar
2023-05-23 13:04 ` [PATCH v1 06/12] ArmPkg: Make variables used for GicInterrupt UINTN Sami Mujawar
2023-05-23 13:04 ` [PATCH v1 07/12] ArmPkg: Fix return value for ArmGicV2AcknowledgeInterrupt Sami Mujawar
2023-05-23 13:32 ` Pedro Falcato
2023-05-23 15:17 ` Sami Mujawar
2023-05-23 13:04 ` [PATCH v1 08/12] ArmPkg: Typecast IntID to UINT32 in ArmGicV2EndOfInterrupt Sami Mujawar
2023-05-23 13:26 ` [edk2-devel] " Ard Biesheuvel
2023-05-23 15:16 ` Sami Mujawar
2023-05-23 13:04 ` [PATCH v1 09/12] ArmPkg: Remove unused function declarations Sami Mujawar
2023-05-23 13:04 ` [PATCH v1 10/12] ArmPkg: Prevent SgiId from setting RES0 bits of GICD_SGIR Sami Mujawar
2023-05-23 13:37 ` Ard Biesheuvel
2023-05-23 13:04 ` [PATCH v1 11/12] ArmPkg: Adjust variable type and cast for RegShift & RegOffset Sami Mujawar
2023-05-23 13:04 ` Sami Mujawar [this message]
2023-05-23 13:38 ` [PATCH v1 12/12] ArmPkg: Fix ArmGicAcknowledgeInterrupt () for GICv3 Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230523130421.10804-13-sami.mujawar@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox