From fd8ffdb8331c5fd866759e59fc578b98d08cebce Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Tue, 26 Jul 2022 13:19:17 -0700 Subject: [PATCH] boards: qemu_x86_tiny: enable support for coverage This adds the bits so that we can use qemu_x86_tiny for coverage, as this is currently the only board that can do demand paging. This uses the board revision as a way to specify the RAM size as coverage requires more memory available to store the coverage data. By piggybacking onto board revision, this avoids adding another board config just for coverage. Signed-off-by: Daniel Leung --- boards/x86/qemu_x86/Kconfig.board | 1 + boards/x86/qemu_x86/qemu_x86_tiny.ld | 32 +++++++++++++++++++ boards/x86/qemu_x86/qemu_x86_tiny_768.conf | 5 +++ boards/x86/qemu_x86/qemu_x86_tiny_768.overlay | 10 ++++++ boards/x86/qemu_x86/revision.cmake | 5 +++ .../mbox_api/boards/qemu_x86_tiny_768.conf | 5 +++ .../mem_map/boards/qemu_x86_tiny_768.overlay | 3 ++ .../stackprot/boards/qemu_x86_tiny_768.conf | 5 +++ 8 files changed, 66 insertions(+) create mode 100644 boards/x86/qemu_x86/qemu_x86_tiny_768.conf create mode 100644 boards/x86/qemu_x86/qemu_x86_tiny_768.overlay create mode 100644 boards/x86/qemu_x86/revision.cmake create mode 100644 tests/kernel/mbox/mbox_api/boards/qemu_x86_tiny_768.conf create mode 100644 tests/kernel/mem_protect/mem_map/boards/qemu_x86_tiny_768.overlay create mode 100644 tests/kernel/mem_protect/stackprot/boards/qemu_x86_tiny_768.conf diff --git a/boards/x86/qemu_x86/Kconfig.board b/boards/x86/qemu_x86/Kconfig.board index 739f18c1eec..275d1c69757 100644 --- a/boards/x86/qemu_x86/Kconfig.board +++ b/boards/x86/qemu_x86/Kconfig.board @@ -26,3 +26,4 @@ config BOARD_QEMU_X86_TINY depends on SOC_IA32 select QEMU_TARGET select CPU_HAS_FPU + select HAS_COVERAGE_SUPPORT diff --git a/boards/x86/qemu_x86/qemu_x86_tiny.ld b/boards/x86/qemu_x86/qemu_x86_tiny.ld index beb78735f98..03720146eb2 100644 --- a/boards/x86/qemu_x86/qemu_x86_tiny.ld +++ b/boards/x86/qemu_x86/qemu_x86_tiny.ld @@ -189,6 +189,7 @@ MEMORY LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, cbprintf_complete) \ LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, cbprintf_nano) \ LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, configs) \ + LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, coverage) \ LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, heap) \ LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, heap-validate) \ LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, mutex) \ @@ -198,6 +199,8 @@ MEMORY LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, stdout_console) \ LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, sys_clock_init) \ LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, rb) \ + LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, tracing_none) \ + LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, tracing_tracking) \ LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, thread_entry) \ LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, work_q) @@ -395,6 +398,10 @@ SECTIONS *libc.a:(.text.*) #endif /* CONFIG_NEWLIB_LIBC */ +#ifdef CONFIG_COVERAGE + *(.text._sub_I_00100_0) +#endif + ZEPHYR_KERNEL_FUNCS_IN_SECT #include @@ -436,6 +443,7 @@ SECTIONS #endif /* CONFIG_NEWLIB_LIBC */ #include +#include #include @@ -466,14 +474,34 @@ SECTIONS LIB_DRIVERS_IN_SECT(data) LIB_SUBSYS_LOGGING_IN_SECT(data) +#ifdef CONFIG_COVERAGE + *(.data.__gcov_.*) + + /* + * This is for the struct gcov_info for + * various functions. + */ + *(.data..LPBX*) +#endif + } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) #include #include #include +/* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ +#include + lnkr_pinned_data_end = .; +/* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ +#include + SECTION_PROLOGUE(pinned.bss, (NOLOAD),) { . = ALIGN(4); @@ -491,6 +519,10 @@ SECTIONS LIB_DRIVERS_IN_SECT(bss) LIB_SUBSYS_LOGGING_IN_SECT(bss) +#ifdef CONFIG_COVERAGE + *(.bss.__gcov0.*) +#endif + lnkr_pinned_bss_end = .; } GROUP_NOLOAD_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) diff --git a/boards/x86/qemu_x86/qemu_x86_tiny_768.conf b/boards/x86/qemu_x86/qemu_x86_tiny_768.conf new file mode 100644 index 00000000000..4601be10f38 --- /dev/null +++ b/boards/x86/qemu_x86/qemu_x86_tiny_768.conf @@ -0,0 +1,5 @@ +# Copyright (c) 2022 Intel Corporation. +# SPDX-License-Identifier: Apache-2.0 + +# Enable coverage regardless since this config for coverage only. +CONFIG_COVERAGE=y diff --git a/boards/x86/qemu_x86/qemu_x86_tiny_768.overlay b/boards/x86/qemu_x86/qemu_x86_tiny_768.overlay new file mode 100644 index 00000000000..bb92000cb41 --- /dev/null +++ b/boards/x86/qemu_x86/qemu_x86_tiny_768.overlay @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2022 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Override with 768KB DRAM */ +&dram0 { + reg = < 0x100000 DT_SIZE_K(768) >; +}; diff --git a/boards/x86/qemu_x86/revision.cmake b/boards/x86/qemu_x86/revision.cmake new file mode 100644 index 00000000000..96fc09545a1 --- /dev/null +++ b/boards/x86/qemu_x86/revision.cmake @@ -0,0 +1,5 @@ +# Copyright (c) 2022 Intel Corporation. +# SPDX-License-Identifier: Apache-2.0 + +# We can't really do board_check_revision() here +# as it will apply to all qemu_x86* boards. diff --git a/tests/kernel/mbox/mbox_api/boards/qemu_x86_tiny_768.conf b/tests/kernel/mbox/mbox_api/boards/qemu_x86_tiny_768.conf new file mode 100644 index 00000000000..c10fad4375b --- /dev/null +++ b/tests/kernel/mbox/mbox_api/boards/qemu_x86_tiny_768.conf @@ -0,0 +1,5 @@ +# Copyright (c) 2022 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +# Need quite some space for coverage. +CONFIG_TEST_EXTRA_STACK_SIZE=1024 diff --git a/tests/kernel/mem_protect/mem_map/boards/qemu_x86_tiny_768.overlay b/tests/kernel/mem_protect/mem_map/boards/qemu_x86_tiny_768.overlay new file mode 100644 index 00000000000..dffdf462738 --- /dev/null +++ b/tests/kernel/mem_protect/mem_map/boards/qemu_x86_tiny_768.overlay @@ -0,0 +1,3 @@ +&dram0 { + reg = < 0x100000 0x100000 >; +}; diff --git a/tests/kernel/mem_protect/stackprot/boards/qemu_x86_tiny_768.conf b/tests/kernel/mem_protect/stackprot/boards/qemu_x86_tiny_768.conf new file mode 100644 index 00000000000..b266485dc1b --- /dev/null +++ b/tests/kernel/mem_protect/stackprot/boards/qemu_x86_tiny_768.conf @@ -0,0 +1,5 @@ +# Copyright 2022 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +# This is needed for coverage. +CONFIG_MAIN_STACK_SIZE=4096