[edk2-devel] [PATCH v1 10/12] ArmPkg: Prevent SgiId from setting RES0 bits of GICD_SGIR

Sami Mujawar posted 12 patches 1 year, 4 months ago
There is a newer version of this series
[edk2-devel] [PATCH v1 10/12] ArmPkg: Prevent SgiId from setting RES0 bits of GICD_SGIR
Posted by Sami Mujawar 1 year, 4 months ago
GICD_SGIR is a 32-bit register, of which INTID is bits [3:0]
and Bits [14:4] is RES0. Since SgiId parameter in the function
ArmGicSendSgiTo () is UINT8, mask unused bits of SgiId before
writing to the GICD_SGIR register to prevent accidental setting
of the RES0 bits.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
 ArmPkg/Drivers/ArmGic/ArmGicLib.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.c b/ArmPkg/Drivers/ArmGic/ArmGicLib.c
index df61e3aad4a7899eaa888cb248ad2a285c7f317d..0127cca3bf0567bc80702f415e9cbb9bd2709fbc 100644
--- a/ArmPkg/Drivers/ArmGic/ArmGicLib.c
+++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.c
@@ -1,6 +1,6 @@
 /** @file
 *
-*  Copyright (c) 2011-2021, Arm Limited. All rights reserved.
+*  Copyright (c) 2011-2023, Arm Limited. All rights reserved.
 *
 *  SPDX-License-Identifier: BSD-2-Clause-Patent
 *
@@ -148,7 +148,9 @@ ArmGicSendSgiTo (
 {
   MmioWrite32 (
     GicDistributorBase + ARM_GIC_ICDSGIR,
-    ((TargetListFilter & 0x3) << 24) | ((CPUTargetList & 0xFF) << 16) | SgiId
+    ((TargetListFilter & 0x3) << 24) |
+    ((CPUTargetList & 0xFF) << 16)   |
+    (SgiId & 0xF)
     );
 }
 
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105183): https://edk2.groups.io/g/devel/message/105183
Mute This Topic: https://groups.io/mt/99086466/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v1 10/12] ArmPkg: Prevent SgiId from setting RES0 bits of GICD_SGIR
Posted by Ard Biesheuvel 1 year, 4 months ago
On Tue, 23 May 2023 at 15:04, Sami Mujawar <sami.mujawar@arm.com> wrote:
>
> GICD_SGIR is a 32-bit register, of which INTID is bits [3:0]
> and Bits [14:4] is RES0. Since SgiId parameter in the function
> ArmGicSendSgiTo () is UINT8, mask unused bits of SgiId before
> writing to the GICD_SGIR register to prevent accidental setting
> of the RES0 bits.
>
> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>

> ---
>  ArmPkg/Drivers/ArmGic/ArmGicLib.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.c b/ArmPkg/Drivers/ArmGic/ArmGicLib.c
> index df61e3aad4a7899eaa888cb248ad2a285c7f317d..0127cca3bf0567bc80702f415e9cbb9bd2709fbc 100644
> --- a/ArmPkg/Drivers/ArmGic/ArmGicLib.c
> +++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.c
> @@ -1,6 +1,6 @@
>  /** @file
>  *
> -*  Copyright (c) 2011-2021, Arm Limited. All rights reserved.
> +*  Copyright (c) 2011-2023, Arm Limited. All rights reserved.
>  *
>  *  SPDX-License-Identifier: BSD-2-Clause-Patent
>  *
> @@ -148,7 +148,9 @@ ArmGicSendSgiTo (
>  {
>    MmioWrite32 (
>      GicDistributorBase + ARM_GIC_ICDSGIR,
> -    ((TargetListFilter & 0x3) << 24) | ((CPUTargetList & 0xFF) << 16) | SgiId
> +    ((TargetListFilter & 0x3) << 24) |
> +    ((CPUTargetList & 0xFF) << 16)   |
> +    (SgiId & 0xF)
>      );
>  }
>
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105193): https://edk2.groups.io/g/devel/message/105193
Mute This Topic: https://groups.io/mt/99086466/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-