Zelalem | 2a45073 | 2020-08-04 12:17:56 -0500 | [diff] [blame] | 1 | diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c |
Sandrine Bailleux | fcdb210 | 2023-09-13 11:05:38 +0200 | [diff] [blame] | 2 | index cae55f314..481050a43 100644 |
Zelalem | 2a45073 | 2020-08-04 12:17:56 -0500 | [diff] [blame] | 3 | --- a/bl31/bl31_main.c |
| 4 | +++ b/bl31/bl31_main.c |
Sandrine Bailleux | fcdb210 | 2023-09-13 11:05:38 +0200 | [diff] [blame] | 5 | @@ -108,6 +108,19 @@ void bl31_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2, |
Zelalem | 2a45073 | 2020-08-04 12:17:56 -0500 | [diff] [blame] | 6 | #endif /* CTX_INCLUDE_PAUTH_REGS */ |
| 7 | } |
| 8 | |
| 9 | +/* |
Sandrine Bailleux | fcdb210 | 2023-09-13 11:05:38 +0200 | [diff] [blame] | 10 | + * UBSAN test function. This is used to test whether CI handles undefined |
| 11 | + * behaviour errors correctly. |
| 12 | + */ |
Zelalem | 2a45073 | 2020-08-04 12:17:56 -0500 | [diff] [blame] | 13 | +#include <limits.h> |
| 14 | + |
| 15 | +static int ubsan_test_add_overflow(void) |
| 16 | +{ |
Sandrine Bailleux | fcdb210 | 2023-09-13 11:05:38 +0200 | [diff] [blame] | 17 | + static int32_t val = INT_MAX; |
| 18 | + val += 0x1; |
| 19 | + return val; |
Zelalem | 2a45073 | 2020-08-04 12:17:56 -0500 | [diff] [blame] | 20 | +} |
| 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 Bailleux | fcdb210 | 2023-09-13 11:05:38 +0200 | [diff] [blame] | 25 | @@ -216,6 +229,10 @@ void bl31_main(void) |
| 26 | PMF_CAPTURE_TIMESTAMP(bl_svc, BL31_EXIT, PMF_CACHE_MAINT); |
| 27 | console_flush(); |
| 28 | #endif |
Zelalem | 2a45073 | 2020-08-04 12:17:56 -0500 | [diff] [blame] | 29 | + |
| 30 | + /* Run UBSAN Test */ |
Sandrine Bailleux | fcdb210 | 2023-09-13 11:05:38 +0200 | [diff] [blame] | 31 | + INFO("BL31: Running UBSAN test\n"); |
| 32 | + ubsan_test_add_overflow(); |
Zelalem | 2a45073 | 2020-08-04 12:17:56 -0500 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | /******************************************************************************* |