Fix gcov build
cover Fix gcov build
A small series to fix gcov build for both x86 and arm.
Wei Liu (4):
arm: acpi/boot.c is only used during initialisation
arm64: use "b" to branch to start_xen
xen: fix gcov compilation
xen: add a gcov Kconfig option
Config.mk | 3 --- xen/Kconfig.debug | 5 +++++ xen/Rules.mk | 4 +++- xen/arch/arm/acpi/Makefile | 2 +- xen/arch/arm/acpi/boot.c | 2 +- xen/arch/arm/arm64/head.S | 4 +++- xen/arch/x86/efi/Makefile | 1 + xen/common/Makefile | 2 +- 8 files changed, 15 insertions(+), 8 deletions(-)
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 1/4 arm: acpi/boot.c is only used during initialisation
That file should contain code and data used during initialisation only.
Mark it as such in build system and correctly annotate enabled_cpus. This is required to enable gcov support on ARM.
---
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
--- xen/arch/arm/acpi/Makefile | 2 +- xen/arch/arm/acpi/boot.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/acpi/Makefile +1 -1
@@ -1,2 +1,2 @@ obj-y += lib.o -obj-y += boot.o +obj-y += boot.init.o
xen/arch/arm/acpi/boot.c +1 -1
@@ -37,7 +37,7 @@#include <asm/setup.h> /* Processors with enabled flag and sane MPIDR */ -static unsigned int enabled_cpus =1 ; +static unsigned int __initdata enabled_cpus =1 ;static bool __initdata bootcpu_valid;/* total number of cpus in this system */
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 1/4] arm: acpi/boot.c is only used during initialisation
Hi Wei,
Quoted 4 lines · Wei Liu
That file should contain code and data used during initialisation only.
Mark it as such in build system and correctly annotate
enabled_cpus. This is required to enable gcov support on ARM.
I am not sure to understand the requirement here. Does it mean it is not possible to have a mix of init code and runtime code?
Quoted 2 lines
Signed-off-by Wei Liu <[email protected]>
Regardless the questions:
Quoted 22 lines
---
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>--- xen/arch/arm/acpi/Makefile | 2 +- xen/arch/arm/acpi/boot.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)xen/arch/arm/acpi/Makefile +1
-1@@ -1,2 +1,2 @@ obj-y += lib.o -obj-y += boot.o +obj-y += boot.init.oxen/arch/arm/acpi/boot.c +0
-0
xen/arch/arm/acpi/boot.c line 43
Quoted 8 lines
xen/arch/arm/acpi/boot.c +1
-1@@ -37,7 +37,7 @@#include <asm/setup.h> /* Processors with enabled flag and sane MPIDR */ -static unsigned int enabled_cpus =1 ; +static unsigned int __initdata enabled_cpus =1 ;static bool __initdata bootcpu_valid;/* total number of cpus in this system */
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 1/4] arm: acpi/boot.c is only used during initialisation
Quoted 11 lines · Julien Grall
Hi Wei,
Quoted 4 lines · Wei Liu
That file should contain code and data used during initialisation only.
Mark it as such in build system and correctly annotate
enabled_cpus. This is required to enable gcov support on ARM.I am not sure to understand the requirement here. Does it mean it is not possible to have a mix of init code and runtime code?
No. That's still allowed.
"This is required to enable gcov support on ARM" is remnant that should be deleted, because strictly speaking if we don't change boot.o to boot.init.o, the resulting binary should still work.
Please consider this patch a general cleanup.
Can I keep your RoB?
Quoted 35 lines
Quoted 2 lines
Signed-off-by Wei Liu <[email protected]>Regardless the questions:
Reviewed-by Julien Grall <[email protected]>Quoted 28 lines
---
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
---
xen/arch/arm/acpi/Makefile | 2 +-xen/arch/arm/acpi/boot.c| 2 +-2 files changed, 2 insertions(+), 2 deletions(-)xen/arch/arm/acpi/Makefile +0
-0@@ -1,2 +1,2 @@obj-y += lib.o
xen/arch/arm/acpi/Makefile +1
-1-obj-y += boot.o +obj-y += boot.init.oxen/arch/arm/acpi/boot.c +1
-1@@ -37,7 +37,7 @@#include <asm/setup.h> /* Processors with enabled flag and sane MPIDR */ -static unsigned int enabled_cpus =1 ; +static unsigned int __initdata enabled_cpus =1 ;static bool __initdata bootcpu_valid;
Quoted 7 lines
xen/arch/arm/acpi/boot.c line 43
Quoted 2 lines
xen/arch/arm/acpi/boot.c +0
-0/* total number of cpus in this system */ Regards,
Signature · 1 line
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 1/4] arm: acpi/boot.c is only used during initialisation
Quoted 13 lines · Wei Liu
Quoted 11 lines · Julien Grall
Hi Wei,
Quoted 4 lines · Wei Liu
That file should contain code and data used during initialisation only.
Mark it as such in build system and correctly annotate
enabled_cpus. This is required to enable gcov support on ARM.I am not sure to understand the requirement here. Does it mean it is not possible to have a mix of init code and runtime code?
Quoted 7 lines
No. That's still allowed.
"This is required to enable gcov support on ARM" is remnant that should be deleted, because strictly speaking if we don't change boot.o to boot.init.o, the resulting binary should still work.
Please consider this patch a general cleanup.
I had a similar clean up in my todo list :).
Quoted 1 line
Can I keep your RoB?
Sure.
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/4 arm64: use "b" to branch to start_xen
In reply to Wei LiuThe cbz instruction has range limitation. When compiled with gcov support the object is larger so cbz can't handle that anymore. The error message is like:
aarch64-linux-gnu-ld -EL -T xen.lds -N prelink.o \
/local/work/xen.git/xen/common/symbols-dummy.o -o /local/work/xen.git/xen/.xen-syms.0
prelink.o: In function `launch':
/local/work/xen.git/xen/arch/arm/arm64/head.S:602:(.text+0x408): relocation truncated to fit: R_AARCH64_CONDBR19 against symbol `start_xen' defined in .init.text section in prelink.o
Use "b" instead.
---
Compile test only.
--- xen/arch/arm/arm64/head.S | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
xen/arch/arm/arm64/head.S +3 -1
@@ -599,7 +599,9 @@ launch: mov x0, x20 /* Marshal args: - phys_offset */ mov x1, x21 /* - FDT */ mov x2, x24 /* - CPU ID */ - cbz x22, start_xen /* and disappear into the land of C */ + cbnz x22, 1f + b start_xen /* and disappear into the land of C */ +1: b start_secondary /* (to the appropriate entry point) */ /* Fail-stop */
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 2/4] arm64: use "b" to branch to start_xen
Quoted 9 lines · Wei Liu
The cbz instruction has range limitation. When compiled with gcov support the object is larger so cbz can't handle that anymore. The error message is like:
aarch64-linux-gnu-ld -EL -T
xen.lds-N prelink.o \
/local/work/xen.git/xen/common/symbols-dummy.o -o /local/work/xen.git/xen/.xen-syms.0
prelink.o: In function `launch':
/local/work/xen.git/xen/arch/arm/arm64/head.S:602:(.text+0x408): relocation truncated to fit:R_AARCH64_CONDBR19against symbol `start_xen' defined in .init.text section in prelink.o
Quoted 5 lines
Use "b" instead.
Signed-off-by Wei Liu <[email protected]>---
Compile test only.
Quoted 30 lines
Cc Stefano Stabellini <[email protected]>Cc Julien Grall <[email protected]>--- xen/arch/arm/arm64/head.S | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)xen/arch/arm/arm64/head.S +3
-1@@ -599,7 +599,9 @@ launch: mov x0, x20 /* Marshal args: - phys_offset */ mov x1, x21 /* - FDT */ mov x2, x24 /* - CPU ID */ - cbz x22, start_xen /* and disappear into the land of C */ + cbnz x22, 1f + b start_xen /* and disappear into the land of C */ +1: b start_secondary /* (to the appropriate entry point) */ /* Fail-stop */Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/4] arm64: use "b" to branch to start_xen
In reply to Wei LiuHi Wei,
Quoted 10 lines · Wei Liu
The cbz instruction has range limitation. When compiled with gcov support the object is larger so cbz can't handle that anymore. The error message is like:
aarch64-linux-gnu-ld -EL -T
xen.lds-N prelink.o \
/local/work/xen.git/xen/common/symbols-dummy.o -o /local/work/xen.git/xen/.xen-syms.0
prelink.o: In function `launch':
/local/work/xen.git/xen/arch/arm/arm64/head.S:602:(.text+0x408): relocation truncated to fit:R_AARCH64_CONDBR19against symbol `start_xen' defined in .init.text section in prelink.oUse "b" instead.
From a quick look the size of xen doubled (776K -> 1.4M) with GCov. Xen on ARM assumes the binary will always fit in 2MB, it might be time to get rid of this limit.
I know that enabling UBSAN [1] will lead to a binary bigger than 2MB and Xen will explode in early boot.
Quoted 1 line
Signed-off-by Wei Liu <[email protected]>
Regards,
[1] http://developers.redhat.com/blog/2014/10/16/gcc-undefined-behavior-sanitizer-ubsan/
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 3/4 xen: fix gcov compilation
In reply to Wei LiuCurrently enabling gcov in hypervisor won't build because although 26c9d03d ("gcov: Adding support for coverage information") claimed that %.init.o files were excluded from applying compilation options, it was in fact not true.
Fix that by filtering out the options correctly. Due to the dependency of stub.o in x86 EFI build can't be eliminated easily and we prefer a generalised method going forward, we introduce nogov-y to explicitly mark objects that don't need to build with gcov support.
---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>
--- xen/Rules.mk | 4 +++- xen/arch/x86/efi/Makefile | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
xen/Rules.mk +3 -1
@@ -115,7 +115,9 @@ subdir-all := $(subdir-y) $(subdir-n) $(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -DINIT_SECTIONS_ONLY -$(obj-$(coverage)): CFLAGS += -fprofile-arcs -ftest-coverage -DTEST_COVERAGE +ifeq ($(coverage),y) +$(filter-out %.init.o $(nogcov-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -fprofile-arcs -ftest-coverage -DTEST_COVERAGE +endif ifeq ($(lto),y) # Would like to handle all object files as bitcode, but objects made from
xen/arch/x86/efi/Makefile +1 -0
@@ -12,3 +12,4 @@ efi := $(if $(efi),$(shell rm disabled)y,$(shell $(call create,boot.init.o); $(c extra-$(efi) += boot.init.o relocs-dummy.o runtime.o compat.o stub.o: $(extra-y) +nogcov-$(efi) += stub.o
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 3/4] xen: fix gcov compilation
Wei Liu writes ("[PATCH 3/4] xen: fix gcov compilation"):
Quoted 8 lines
Currently enabling gcov in hypervisor won't build because although
26c9d03d("gcov: Adding support for coverage information") claimed that %.init.o files were excluded from applying compilation options, it was in fact not true.Fix that by filtering out the options correctly. Due to the dependency of stub.o in x86 EFI build can't be eliminated easily and we prefer a generalised method going forward, we introduce nogov-y to explicitly
^
Quoted 1 line
mark objects that don't need to build with gcov support.
And I'm afraid the second sentence there is not comprehensible. It seesm to be "Due to X, Y" but I can't quite figure out which parts of the sentence are X and which are Y.
I'm not unhappy with the approach in the Makefile, though.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 3/4] xen: fix gcov compilation
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 30.08.16 at 14:57, <[email protected]> wrote:
Wei Liu writes ("[PATCH 3/4] xen: fix gcov compilation"):
Quoted 8 lines
Currently enabling gcov in hypervisor won't build because although
26c9d03d("gcov: Adding support for coverage information") claimed that %.init.o files were excluded from applying compilation options, it was in fact not true.Fix that by filtering out the options correctly. Due to the dependency of stub.o in x86 EFI build can't be eliminated easily and we prefer a generalised method going forward, we introduce nogov-y to explicitly
Quoted 6 lines
^Quoted 1 line
mark objects that don't need to build with gcov support.
And I'm afraid the second sentence there is not comprehensible. It seesm to be "Due to X, Y" but I can't quite figure out which parts of the sentence are X and which are Y.
Does s/Due to/Since/ in the original sentence help?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 3/4] xen: fix gcov compilation
In reply to Ian JacksonQuoted 9 lines · Ian Jackson
Wei Liu writes ("[PATCH 3/4] xen: fix gcov compilation"):
Quoted 8 lines
Currently enabling gcov in hypervisor won't build because although
26c9d03d("gcov: Adding support for coverage information") claimed that %.init.o files were excluded from applying compilation options, it was in fact not true.Fix that by filtering out the options correctly. Due to the dependency of stub.o in x86 EFI build can't be eliminated easily and we prefer a generalised method going forward, we introduce nogov-y to explicitly
Quoted 7 lines
^Quoted 1 line
mark objects that don't need to build with gcov support.
And I'm afraid the second sentence there is not comprehensible. It seesm to be "Due to X, Y" but I can't quite figure out which parts of the sentence are X and which are Y.
Let's rewrite it as such:
Due to 1) the dependency of stub.o in x86 EFI build can't be eliminated easily and 2) we prefer a generalised method going forward, we introduce nogov-y to explicitly.
Is this clearer?
Quoted 3 lines
I'm not unhappy with the approach in the
Makefile, though.Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 4/4 xen: add a gcov Kconfig option
In reply to Wei Liu---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Doug Goldstein <[email protected]>
Would like to have it default to DEBUG, but we also need to check compiler to be gcc. I couldn't figure out how to check compiler to be gcc in Kconfig.
--- Config.mk | 3 --- xen/Kconfig.debug | 5 +++++ xen/Rules.mk | 2 +- xen/common/Makefile | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-)
Config.mk +0 -3
@@ -20,9 +20,6 @@ or = $(if $(strip $(1)),$(1),$(if $(strip $(2)),$(2),$(if $(strip $(3)),$( debug ?= y debug_symbols ?= $(debug) -# Test coverage support -coverage ?= n - XEN_COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/ \ -e s/i86pc/x86_32/ -e s/amd64/x86_64/ \ -e s/armv7.*/arm32/ -e s/armv8.*/arm64/ \
xen/Kconfig.debug +5 -0
@@ -13,6 +13,11 @@ config DEBUG if DEBUG || EXPERT = "y" +config GCOV + bool "Gcov Support" + ---help--- + Enable gcov (a test coverage program in GCC) support. + config CRASH_DEBUG bool "Crash Debugging Support" depends on X86
xen/Rules.mk +1 -1
@@ -115,7 +115,7 @@ subdir-all := $(subdir-y) $(subdir-n) $(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -DINIT_SECTIONS_ONLY -ifeq ($(coverage),y) +ifeq ($(CONFIG_GCOV),y) $(filter-out %.init.o $(nogcov-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -fprofile-arcs -ftest-coverage -DTEST_COVERAGE endif
xen/common/Makefile +1 -1
@@ -75,7 +75,7 @@ obj-$(CONFIG_TMEM) += $(tmem-y) subdir-$(CONFIG_X86) += hvm -subdir-$(coverage) += gcov +subdir-$(CONFIG_GCOV) += gcov subdir-y += libelf subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 4/4] xen: add a gcov Kconfig option
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 30.08.16 at 14:01, <[email protected]> wrote:
Signed-off-by Wei Liu <[email protected]>
with one adjustment (see below).
Quoted 8 lines
Cc Konrad Rzeszutek Wilk <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Tim Deegan <[email protected]>Cc Doug Goldstein <[email protected]>Would like to have it default to DEBUG, but we also need to check compiler to be gcc. I couldn't figure out how to check compiler to be gcc in
Kconfig.
Actually I don't think defaulting to DEBUG would have been a good idea. Why would you want everyone to carry that extra baggage regardless of whether they actually mean to make use of it? And anyway, conversion to Kconfig should retain current behavior, which clearly was ...
Config.mk or = $(if $(strip $(1)),$(1),$(if $(strip $(2)),$(2),$(if $(strip $(3)),$( · line 24
Quoted 9 lines
Config.mk +0
-0@@ -20,9 +20,6 @@ or = $(if $(strip $(1)),$(1),$(if $(strip$(2)),$(2),$(if $(strip $(3)),$(
debug ?= y
debug_symbols?= $(debug)Config.mk +0
-2-# Test coverage support -coverage ?= n
... off by default.
Quoted 4 lines
xen/Kconfig.debug +0
-0@@ -13,6 +13,11 @@ config DEBUG
xen/Kconfig.debug config DEBUG · line 23
Quoted 10 lines
xen/Kconfig.debug +5
-0if DEBUG || EXPERT = "y" +config GCOV + bool "Gcov Support" + ---help--- + Enable gcov (a test coverage program in GCC) support. + config CRASH_DEBUG bool "Crash Debugging Support" depends on X86
I now see that someone prior to you already managed to break the alphabetical ordering (DEVICE_TREE_DEBUG got added to the end), but please don't introduce further issues like this. The only exception here are entries which have dependencies on others in this same section (like PERF_ARRAYS depends on PERF_COUNTERS).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 4/4] xen: add a gcov Kconfig option
Quoted 29 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 30.08.16 at 14:01, <[email protected]> wrote:
Signed-off-by Wei Liu <[email protected]>Acked-by Jan Beulich <[email protected]>with one adjustment (see below).
Quoted 8 lines
Cc Konrad Rzeszutek Wilk <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Tim Deegan <[email protected]>Cc Doug Goldstein <[email protected]>Would like to have it default to DEBUG, but we also need to check compiler to be gcc. I couldn't figure out how to check compiler to be gcc in
Kconfig.Actually I don't think defaulting to DEBUG would have been a good idea. Why would you want everyone to carry that extra baggage regardless of whether they actually mean to make use of it? And anyway, conversion to
Kconfigshould retain current behavior, which clearly was ...Quoted 7 lines
Config.mk +0
-0@@ -20,9 +20,6 @@ or = $(if $(strip $(1)),$(1),$(if $(strip$(2)),$(2),$(if $(strip $(3)),$(
debug ?= y
debug_symbols?= $(debug)
Quoted 5 lines
Config.mk or = $(if $(strip $(1)),$(1),$(if $(strip $(2)),$(2),$(if $(strip $(3)),$( · line 24
Quoted 2 lines
Config.mk +0
-2-# Test coverage support -coverage ?= n... off by default.
OK. Makes sense to me.
Quoted 6 lines
Quoted 6 lines
xen/Kconfig.debug +0
-0@@ -13,6 +13,11 @@ config DEBUG if DEBUG || EXPERT = "y"
Quoted 15 lines
xen/Kconfig.debug config DEBUG · line 23
Quoted 8 lines
xen/Kconfig.debug +5
-0+config GCOV + bool "Gcov Support" + ---help--- + Enable gcov (a test coverage program in GCC) support. + config CRASH_DEBUG bool "Crash Debugging Support" depends on X86I now see that someone prior to you already managed to break the alphabetical ordering (
DEVICE_TREE_DEBUGgot added to the end), but please don't introduce further issues like this. The only exception here are entries which have dependencies on others in this same section (likePERF_ARRAYSdepends onPERF_COUNTERS).
OK. I will move this option to correct location.
Wei.
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 4/4] xen: add a gcov Kconfig option
Quoted 10 lines · Wei Liu
Quoted 6 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 30.08.16 at 14:01, <[email protected]> wrote:
Signed-off-by Wei Liu <[email protected]>Acked-by Jan Beulich <[email protected]>with one adjustment (see below).
Thanks for doing this Wei. I agree with Jan's reviews. You can toss my Reviewed-by: Doug Goldstein <[email protected]> on there if you'd like as well.
--
Doug
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel