From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw0-x232.google.com (mail-yw0-x232.google.com [IPv6:2607:f8b0:4002:c05::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 942A181D72 for ; Fri, 28 Oct 2016 04:22:43 -0700 (PDT) Received: by mail-yw0-x232.google.com with SMTP id w3so78109782ywg.1 for ; Fri, 28 Oct 2016 04:22:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Kr8x0DyIGRHsrYooapuZRu4orO77bJj/bZFMxh6f7nk=; b=jYg5ilplpBASzSh8W9dByQfGxxJBw3k9N1fGmghmRi9LFjy1VPJlO+dDJ0z3VHYvpZ Q4oS6gQKZHElcDH33ctFjGN0UPji4xcOO4n0kzwxf9Pmvv1Wf/AAv/amCfat1p2coeIP OyUs0JcoblTF4gLHNqzU1vXblQz/9hpH6PkIg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Kr8x0DyIGRHsrYooapuZRu4orO77bJj/bZFMxh6f7nk=; b=j+cufv43YNJgbiYDZ0av1Dei7mCfNY47t8XBqC1yYyJyt2pmIt9Cnq3v8UfOGvK6s6 B/3f2m5RPf8cjmEScB6tIaoFYYR3LFnetaMxor3ixPkgGoDJgCNWGh7IosWAqSWhtGZp ukjDZpSXzUepUGJbk0l7qJlqLlbtdG8KLvbIQpLv3yHchynEKLfV7IbYk/mujK4zxkzW qrq4EQN8IYdDKDFHjkCcE4irckoFEAZcKuwYkvp0NbXm4LcjzQl3RYuiG7TnonDgKEgy DZByGLWPz3GNdgp0HdjsQuLmWjE1kycdqo0/nhhK0oz7UbCg7Ne9LE6ZsT8eHDAHdVRs r1Xw== X-Gm-Message-State: ABUngvfYs2TIjD4V7Fx+9f666hf5cKGgDA9MhujGW9KkK5SmSfVlYM0/RAMEBjNNyYCzLfxFUFVdXBrJFbvyyZk/ X-Received: by 10.36.19.212 with SMTP id 203mr2014623itz.59.1477653762913; Fri, 28 Oct 2016 04:22:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.5.139 with HTTP; Fri, 28 Oct 2016 04:22:42 -0700 (PDT) In-Reply-To: <1477032035-27652-1-git-send-email-dennis.chen@arm.com> References: <1477032035-27652-1-git-send-email-dennis.chen@arm.com> From: Ard Biesheuvel Date: Fri, 28 Oct 2016 12:22:42 +0100 Message-ID: To: Dennis Chen Cc: edk2-devel-01 , nd@arm.com, Leif Lindholm Subject: Re: [PATCH] ArmPkg: Assign the real INTID value for sanity check X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Oct 2016 11:22:43 -0000 Content-Type: text/plain; charset=UTF-8 Hi Dennis, On 21 October 2016 at 07:40, Dennis Chen 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 > Cc: Leif Lindholm > Signed-off-by: Dennis Chen > --- > 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 >