diff options
author | Heyi Guo <guoheyi@linux.alibaba.com> | 2020-05-19 14:01:49 +0800 |
---|---|---|
committer | Manish Pandey <manish.pandey2@arm.com> | 2021-02-03 11:12:13 +0000 |
commit | 69ae4427f04681ff86e7e09b43815e0f94ad708d (patch) | |
tree | df08268007cae00ba0cb10c6285d6732d4f4498c /drivers/arm/gic | |
parent | deb18901d127bf4252e87a4b597ef7bd2b1e58b1 (diff) | |
download | arm-trusted-firmware-69ae4427f04681ff86e7e09b43815e0f94ad708d.tar.gz |
drivers/gicv3: fix logical issue for num_eints
In function gicv3_spis_config_defaults(), the variable num_ints is set
to (maximum SPI INTID + 1), while num_eints is set to (maximum ESPI
INTID). It introduces not only inconsistency to the code, but also
logical bug in the "for" loops, for the INTID of num_eints is also
valid and the check should be inclusive.
Fix this by setting num_eints to (maximum ESPI INTID + 1) as well.
Fix similar issues in gicv3_distif_save() and
gicv3_distif_init_restore().
Signed-off-by: Heyi Guo <guoheyi@linux.alibaba.com>
Change-Id: I4425777d17e84e85f38853603340bd348640154f
Diffstat (limited to 'drivers/arm/gic')
-rw-r--r-- | drivers/arm/gic/v3/gicv3_helpers.c | 4 | ||||
-rw-r--r-- | drivers/arm/gic/v3/gicv3_main.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/drivers/arm/gic/v3/gicv3_helpers.c b/drivers/arm/gic/v3/gicv3_helpers.c index ff346f9df..d2cce9607 100644 --- a/drivers/arm/gic/v3/gicv3_helpers.c +++ b/drivers/arm/gic/v3/gicv3_helpers.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2021, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -117,7 +117,7 @@ void gicv3_spis_config_defaults(uintptr_t gicd_base) * Maximum ESPI INTID is 32 * (GICD_TYPER.ESPI_range + 1) + 4095 */ num_eints = ((((typer_reg >> TYPER_ESPI_RANGE_SHIFT) & - TYPER_ESPI_RANGE_MASK) + 1U) << 5) + MIN_ESPI_ID - 1; + TYPER_ESPI_RANGE_MASK) + 1U) << 5) + MIN_ESPI_ID; for (i = MIN_ESPI_ID; i < num_eints; i += (1U << IGROUPR_SHIFT)) { diff --git a/drivers/arm/gic/v3/gicv3_main.c b/drivers/arm/gic/v3/gicv3_main.c index 65145d597..5a49b4f5e 100644 --- a/drivers/arm/gic/v3/gicv3_main.c +++ b/drivers/arm/gic/v3/gicv3_main.c @@ -757,7 +757,7 @@ void gicv3_distif_save(gicv3_dist_ctx_t * const dist_ctx) * Maximum ESPI INTID is 32 * (GICD_TYPER.ESPI_range + 1) + 4095 */ num_eints = ((((typer_reg >> TYPER_ESPI_RANGE_SHIFT) & - TYPER_ESPI_RANGE_MASK) + 1U) << 5) + MIN_ESPI_ID - 1; + TYPER_ESPI_RANGE_MASK) + 1U) << 5) + MIN_ESPI_ID; } else { num_eints = 0U; } @@ -881,7 +881,7 @@ void gicv3_distif_init_restore(const gicv3_dist_ctx_t * const dist_ctx) * Maximum ESPI INTID is 32 * (GICD_TYPER.ESPI_range + 1) + 4095 */ num_eints = ((((typer_reg >> TYPER_ESPI_RANGE_SHIFT) & - TYPER_ESPI_RANGE_MASK) + 1U) << 5) + MIN_ESPI_ID - 1; + TYPER_ESPI_RANGE_MASK) + 1U) << 5) + MIN_ESPI_ID; } else { num_eints = 0U; } |