From patchwork Tue Jun 27 09:33:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9811139 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CE57E603D7 for ; Tue, 27 Jun 2017 09:35:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B6DA27F90 for ; Tue, 27 Jun 2017 09:35:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F885284C7; Tue, 27 Jun 2017 09:35:55 +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=-4.2 required=2.0 tests=BAYES_00, 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 AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8CF9D27F90 for ; Tue, 27 Jun 2017 09:35:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dPmsI-0003zg-Bs; Tue, 27 Jun 2017 09:33:34 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dPmsG-0003zP-AL for xen-devel@lists.xen.org; Tue, 27 Jun 2017 09:33:32 +0000 Received: from [85.158.139.211] by server-16.bemta-5.messagelabs.com id 19/71-01752-B6622595; Tue, 27 Jun 2017 09:33:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBLMWRWlGSWpSXmKPExsVysyfVTTdLLSj S4G+XpcWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmrFlzxe2gje8FZ+vL2RtYFzN3cXIxSEksJlR 4t/1K2wQzmlGiQsTtrB2MXJysAloStz5/IkJxBYRkJa49vkyI0gRs8BzRolJLTPAioQFnCT+L vzODGKzCKhKHPz4ih3E5hWwkOi8cZIRxJYQkJfY1XYRrJ5TwFLiR+sVsHohoJpFc1pYJzByL2 BkWMWoUZxaVJZapGtkrJdUlJmeUZKbmJmja2hgqpebWlycmJ6ak5hUrJecn7uJEejjegYGxh2 MO9r9DjFKcjApifKulgiKFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBa6YKlBMsSk1PrUjLzAEG G0xagoNHSYS37HhgpBBvcUFibnFmOkTqFKOilDhvFUifAEgiozQPrg0W4JcYZaWEeRkZGBiEe ApSi3IzS1DlXzGKczAqCfO+B5nCk5lXAjf9FdBiJqDFLPMCQBaXJCKkpBoYs1nn9DnVbNl427 Pgx6+zcpdO2hxrd95czi7b8EIi1eKU/t94062HKq79fFJzlzl9Ns+cdV4KCucDpUubCz53bZp y1Jopvbr9e+KPetPi9N337tzKX/j81nm1poywqyv988uyzvVqtWqud3507aZDOVv6/4mnZaIe MpRKFzmI29+dwq3dob9PiaU4I9FQi7moOBEAAr5JymsCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-206.messagelabs.com!1498556010!101654428!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15404 invoked from network); 27 Jun 2017 09:33:30 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-206.messagelabs.com with SMTP; 27 Jun 2017 09:33:30 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 21AC81596; Tue, 27 Jun 2017 02:33:30 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 87E583F581; Tue, 27 Jun 2017 02:33:28 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 27 Jun 2017 10:33:20 +0100 Message-Id: <20170627093320.9811-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170627093320.9811-1-julien.grall@arm.com> References: <20170627093320.9811-1-julien.grall@arm.com> Cc: sstabellini@kernel.org, wei.liu2@citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, tim@xen.org, Julien Grall , jbeulich@suse.com Subject: [Xen-devel] [PATCH 2/2] xen/mm: Introduce {G, M}FN_INVALID_INITIALIZER X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The current implementation of {G,M}FN_INVALID cannot be used to initialize global variable because the initializer element is not a constant. Due to a bug in GCC 4.9 and older ([1]), it is not easy to find a common value to initialize a variable and directly passed as an argument. Introduce 2 news define {G,M}FN_INVALID_INITIALIZER to be used for initializing a variable. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64856 Signed-off-by: Julien Grall Acked-by: Tim Deegan (and Ack for the revert too) --- Build tested it with: * ARM: GCC 4.9.4, 5.1, 4.3, 6.1.1, 7.1.0 * x86: Clang 3.5.0, 3.6.0, 3.6.2, 3.8.0, 3.9.0, 4.0.0 With introducing a dummy global variable common/mm.c: mfn_t foo = INVALID_MFN_INITIALIZER --- xen/include/xen/mm.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 0050fba498..251db4ffa1 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -57,6 +57,11 @@ TYPE_SAFE(unsigned long, mfn); #define PRI_mfn "05lx" #define INVALID_MFN _mfn(~0UL) +/* + * To be used for global variable initialization. This workaround a bug + * in GCC < 5.0. + */ +#define INVALID_MFN_INITIALIZER {~0UL} #ifndef mfn_t #define mfn_t /* Grep fodder: mfn_t, _mfn() and mfn_x() are defined above */ @@ -90,6 +95,11 @@ static inline bool_t mfn_eq(mfn_t x, mfn_t y) TYPE_SAFE(unsigned long, gfn); #define PRI_gfn "05lx" #define INVALID_GFN _gfn(~0UL) +/* + * To be used for global variable initialization. This workaround a bug + * in GCC < 5.0 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64856 + */ +#define INVALID_GFN_INITIALIZER { ~0UL } #ifndef gfn_t #define gfn_t /* Grep fodder: gfn_t, _gfn() and gfn_x() are defined above */