Boyan Karatotev | 2abf844 | 2025-08-27 15:26:45 +0100 | [diff] [blame] | 1 | diff --git i/bl31/bl31_main.c w/bl31/bl31_main.c |
| 2 | index bf870a392..65eb3b8f2 100644 |
| 3 | --- i/bl31/bl31_main.c |
| 4 | +++ w/bl31/bl31_main.c |
| 5 | @@ -94,6 +94,19 @@ static void __init bl31_lib_init(void) |
| 6 | cm_init(); |
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 |
Boyan Karatotev | 2abf844 | 2025-08-27 15:26:45 +0100 | [diff] [blame] | 25 | @@ -235,6 +248,10 @@ void __no_pauth bl31_main(u_register_t arg0, u_register_t arg1, u_register_t arg |
Manish Pandey | aac106f | 2024-03-05 11:35:49 +0000 | [diff] [blame] | 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 | |
Boyan Karatotev | 2abf844 | 2025-08-27 15:26:45 +0100 | [diff] [blame] | 35 | void __no_pauth bl31_warmboot(void) |