From a6ebe08333dcc6c263b6bb8936d4883663c63798 Mon Sep 17 00:00:00 2001 From: Harshit Sharma Date: Mon, 20 Jul 2020 00:21:05 -0700 Subject: lib: Add ASan support to romstage on x86 arch This patch adds ASan support to romstage on x86 architecture. A Kconfig option is added to enable ASan in romstage. Compiler flags are updated. A memory space representing the shadow region is reserved in linker section. And a function call to asan_init() is added to initialize shadow region when romstage loads. Change-Id: I67ebfb5e8d602e865b1f5c874860861ae4e54381 Signed-off-by: Harshit Sharma Reviewed-on: https://review.coreboot.org/c/coreboot/+/43604 Tested-by: build bot (Jenkins) Reviewed-by: Werner Zeh --- src/arch/x86/assembly_entry.S | 4 ++++ src/arch/x86/car.ld | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/arch') diff --git a/src/arch/x86/assembly_entry.S b/src/arch/x86/assembly_entry.S index fb48469c55..0d8307bb1f 100644 --- a/src/arch/x86/assembly_entry.S +++ b/src/arch/x86/assembly_entry.S @@ -49,6 +49,10 @@ debug_spinloop: #if CONFIG(IDT_IN_EVERY_STAGE) call exception_init #endif + +#if CONFIG(ASAN_IN_ROMSTAGE) + call asan_init +#endif call car_stage_entry /* Expect to never return. */ diff --git a/src/arch/x86/car.ld b/src/arch/x86/car.ld index 17b774845b..eabe87380a 100644 --- a/src/arch/x86/car.ld +++ b/src/arch/x86/car.ld @@ -72,8 +72,12 @@ *(.sbss.*) . = ALIGN(ARCH_POINTER_ALIGN_SIZE); _ebss = .; - _car_unallocated_start = .; +#if ENV_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE) + _shadow_size = (_ebss - _car_region_start) >> 3; + REGION(asan_shadow, ., _shadow_size, ARCH_POINTER_ALIGN_SIZE) +#endif + _car_unallocated_start = .; _car_region_end = . + CONFIG_DCACHE_RAM_SIZE - (. - _car_region_start); } . = _car_region_end; -- cgit v1.2.3