mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-06-12 22:31:45 +01:00
7bdcf55705
UBSan (Undefined Behavior Sanitizer) is a tool implemented using compiler instrumentation at runtime that allows checking for statements whose output is not deterministic or defined by the C standard. Compiling and running OpenSBI with UBSan instrumentation will print a message in the console if any sentence performs such an action. Support involves two main components: 1. The UBSan implementation hooks (derived from NetBSD), used by the compiler to handle the check output. 2. A test suite integrated with the SBI unit test framework to verify correct operation at runtime. Usage: make UBSAN=y PLATFORM=generic ... The test suite is built when both UBSAN=y and CONFIG_SBIUNIT=y are enabled. When UBSan is enabled, FW_PAYLOAD_OFFSET may need to be increased due to the size increase added by the instrumentation. A value of 0x400000 has been tested. UBSan adds runtime overhead and is intended for development builds only, not for production. Note: This patch marks __stack_chk_guard in sbi_init.c as a weak symbol to prevent multiple definition errors at compile time with UBSan instrumentation enabled. This resolves the conflict between the .globl definitions in sbi_init.c and test_head.S. Signed-off-by: Marcos Oduardo <marcos.oduardo@gmail.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20260515163321.2038366-1-marcos.oduardo@gmail.com Signed-off-by: Anup Patel <anup@brainfault.org>
32 lines
1.2 KiB
Makefile
32 lines
1.2 KiB
Makefile
libsbi-objs-$(CONFIG_SBIUNIT) += tests/sbi_unit_test.o
|
|
libsbi-objs-$(CONFIG_SBIUNIT) += tests/sbi_unit_tests.carray.o
|
|
|
|
carray-sbi_unit_tests-$(CONFIG_SBIUNIT) += bitmap_test_suite
|
|
libsbi-objs-$(CONFIG_SBIUNIT) += tests/sbi_bitmap_test.o
|
|
|
|
carray-sbi_unit_tests-$(CONFIG_SBIUNIT) += console_test_suite
|
|
libsbi-objs-$(CONFIG_SBIUNIT) += tests/sbi_console_test.o
|
|
|
|
carray-sbi_unit_tests-$(CONFIG_SBIUNIT) += atomic_test_suite
|
|
libsbi-objs-$(CONFIG_SBIUNIT) += tests/riscv_atomic_test.o
|
|
|
|
carray-sbi_unit_tests-$(CONFIG_SBIUNIT) += locks_test_suite
|
|
libsbi-objs-$(CONFIG_SBIUNIT) += tests/riscv_locks_test.o
|
|
|
|
carray-sbi_unit_tests-$(CONFIG_SBIUNIT) += math_test_suite
|
|
libsbi-objs-$(CONFIG_SBIUNIT) += tests/sbi_math_test.o
|
|
|
|
carray-sbi_unit_tests-$(CONFIG_SBIUNIT) += ecall_test_suite
|
|
libsbi-objs-$(CONFIG_SBIUNIT) += tests/sbi_ecall_test.o
|
|
|
|
carray-sbi_unit_tests-$(CONFIG_SBIUNIT) += bitops_test_suite
|
|
libsbi-objs-$(CONFIG_SBIUNIT) += tests/sbi_bitops_test.o
|
|
|
|
carray-sbi_unit_tests-$(CONFIG_SBIUNIT) += string_test_suite
|
|
libsbi-objs-$(CONFIG_SBIUNIT) += tests/sbi_string_test.o
|
|
|
|
ifeq ($(UBSAN),y)
|
|
carray-sbi_unit_tests-$(CONFIG_SBIUNIT) += ubsan_test_suite
|
|
libsbi-objs-$(CONFIG_SBIUNIT) += tests/sbi_ubsan_test.o
|
|
endif
|