[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XEN][PATCH] coverage: add extended coverage capabilities


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Wed, 3 Dec 2025 22:24:37 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bPtGcHBEXFQVmoPyWWG8r+gWneBTvEfW3Fjt1tGU0Ws=; b=XoJZ8uoT6ddshkID9euPlo+EA62KrrAKOBUhWFCduplTSjvS1+852ckihDkg/g81gz0kjtiZ0YjeLxQ0QP5e3+ybw/Csiek60rU3LTv1UuVJREwoznQkY/145V5DsV+xZSk3br3BguszzhjkhsP43Qo73ip+Cz8IRgVXvUhDFEMOiBSfPBdfQueQTW8aP6HldB1BL2DUyi7Wb3QP0nTp7N/0uRcoTmKbFd6jJAD3RaZJxYIaoqiSYr2OA9V/3ZidvW/Y771lg0rXmKLg5cvy3ygXWFLjQpdX6Quz1z2zAcdr0oIeZDl4IDVAO6UqDlSFlrdXnsX6XkoWGBCHdJ6zeA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pvrhbRmi8BUoz1kZo+v9ojTrgh/0P2GvmZ2KNuF1xqMczteUe1403mupyrNb2I785T52+L4uYhbIZhfK8GGG5uS3b3tBimel838Uvp2wXRp/apeZzBr3ZWNPcivRcnKk+TDAPxAHrNDofW4OfLWLGZ/NQp0lDho1IUavKCXgzgeXKl9f6if4co6+yMIiswdjS4hz8kt5+ReytbMc0T8F9Gk3IsDy07RYFx5cJo0pFWstvrvFnWVCNc95Wu4zYl/RW/jtalk03kmeWBiOZYW0P1x8z6LZnYoxIeU80YaHRc0iJ3i1HsA+9wN27+I/Ke7gwkKDQlCVaDOZBL9So2muYg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Grygorii Strashko <grygorii_strashko@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, Victor Lira <victorm.lira@xxxxxxx>
  • Delivery-date: Wed, 03 Dec 2025 22:25:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcZKObyWzDLx/m00qdJ3PE7ZDmIg==
  • Thread-topic: [XEN][PATCH] coverage: add extended coverage capabilities

From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>

Added CONFIG_COVERAGE_EXTENDED to enable coverage for .init and lib code.
When enabled - Xen .init data will not be freed.

Signed-off-by: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
---
 xen/Kconfig.debug          | 10 ++++++++++
 xen/Rules.mk               | 13 +++++++++++++
 xen/arch/arm/setup.c       |  2 ++
 xen/arch/x86/setup.c       |  4 ++++
 xen/common/libelf/Makefile |  4 +++-
 xen/common/libfdt/Makefile |  4 +++-
 6 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug
index d900d926c555..3e04e1a3992b 100644
--- a/xen/Kconfig.debug
+++ b/xen/Kconfig.debug
@@ -44,6 +44,16 @@ config COVERAGE
 
          If unsure, say N here.
 
+config COVERAGE_EXTENDED
+    bool "Extended Code coverage support"
+    depends on COVERAGE
+    default y
+    help
+      Enable Extended code coverage support which include .init and libs code.
+      The .init sections are not freed in this case.
+
+      If unsure, say N here.
+
 config CONDITION_COVERAGE
        bool "Condition coverage support"
        depends on COVERAGE && CC_HAS_MCDC
diff --git a/xen/Rules.mk b/xen/Rules.mk
index 2b28d1ac3c18..6d66a2332fb0 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -145,11 +145,18 @@ endif
 # Ensure that profile/coverage data is updated atomically
 $(call cc-option-add,cov-cflags-$(CONFIG_COVERAGE),CC,-fprofile-update=atomic)
 
+ifeq ($(CONFIG_COVERAGE_EXTENDED),y)
+$(nocov-y) $(extra-y): \
+    cov-cflags-y :=
+
+$(obj-y) $(obj-bin-y) $(extra-y) $(lib-y): _c_flags += $(cov-cflags-y)
+else
 # Reset cov-cflags-y in cases where an objects has another one as prerequisite
 $(nocov-y) $(filter %.init.o, $(obj-y) $(obj-bin-y) $(extra-y)): \
     cov-cflags-y :=
 
 $(non-init-objects): _c_flags += $(cov-cflags-y)
+endif
 
 ifeq ($(CONFIG_UBSAN),y)
 # Any -fno-sanitize= options need to come after any -fsanitize= options
@@ -260,6 +267,7 @@ $(obj)/%.o: $(src)/%.S FORCE
 
 
 quiet_cmd_obj_init_o = INIT_O  $@
+ifneq ($(CONFIG_COVERAGE_EXTENDED),y)
 define cmd_obj_init_o
     $(OBJDUMP) -h $< | while read idx name sz rest; do \
         case "$$name" in \
@@ -272,6 +280,11 @@ define cmd_obj_init_o
     done || exit $$?; \
     $(OBJCOPY) $(foreach s,$(SPECIAL_DATA_SECTIONS),--rename-section 
.$(s)=.init.$(s)) $< $@
 endef
+else
+define cmd_obj_init_o
+    $(OBJCOPY) $(foreach s,$(SPECIAL_DATA_SECTIONS),--rename-section 
.$(s)=.init.$(s)) $< $@
+endef
+endif
 
 $(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): $(obj)/%.init.o: 
$(obj)/%.o FORCE
        $(call if_changed,obj_init_o)
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 7ad870e382c2..900585eb7099 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -68,10 +68,12 @@ static __used void noreturn init_done(void)
 {
     int rc;
 
+#if !defined(CONFIG_COVERAGE_EXTENDED)
     /* Must be done past setting system_state. */
     unregister_init_virtual_region();
 
     free_init_memory();
+#endif
 
     /*
      * We have finished booting. Mark the section .data.ro_after_init
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 872a8c63f94a..05810fa67787 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -845,6 +845,7 @@ static void noreturn init_done(void)
 
     domain_unpause_by_systemcontroller(dom0);
 
+#if !defined(CONFIG_COVERAGE_EXTENDED)
     /* MUST be done prior to removing .init data. */
     unregister_init_virtual_region();
 
@@ -867,6 +868,9 @@ static void noreturn init_done(void)
     destroy_xen_mappings(start, end);
     init_xenheap_pages(__pa(start), __pa(end));
     printk("Freed %lukB init memory\n", (end - start) >> 10);
+#else
+    (void) end, (void) start, (void)va;
+#endif
 
     /* Mark .rodata/ro_after_init as RO.  Maybe reform the superpage. */
     modify_xen_mappings((unsigned long)&__2M_rodata_start,
diff --git a/xen/common/libelf/Makefile b/xen/common/libelf/Makefile
index 917d12b006f7..337a3a8e1b35 100644
--- a/xen/common/libelf/Makefile
+++ b/xen/common/libelf/Makefile
@@ -1,5 +1,7 @@
 obj-bin-y := libelf.o
-nocov-y += libelf.o
+ifneq ($(CONFIG_COVERAGE_EXTENDED),y)
+       nocov-y += libelf.o
+endif
 libelf-objs := libelf-tools.o libelf-loader.o libelf-dominfo.o
 
 SECTIONS := text data $(SPECIAL_DATA_SECTIONS)
diff --git a/xen/common/libfdt/Makefile b/xen/common/libfdt/Makefile
index 6ce679f98f47..8c62563ccdbc 100644
--- a/xen/common/libfdt/Makefile
+++ b/xen/common/libfdt/Makefile
@@ -5,7 +5,9 @@ SECTIONS := text data $(SPECIAL_DATA_SECTIONS)
 # For CONFIG_OVERLAY_DTB, libfdt functionalities will be needed during runtime.
 ifneq ($(CONFIG_OVERLAY_DTB),y)
 OBJCOPYFLAGS := $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s))
-nocov-y += libfdt.o
+ifneq ($(CONFIG_COVERAGE_EXTENDED),y)
+       nocov-y += libfdt.o
+endif
 endif
 
 obj-y += libfdt.o
-- 
2.34.1



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.