public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Dennis Chen <dennis.chen@arm.com>
To: <edk2-devel@lists.01.org>
Cc: <nd@arm.com>, Dennis Chen <dennis.chen@arm.com>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Leif Lindholm <leif.lindholm@linaro.org>
Subject: [PATCH] ArmPkg: Assign the real INTID value for sanity check
Date: Fri, 21 Oct 2016 14:40:35 +0800	[thread overview]
Message-ID: <1477032035-27652-1-git-send-email-dennis.chen@arm.com> (raw)

Current implementation doesn't assign the INTID value readed from
GICC_IAR to the @InterruptId parameter in case of GICv3, thus make
the sanity check of the INTID in the caller becomes untrustworthy, this
patch is trying to re-assign the @InterruptId to mitigate this issue.

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Dennis Chen <dennis.chen@arm.com>
---
 ArmPkg/Drivers/ArmGic/ArmGicLib.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.c b/ArmPkg/Drivers/ArmGic/ArmGicLib.c
index 733488c..6c9ee8b 100644
--- a/ArmPkg/Drivers/ArmGic/ArmGicLib.c
+++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.c
@@ -135,27 +135,32 @@ ArmGicAcknowledgeInterrupt (
   OUT UINTN           *InterruptId
   )
 {
-  UINTN Value;
+  UINTN Value, IntID;
   ARM_GIC_ARCH_REVISION Revision;
 
+  // InterruptId is required for the caller to know if a valid or spurious
+  // interrupt has been read
+  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 ();
+    // For GICv3, the Value readed from GICC_IAR is the final INTID
+    IntID = Value;
   } else {
     ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
     // Report Spurious interrupt which is what the above controllers would
     // return if no interrupt was available
     Value = 1023;
+    IntID = Value;
   }
 
+  if (InterruptId != NULL)
+	*InterruptId = IntID;
+
   return Value;
 }
 
-- 
2.7.4



             reply	other threads:[~2016-10-21  6:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-21  6:40 Dennis Chen [this message]
2016-10-28 11:22 ` [PATCH] ArmPkg: Assign the real INTID value for sanity check 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=1477032035-27652-1-git-send-email-dennis.chen@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