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

[Xen-devel] [PATCH v2 1/2] x86/ubsan: Don't perform alignment checking on supporting compilers



GCC 5 introduced -fsanitize=alignment which is enabled by default by
CONFIG_UBSAN.  This trips a load of wont-fix cases in the ACPI tables and the
hypercall page and stubs writing logic.

It also causes the native Xen boot to crash before the console is set up, for
an as-yet unidentified reason (most likley a wont-fix case earlier on boot).

Disable alignment sanitisation on compilers which would try using it.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Wei Liu <wl@xxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
CC: Julien Grall <julien.grall@xxxxxxx>

v2:
 * Avoid using -fno-sanitize=alignment for ARM
---
 xen/Rules.mk          | 5 ++++-
 xen/arch/x86/Rules.mk | 4 ++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/xen/Rules.mk b/xen/Rules.mk
index a151b3f625..bf81735b8b 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -138,7 +138,10 @@ $(filter-out %.init.o $(nocov-y),$(obj-y) $(obj-bin-y) 
$(extra-y)): CFLAGS += $(
 endif
 
 ifeq ($(CONFIG_UBSAN),y)
-$(filter-out %.init.o $(noubsan-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS 
+= -fsanitize=undefined
+UBSAN_FLAGS += -fsanitize=undefined
+# Any -fno-sanitise= options need to come after any -fsanitise= options
+$(filter-out %.init.o $(noubsan-y),$(obj-y) $(obj-bin-y) $(extra-y)):\
+CFLAGS += $(filter-out -fno-%,$(UBSAN_FLAGS)) $(filter -fno-%,$(UBSAN_FLAGS))
 endif
 
 ifeq ($(CONFIG_LTO),y)
diff --git a/xen/arch/x86/Rules.mk b/xen/arch/x86/Rules.mk
index babc0edbcd..00d861cf76 100644
--- a/xen/arch/x86/Rules.mk
+++ b/xen/arch/x86/Rules.mk
@@ -57,6 +57,10 @@ endif
 $(call cc-option-add,CFLAGS-stack-boundary,CC,-mpreferred-stack-boundary=3)
 CFLAGS += $(CFLAGS-stack-boundary)
 
+ifeq ($(CONFIG_UBSAN),y)
+$(call cc-option-add,UBSAN_FLAGS,CC,-fno-sanitize=alignment)
+endif
+
 # Set up the assembler include path properly for older toolchains.
 CFLAGS += -Wa,-I$(BASEDIR)/include
 
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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