blob: 70af5e95ddae3e23af53448c3d904f455db15df7 [file] [log] [blame]
Zelalem2a450732020-08-04 12:17:56 -05001From 080e004b7ba917bd88d9f9c51d077e32a959d8fa Mon Sep 17 00:00:00 2001
2From: Zelalem <zelalem.aweke@arm.com>
3Date: Fri, 6 Dec 2019 10:29:13 -0600
4Subject: [PATCH] Add UBSAN test patch
5
6Change-Id: Ib2c78d9da0f214957dcad0d1d9a89089c10c9b48
7---
8 bl31/bl31_main.c | 17 +++++++++++++++++
9 1 file changed, 17 insertions(+)
10
11diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c
12index 92a2027dd..46cbed65e 100644
13--- a/bl31/bl31_main.c
14+++ b/bl31/bl31_main.c
15@@ -85,6 +85,19 @@ void bl31_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
16 #endif /* CTX_INCLUDE_PAUTH_REGS */
17 }
18
19+/*
20+* UBSAN test function. This is used to test whether CI handles
21+* undefined behaviour errors correctly.
22+*/
23+#include <limits.h>
24+
25+static int ubsan_test_add_overflow(void)
26+{
27+ static int32_t val = INT_MAX;
28+ val += 0x1;
29+ return val;
30+}
31+
32 /*******************************************************************************
33 * BL31 is responsible for setting up the runtime services for the primary cpu
34 * before passing control to the bootloader or an Operating System. This
35@@ -147,6 +160,10 @@ void bl31_main(void)
36 * from BL31
37 */
38 bl31_plat_runtime_setup();
39+
40+ /* Run UBSAN Test */
41+ INFO("BL31: Running UBSAN test\n");
42+ ubsan_test_add_overflow();
43 }
44
45 /*******************************************************************************
46--
472.17.1
48