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

2019-07-31 Thread Andrew Cooper
On 26/07/2019 08:33, Jan Beulich wrote:
 On 27.06.19 at 20:56,  wrote:
>> 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 
> Reviewed-by: Jan Beulich 
>
> I'm sorry for the delay - it was only now that I've been told how
> to access the mails still delivered to my old mailbox between me
> leaving the office that day and the switch of mailboxes actually
> having happened.

TBH, I'd completely forgotten about this series.  Thanks for the reminder.

~Andrew

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

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

2019-07-26 Thread Jan Beulich
>>> On 27.06.19 at 20:56,  wrote:
> 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 

Reviewed-by: Jan Beulich 

I'm sorry for the delay - it was only now that I've been told how
to access the mails still delivered to my old mailbox between me
leaving the office that day and the switch of mailboxes actually
having happened.

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

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

2019-06-27 Thread Andrew Cooper
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 
---
CC: Jan Beulich 
CC: Wei Liu 
CC: Roger Pau Monné 
CC: Stefano Stabellini 
CC: Julien Grall 

v2:
 * Avoid using -fno-sanitize=alignment for ARM
v3:
 * Use CFLAGS_UBSAN, initialised to empty first.
 * Leave a comment explaining why we use -fno-sanitize=alignment

The reason why x86 has a ifeq ($(CONFIG_UBSAN),y) is to avoid yet another
cc-option-add evaluated for every translation uint in the default case.  This
will all go away when we update to a recent version of Kconfig which moves all
the toolchain checks into that phase.
---
 xen/Rules.mk  | 8 +++-
 xen/arch/x86/Rules.mk | 8 
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/xen/Rules.mk b/xen/Rules.mk
index a151b3f625..3090ea7828 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -41,6 +41,9 @@ ALL_OBJS-y   += $(BASEDIR)/xsm/built_in.o
 ALL_OBJS-y   += $(BASEDIR)/arch/$(TARGET_ARCH)/built_in.o
 ALL_OBJS-$(CONFIG_CRYPTO)   += $(BASEDIR)/crypto/built_in.o
 
+# Initialise some variables
+CFLAGS_UBSAN :=
+
 ifeq ($(CONFIG_DEBUG),y)
 CFLAGS += -O1
 else
@@ -138,7 +141,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
+CFLAGS_UBSAN += -fsanitize=undefined
+# Any -fno-sanitize= options need to come after any -fsanitize= options
+$(filter-out %.init.o $(noubsan-y),$(obj-y) $(obj-bin-y) $(extra-y)): \
+CFLAGS += $(filter-out -fno-%,$(CFLAGS_UBSAN)) $(filter -fno-%,$(CFLAGS_UBSAN))
 endif
 
 ifeq ($(CONFIG_LTO),y)
diff --git a/xen/arch/x86/Rules.mk b/xen/arch/x86/Rules.mk
index babc0edbcd..52e93afb48 100644
--- a/xen/arch/x86/Rules.mk
+++ b/xen/arch/x86/Rules.mk
@@ -57,6 +57,14 @@ endif
 $(call cc-option-add,CFLAGS-stack-boundary,CC,-mpreferred-stack-boundary=3)
 CFLAGS += $(CFLAGS-stack-boundary)
 
+ifeq ($(CONFIG_UBSAN),y)
+# Don't enable alignment sanitisation.  x86 has efficient unaligned accesses,
+# and various things (ACPI tables, hypercall pages, stubs, etc) are wont-fix.
+# It also causes an as-yet-unidentified crash on native boot before the
+# console starts.
+$(call cc-option-add,CFLAGS_UBSAN,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@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel