public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sami Mujawar" <sami.mujawar@arm.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"adr.her.arc.95@gmail.com" <adr.her.arc.95@gmail.com>
Cc: "Adrián Herrera" <adr.her.arc.95@gmail.com>,
	"Joey Gouly" <Joey.Gouly@arm.com>,
	"Ard Biesheuvel" <ardb+tianocore@kernel.org>,
	"leif@nuviainc.com" <leif@nuviainc.com>, nd <nd@arm.com>
Subject: Re: [edk2-devel] [PATCH] ArmPkg/ArmGicLib: fix maximum interrupts supported
Date: Mon, 26 Apr 2021 07:56:15 +0000	[thread overview]
Message-ID: <AM6PR08MB37849AD705E8464FBD9B025284429@AM6PR08MB3784.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <2a2fef8f58a134336f19e049fbeb2c951bffaa52.1619206373.git.adr.her.arc.95@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2236 bytes --]

Hi Adrian,

I believe there is already a similar patch on the mailing list at https://edk2.groups.io/g/devel/message/72596. This patch is pending review and tested-by.
Can you check if this patch covers the problems you describe, please?

Regards,

Sami Mujawar

From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Adrián Herrera via groups.io <adr.her.arc.95=gmail.com@groups.io>
Date: Saturday, 24 April 2021 at 03:57
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Adrián Herrera <adr.her.arc.95@gmail.com>
Subject: [edk2-devel] [PATCH] ArmPkg/ArmGicLib: fix maximum interrupts supported
The maximum number of interrupts supported is determined as
32 * (GICD_TYPER.ITLinesNumber + 1).

When GICD_TYPER.ITLinesNumber = 0b11111, the maximum number of
interrupts supported is 1024. However, both GICv2 and GICv3 reserve
INTIDs 1020-1023 for special purposes.

This results in runtime crashes because:
  (1) ArmGicLib functions do not guard against special interrupts.
  (2) ArmGicGetMaxNumInterrupts number includes special interrupts.
  (2) ArmGicV*Dxe relies on ArmGicGetMaxNumInterrupts, and thus
      programs special interrupts through ArmGicLib.

ArmGicGetMaxNumInterrupts now does not include special interrupts, that
is, it reports 1020 instead of 1024 when GICD_TYPER.ITLinesNumber = 0b11111.
This avoids the overhead of guarding ArmGicLib functions while not
requiring to modify the drivers code.

Signed-off-by: Adrián Herrera <adr.her.arc.95@gmail.com>
---
 ArmPkg/Drivers/ArmGic/ArmGicLib.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.c b/ArmPkg/Drivers/ArmGic/ArmGicLib.c
index 6b01c88206..dff1401e9c 100644
--- a/ArmPkg/Drivers/ArmGic/ArmGicLib.c
+++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.c
@@ -120,7 +120,10 @@ ArmGicGetMaxNumInterrupts (
   IN  INTN          GicDistributorBase


   )


 {


-  return 32 * ((MmioRead32 (GicDistributorBase + ARM_GIC_ICDICTR) & 0x1F) + 1);


+  UINT32 ITLinesNumber;


+


+  ITLinesNumber = MmioRead32 (GicDistributorBase + ARM_GIC_ICDICTR) & 0x1F;


+  return MIN (32 * (ITLinesNumber+ 1), 1020);


 }





 VOID


--
2.30.0






[-- Attachment #2: Type: text/html, Size: 5172 bytes --]

  reply	other threads:[~2021-04-26  7:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-23 19:40 [PATCH] ArmPkg/ArmGicLib: fix maximum interrupts supported adr.her.arc.95
2021-04-26  7:56 ` Sami Mujawar [this message]
2021-04-27  9:48   ` [edk2-devel] " Adrián Herrera
2021-04-27 12:41     ` Sami Mujawar

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=AM6PR08MB37849AD705E8464FBD9B025284429@AM6PR08MB3784.eurprd08.prod.outlook.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