public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Dennis Chen <dennis.chen@arm.com>
Cc: edk2-devel-01 <edk2-devel@lists.01.org>,
	nd@arm.com,  Leif Lindholm <leif.lindholm@linaro.org>
Subject: Re: [PATCH] ArmPkg: Assign the real INTID value for sanity check
Date: Fri, 28 Oct 2016 12:22:42 +0100	[thread overview]
Message-ID: <CAKv+Gu_41oF_6ehEMvVOjS-6p3B2W336c=ggrCSz=vLtMNPFEQ@mail.gmail.com> (raw)
In-Reply-To: <1477032035-27652-1-git-send-email-dennis.chen@arm.com>

Hi Dennis,

On 21 October 2016 at 07:40, Dennis Chen <dennis.chen@arm.com> wrote:
> 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);
> +

Given the assert here ...

>    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;

... I think we can assign *InterruptId directly here, rather than go
via a local ...

>    } else if (Revision == ARM_GIC_ARCH_REVISION_3) {
>      Value = ArmGicV3AcknowledgeInterrupt ();
> +    // For GICv3, the Value readed from GICC_IAR is the final INTID
> +    IntID = Value;

... and here ...

>    } 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;

... and here ...

>    }
>
> +  if (InterruptId != NULL)
> +       *InterruptId = IntID;
> +

... and drop this hunk.

>    return Value;
>  }
>
> --
> 2.7.4
>


      reply	other threads:[~2016-10-28 11:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-21  6:40 [PATCH] ArmPkg: Assign the real INTID value for sanity check Dennis Chen
2016-10-28 11:22 ` Ard Biesheuvel [this message]

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='CAKv+Gu_41oF_6ehEMvVOjS-6p3B2W336c=ggrCSz=vLtMNPFEQ@mail.gmail.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