blob: c452e6ba3cd5a1467ad2987876b22f18410bc121 [file] [log] [blame]
Zelalem2a450732020-08-04 12:17:56 -05001diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c
Manish Pandeyaac106f2024-03-05 11:35:49 +00002index 8c5ba6f2e..21ed3b686 100644
Zelalem2a450732020-08-04 12:17:56 -05003--- a/bl31/bl31_main.c
4+++ b/bl31/bl31_main.c
Juan Pablo Condec9ee7632023-11-09 17:44:35 -06005@@ -112,6 +112,19 @@ void bl31_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
Yann Gautiereeb54302024-01-03 17:37:02 +01006 report_ctx_memory_usage();
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
Manish Pandeyaac106f2024-03-05 11:35:49 +000025@@ -224,6 +237,10 @@ void bl31_main(void)
26
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
35 /*******************************************************************************