Zelalem | 2a45073 | 2020-08-04 12:17:56 -0500 | [diff] [blame] | 1 | From 080e004b7ba917bd88d9f9c51d077e32a959d8fa Mon Sep 17 00:00:00 2001 |
| 2 | From: Zelalem <zelalem.aweke@arm.com> |
| 3 | Date: Fri, 6 Dec 2019 10:29:13 -0600 |
| 4 | Subject: [PATCH] Add UBSAN test patch |
| 5 | |
| 6 | Change-Id: Ib2c78d9da0f214957dcad0d1d9a89089c10c9b48 |
| 7 | --- |
| 8 | bl31/bl31_main.c | 17 +++++++++++++++++ |
| 9 | 1 file changed, 17 insertions(+) |
| 10 | |
| 11 | diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c |
| 12 | index 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 | -- |
| 47 | 2.17.1 |
| 48 | |