fix: overflow before widen
To avoid overflow before widen:
- Explicitly cast the operation to 64-bit in the
GIC driver code.
- Use UINT64_C(1) to define a 64-bit wide bitfield.
Signed-off-by: J-Alves <joao.alves@arm.com>
Change-Id: I930857acaae52e295d769750ac5e9fe42aa3458b
diff --git a/src/arch/aarch64/plat/interrupts/gicv3.c b/src/arch/aarch64/plat/interrupts/gicv3.c
index ff04b30..95142b5 100644
--- a/src/arch/aarch64/plat/interrupts/gicv3.c
+++ b/src/arch/aarch64/plat/interrupts/gicv3.c
@@ -7,6 +7,7 @@
*/
#include <libfdt.h>
+#include <stdint.h>
#include "hf/check.h"
#include "hf/cpu.h"
@@ -539,7 +540,8 @@
((aff1 & SGIR_AFF_MASK) << SGIR_AFF1_SHIFT);
/* Construct the SGI target affinity. */
- sgir |= ((1U << aff0) & SGIR_TGT_MASK) << SGIR_TGT_SHIFT;
+ sgir |= ((UINT64_C(1) << aff0) & SGIR_TGT_MASK)
+ << SGIR_TGT_SHIFT;
}
/* Populate the Interrupt Routing Mode field. */
diff --git a/src/manifest.c b/src/manifest.c
index 2ccdf96..44436df 100644
--- a/src/manifest.c
+++ b/src/manifest.c
@@ -102,7 +102,7 @@
}
i = boot_order / BOOT_ORDER_ENTRY_BITS;
- boot_order_mask = 1 << (boot_order % BOOT_ORDER_ENTRY_BITS);
+ boot_order_mask = UINT64_C(1) << (boot_order % BOOT_ORDER_ENTRY_BITS);
if ((boot_order_mask & manifest_data->boot_order_values[i]) != 0U) {
dlog_error("Boot order must be a unique value.");