blob: 364216a1955726a1b99408ccf33004fc74dc2118 [file] [log] [blame]
Boyan Karatotev2abf8442025-08-27 15:26:45 +01001diff --git i/bl31/bl31_main.c w/bl31/bl31_main.c
2index bf870a392..65eb3b8f2 100644
3--- i/bl31/bl31_main.c
4+++ w/bl31/bl31_main.c
5@@ -94,6 +94,19 @@ static void __init bl31_lib_init(void)
6 cm_init();
Zelalem2a450732020-08-04 12:17:56 -05007 }
8
9+/*
Sandrine Bailleuxfcdb2102023-09-13 11:05:38 +020010+ * UBSAN test function. This is used to test whether CI handles undefined
11+ * behaviour errors correctly.
12+ */
Zelalem2a450732020-08-04 12:17:56 -050013+#include <limits.h>
14+
15+static int ubsan_test_add_overflow(void)
16+{
Sandrine Bailleuxfcdb2102023-09-13 11:05:38 +020017+ static int32_t val = INT_MAX;
18+ val += 0x1;
19+ return val;
Zelalem2a450732020-08-04 12:17:56 -050020+}
21+
22 /*******************************************************************************
23 * BL31 is responsible for setting up the runtime services for the primary cpu
24 * before passing control to the bootloader or an Operating System. This
Boyan Karatotev2abf8442025-08-27 15:26:45 +010025@@ -235,6 +248,10 @@ void __no_pauth bl31_main(u_register_t arg0, u_register_t arg1, u_register_t arg
Manish Pandeyaac106f2024-03-05 11:35:49 +000026
Sandrine Bailleuxfcdb2102023-09-13 11:05:38 +020027 console_flush();
Manish Pandeyaac106f2024-03-05 11:35:49 +000028 console_switch_state(CONSOLE_FLAG_RUNTIME);
Zelalem2a450732020-08-04 12:17:56 -050029+
30+ /* Run UBSAN Test */
Sandrine Bailleuxfcdb2102023-09-13 11:05:38 +020031+ INFO("BL31: Running UBSAN test\n");
32+ ubsan_test_add_overflow();
Zelalem2a450732020-08-04 12:17:56 -050033 }
34
Boyan Karatotev2abf8442025-08-27 15:26:45 +010035 void __no_pauth bl31_warmboot(void)