blob: 53d2d1bd8fb4b2baaa2b722bb672df6bac945f7b [file] [log] [blame]
Zelalem2a450732020-08-04 12:17:56 -05001diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c
Sandrine Bailleuxfcdb2102023-09-13 11:05:38 +02002index cae55f314..481050a43 100644
Zelalem2a450732020-08-04 12:17:56 -05003--- a/bl31/bl31_main.c
4+++ b/bl31/bl31_main.c
Sandrine Bailleuxfcdb2102023-09-13 11:05:38 +02005@@ -108,6 +108,19 @@ void bl31_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
Zelalem2a450732020-08-04 12:17:56 -05006 #endif /* CTX_INCLUDE_PAUTH_REGS */
7 }
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
Sandrine Bailleuxfcdb2102023-09-13 11:05:38 +020025@@ -216,6 +229,10 @@ void bl31_main(void)
26 PMF_CAPTURE_TIMESTAMP(bl_svc, BL31_EXIT, PMF_CACHE_MAINT);
27 console_flush();
28 #endif
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 /*******************************************************************************