From patchwork Thu Jun 27 18:56:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11020355 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2F2814C0 for ; Thu, 27 Jun 2019 18:58:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B748226E4A for ; Thu, 27 Jun 2019 18:58:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7A8B2793A; Thu, 27 Jun 2019 18:58:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 24E701FFE6 for ; Thu, 27 Jun 2019 18:58:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hgZZM-0004kD-R3; Thu, 27 Jun 2019 18:56:28 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hgZZL-0004k7-Ta for xen-devel@lists.xenproject.org; Thu, 27 Jun 2019 18:56:27 +0000 X-Inumbo-ID: 424c518e-990d-11e9-9db6-1bd82ea84f70 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 424c518e-990d-11e9-9db6-1bd82ea84f70; Thu, 27 Jun 2019 18:56:24 +0000 (UTC) Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: srMw/8wIVKvWvyFCf9UQcAkSdL1mRWZGpE0+fD7JGte1fIUhFetKuCDbQrp8pCKmCtLvghUaxC 6SBUkA8qHMv8JrF/aBdxIx5+B355wZVhQkEiT6prhTX3Fv70xhel+4vY8SHAYCntNv8b618MwB duxkSBWfTbO+GxQHwcCH0iW/v/gpM78ObvRUu1KqDOi0U5bR1jqu3QkY8Et9F4Zb9xfn2ERP5r ux32yYjfPguQCtnFzmXMXl73d4immTFXgsxT7JTwUDUStpkD4SGvkJYoIBTTUcnsZcMmd4AYj+ eZI= X-SBRS: 2.7 X-MesageID: 2345786 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.63,424,1557201600"; d="scan'208";a="2345786" From: Andrew Cooper To: Xen-devel Date: Thu, 27 Jun 2019 19:56:20 +0100 Message-ID: <20190627185620.4724-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190624101723.23291-2-andrew.cooper3@citrix.com> References: <20190624101723.23291-2-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 1/2] x86/ubsan: Don't perform alignment checking on supporting compilers X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Andrew Cooper , Julien Grall , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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