From nobody Fri Apr 19 05:53:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1561371537; cv=none; d=zoho.com; s=zohoarc; b=El27bjCGwRWZz2No5HKTgx/qbIcs3i5M0x3JLWQN0vkMDdIcBjwOGbniRFUPAKs+VPGnZdGFGawU2OwuAHDhW5LxQ9vsOM3ofuwAkEb1+ItNoEZ3bwfyjaVjptoZibblnM+8w3pvQ8oj9iUc2tPbUFdOT1+l9Wb89D3r/pWWANM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561371537; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=UX68Ne7TRi6vqU9qnG1dCN7Si0i8XrcypqkWkKdfF1w=; b=BBvC3KJulEV6oIdOUqaf+5M8oPtvz8mMP+s3TnatNtisPlTjQVfS7Gs5oSMyU2cCY4BN3Av2PwmByBg5TOHHTY7ozVDP3OAVw2flFf5Ht4GyBDnJbWDewv+b1rvqamYyqjDWcUvfZMpB4rdrpr3k1MDQ0Rq/1xuBSf4lOQnwcIw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1561371537421702.1958324119975; Mon, 24 Jun 2019 03:18:57 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hfM2Y-00025x-5G; Mon, 24 Jun 2019 10:17:34 +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 1hfM2W-00025r-TQ for xen-devel@lists.xenproject.org; Mon, 24 Jun 2019 10:17:32 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 44818092-9669-11e9-9a83-5333c333f460; Mon, 24 Jun 2019 10:17:28 +0000 (UTC) X-Inumbo-ID: 44818092-9669-11e9-9a83-5333c333f460 Authentication-Results: esa4.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 (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.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=esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: H3eK4YqKYhfCQc//pP0YFWwGqDECrf3/EpaEjDOaystK3aSZT8Y3KG6JsQngcxhuPxdkdyrA1G HGmzNh+dTNEMNF9r6yOEci+aq0V+urKRA4/BrWgTjzvjw3f1abpW34u0oVBeCfQAZ7EJiKNaca 623RURNov0Eo/YYvM6lLKHIAZ6w8YryPQ/EIuy/lId8Kc7zIK/heP3YHMs74Lmegdksw8leNUu RAXCx5WRZNI+9HK28J+W5ItmjYuyTiIw40Rm+4DEuOeww8gtAIEnCzCaHfx8xhGTQRC/xVQ+pZ PIA= X-SBRS: 2.7 X-MesageID: 2154245 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.63,411,1557201600"; d="scan'208";a="2154245" From: Andrew Cooper To: Xen-devel Date: Mon, 24 Jun 2019 11:17:22 +0100 Message-ID: <20190624101723.23291-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190624101723.23291-1-andrew.cooper3@citrix.com> References: <20190624101723.23291-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 1/2] xen/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=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" GCC 5 introduced -fsanitize=3Dalignment which is enabled by default by CONFIG_UBSAN. This trips a load of wont-fix cases in the ACPI tables and t= he hypercall page and stubs writing logic. It also causes the native Xen boot to crash before the console is set up, f= or 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=C3=A9 CC: Stefano Stabellini CC: Julien Grall This isn't ideal, but we can't do better without a bit of an overhaul which= I don't have time for now. Linux uses a whitelist of sanitisers but I'm not entirely sure we want to go that route. ARM currently isn't working well w= ith UBSAN, but AFACIT, all ARM platforms that we support also disable alignment sanitisation in Linux. --- xen/Rules.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/Rules.mk b/xen/Rules.mk index a151b3f625..61cd8ed5d9 100644 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -138,7 +138,9 @@ $(filter-out %.init.o $(nocov-y),$(obj-y) $(obj-bin-y) = $(extra-y)): CFLAGS +=3D $( endif =20 ifeq ($(CONFIG_UBSAN),y) -$(filter-out %.init.o $(noubsan-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLA= GS +=3D -fsanitize=3Dundefined +UBSAN_FLAGS :=3D -fsanitize=3Dundefined +$(call cc-option-add,UBSAN_FLAGS,CC,-fno-sanitize=3Dalignment) +$(filter-out %.init.o $(noubsan-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLA= GS +=3D $(UBSAN_FLAGS) endif =20 ifeq ($(CONFIG_LTO),y) --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 19 05:53:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1561371533; cv=none; d=zoho.com; s=zohoarc; b=nSfGQi14FWBTuOBCxbgT5v5L1s27sAPeK4ei+VkMTH090u7mQDQi4S8J8WRtob8pewpCipoUK9bhysc4iyPUFSDtafq+GAKQcJTYHYGCC3W8K05iUkTW/FXOx3M5CD5MEQ5bVWA735fp+pi1IBqa4fmzka+yAJptOg8GBR7EakE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561371533; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=LHyVaoztrJihNdY0BwRHQ39kXKUQVjzXKiVlx66JN9Y=; b=lCdPJNncIKjBhZ4J7B093Q0/eYdWu0y6NhGWCx25zjGo5HxfG8Ai34xv4LE+XRC/ECMIANVgt10GxAbjIjnmV3/3y9eLGGrQU8TH41E+88n+ApOLNIG6bj2tU85LYmjEg/1HFUmS2O9nBl3B+SkdGnXspPPAmsuupsjo6Bt69zs= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1561371532837893.9154108692215; Mon, 24 Jun 2019 03:18:52 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hfM2Z-00026N-IG; Mon, 24 Jun 2019 10:17:35 +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 1hfM2Y-00025w-4s for xen-devel@lists.xenproject.org; Mon, 24 Jun 2019 10:17:34 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 44c4bf7e-9669-11e9-810a-a7cb20a00708; Mon, 24 Jun 2019 10:17:28 +0000 (UTC) X-Inumbo-ID: 44c4bf7e-9669-11e9-810a-a7cb20a00708 Authentication-Results: esa1.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 (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: wtmDhrRMO1Q6BHPzeWSzkzW4ch6JB7GKPQRAvmrvdGd1l82J6vTOtCK3w9sivrVH0TR2AYjae2 1XkQQOJ+4ZroBk8p5YbK1og2WpzcHk79PvkqUvRzoK+vQA8vm+Ri+Gt64Rrh0yo3P4vHDxWSOK P+s8itDmFknmjz5+nAb9quHa+DVUZ7p3ae55HWiALGaLneMpVXxB4/TIGz6zde5T7zniin3ccF 6jxPMKwEM9NPkuvRW6VgwuslMsE1MSQQB6FJ+1Zxg71gx4gYzVuvgK+5lp7b3bWEaqig2fCKgI BLQ= X-SBRS: 2.7 X-MesageID: 2143317 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.63,411,1557201600"; d="scan'208";a="2143317" From: Andrew Cooper To: Xen-devel Date: Mon, 24 Jun 2019 11:17:23 +0100 Message-ID: <20190624101723.23291-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190624101723.23291-1-andrew.cooper3@citrix.com> References: <20190624101723.23291-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/2] xen/ubsan: Support for -fsanitise=builtin 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=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This fixes the UBSAN build for GCC 8 and later. The sanitiser checks for passing 0 to the ctz()/clz() builtins. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Julien Grall --- xen/common/ubsan/ubsan.c | 21 +++++++++++++++++++++ xen/common/ubsan/ubsan.h | 9 +++++++++ 2 files changed, 30 insertions(+) diff --git a/xen/common/ubsan/ubsan.c b/xen/common/ubsan/ubsan.c index 50a4e14fac..e75f614fa7 100644 --- a/xen/common/ubsan/ubsan.c +++ b/xen/common/ubsan/ubsan.c @@ -518,3 +518,24 @@ void __ubsan_handle_pointer_overflow(struct pointer_ov= erflow_data *data, =20 ubsan_epilogue(&flags); } + +void __ubsan_handle_invalid_builtin(struct invalid_builtin_data *data) +{ + unsigned long flags; + const char *fn; + + if (suppress_report(&data->location)) + return; + + ubsan_prologue(&data->location, &flags); + + switch (data->kind) { + case kind_ctz: fn =3D "ctz"; break; + case kind_clz: fn =3D "clz"; break; + default: fn =3D ""; break; + } + + pr_err("passing zero to %s(), which is not a valid argument\n", fn); + + ubsan_epilogue(&flags); +} diff --git a/xen/common/ubsan/ubsan.h b/xen/common/ubsan/ubsan.h index 2710cd423e..a3159040fe 100644 --- a/xen/common/ubsan/ubsan.h +++ b/xen/common/ubsan/ubsan.h @@ -84,6 +84,15 @@ struct pointer_overflow_data { struct source_location location; }; =20 +struct invalid_builtin_data { + struct source_location location; + unsigned char kind; +}; +enum { + kind_ctz, + kind_clz, +}; + #if defined(CONFIG_ARCH_SUPPORTS_INT128) && defined(__SIZEOF_INT128__) typedef __int128 s_max; typedef unsigned __int128 u_max; --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel