Zelalem | 2a45073 | 2020-08-04 12:17:56 -0500 | [diff] [blame] | 1 | diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c |
Manish Pandey | aac106f | 2024-03-05 11:35:49 +0000 | [diff] [blame] | 2 | index 8c5ba6f2e..21ed3b686 100644 |
Zelalem | 2a45073 | 2020-08-04 12:17:56 -0500 | [diff] [blame] | 3 | --- a/bl31/bl31_main.c |
| 4 | +++ b/bl31/bl31_main.c |
Juan Pablo Conde | c9ee763 | 2023-11-09 17:44:35 -0600 | [diff] [blame] | 5 | @@ -112,6 +112,19 @@ void bl31_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2, |
Yann Gautier | eeb5430 | 2024-01-03 17:37:02 +0100 | [diff] [blame] | 6 | report_ctx_memory_usage(); |
Zelalem | 2a45073 | 2020-08-04 12:17:56 -0500 | [diff] [blame] | 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 |
Manish Pandey | aac106f | 2024-03-05 11:35:49 +0000 | [diff] [blame] | 25 | @@ -224,6 +237,10 @@ void bl31_main(void) |
| 26 | |
Sandrine Bailleux | fcdb210 | 2023-09-13 11:05:38 +0200 | [diff] [blame] | 27 | console_flush(); |
Manish Pandey | aac106f | 2024-03-05 11:35:49 +0000 | [diff] [blame] | 28 | console_switch_state(CONSOLE_FLAG_RUNTIME); |
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 | /******************************************************************************* |