From patchwork Wed Sep 28 12:00:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9353771 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 573046077A for ; Wed, 28 Sep 2016 12:03:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 485C729515 for ; Wed, 28 Sep 2016 12:03:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CA0B29521; Wed, 28 Sep 2016 12:03:11 +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 1529E29515 for ; Wed, 28 Sep 2016 12:03:06 +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 1bpDXV-0005gg-EW; Wed, 28 Sep 2016 12:00:41 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpDXU-0005gY-2t for xen-devel@lists.xenproject.org; Wed, 28 Sep 2016 12:00:40 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 2C/37-27233-7E0BBE75; Wed, 28 Sep 2016 12:00:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEIsWRWlGSWpSXmKPExsXS6fjDS/fphtf hBv+PmFt83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBnX189jLTiZW/Fx6RX2BsZ5cV2MnBxCAnkS O1pWMoHYvAJ2ErN39rOA2BIChhJP319nA7FZBFQlPs18DGazCahLtD3bztrFyMEhImAgce5oU hcjFwezQCOzRMvkC2BzhAVMJaasvswEUsMrICjxd4cwSJgZaPyHk5/YJzByzULIzEKSgbC1JB 7+usUCYWtLLFv4mhmknFlAWmL5Pw6IsInE68NX0JSA2PYSR2+uYlrAyLGKUaM4tagstUjX0Fw vqSgzPaMkNzEzR9fQwFgvN7W4ODE9NScxqVgvOT93EyMw/BiAYAfjy9OehxglOZiURHnDl70O F+JLyk+pzEgszogvKs1JLT7EKMPBoSTBO2s9UE6wKDU9tSItMwcYCTBpCQ4eJRFeWZA0b3FBY m5xZjpE6hSjLsexuTfWMgmx5OXnpUqJ82qDFAmAFGWU5sGNgEXlJUZZKWFeRqCjhHgKUotyM0 tQ5V8xinMwKgnzbgGZwpOZVwK36RXQEUxARyw98QLkiJJEhJRUAyMD5+ObevFr5z6r5aqb+HB B1t0vD1R2zX5/e6nVT+NdbFxtRn2y622UJA+cU046FzHrlkvQ/Taj0gufXLLfNq3+udRwzs2H E/KEzdJ70z41PrxjtZB3besNo+4lU7dJfbW7ndYQ8/1OQY5aeG/GglNqe1QYRE4e/Lxn7wdDl 1Xuh6siHnpYS3oosRRnJBpqMRcVJwIA5uKkeMUCAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1475064035!62510825!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG, UPPERCASE_25_50 X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43585 invoked from network); 28 Sep 2016 12:00:37 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-10.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 28 Sep 2016 12:00:37 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Wed, 28 Sep 2016 06:00:34 -0600 Message-Id: <57EBCCFF020000780011348A@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.1 Date: Wed, 28 Sep 2016 06:00:31 -0600 From: "Jan Beulich" To: "xen-devel" Mime-Version: 1.0 Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Shannon Zhao Subject: [Xen-devel] [PATCH] pub-headers: reduce C99 dependencies 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP For consumers not using (fully) C99-aware compilers, limit the number of places where tweaking of the headers would be necessary: Introduce and use xen_mk_ullong(), allowing its helper macro to be overridden at once. For now don't touch public/io/, which also has a few offenders. The need to include xen.h in hvm/e820.h demonstrates that it is a bad idea to include public headers first thing - arch/x86/hvm/mtrr.c needs adjustment just because of this. Signed-off-by: Jan Beulich Reviewed-by: Julien Grall Acked-by: Wei Liu --- I wonder why all those ARM constants carry the ULL suffix despite only two of them actually exceeding 32 significant bits. pub-headers: reduce C99 dependencies For consumers not using (fully) C99-aware compilers, limit the number of places where tweaking of the headers would be necessary: Introduce and use xen_mk_ullong(), allowing its helper macro to be overridden at once. For now don't touch public/io/, which also has a few offenders. The need to include xen.h in hvm/e820.h demonstrates that it is a bad idea to include public headers first thing - arch/x86/hvm/mtrr.c needs adjustment just because of this. Signed-off-by: Jan Beulich --- I wonder why all those ARM constants carry the ULL suffix despite only two of them actually exceeding 32 significant bits. --- a/xen/arch/x86/hvm/mtrr.c +++ b/xen/arch/x86/hvm/mtrr.c @@ -16,7 +16,6 @@ * this program; If not, see . */ -#include #include #include #include @@ -25,6 +24,7 @@ #include #include #include +#include /* Get page attribute fields (PAn) from PAT MSR. */ #define pat_cr_2_paf(pat_cr,n) ((((uint64_t)pat_cr) >> ((n)<<3)) & 0xff) --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -391,38 +391,38 @@ typedef uint64_t xen_callback_t; */ /* vGIC v2 mappings */ -#define GUEST_GICD_BASE 0x03001000ULL -#define GUEST_GICD_SIZE 0x00001000ULL -#define GUEST_GICC_BASE 0x03002000ULL -#define GUEST_GICC_SIZE 0x00002000ULL +#define GUEST_GICD_BASE xen_mk_ullong(0x03001000) +#define GUEST_GICD_SIZE xen_mk_ullong(0x00001000) +#define GUEST_GICC_BASE xen_mk_ullong(0x03002000) +#define GUEST_GICC_SIZE xen_mk_ullong(0x00002000) /* vGIC v3 mappings */ -#define GUEST_GICV3_GICD_BASE 0x03001000ULL -#define GUEST_GICV3_GICD_SIZE 0x00010000ULL +#define GUEST_GICV3_GICD_BASE xen_mk_ullong(0x03001000) +#define GUEST_GICV3_GICD_SIZE xen_mk_ullong(0x00010000) -#define GUEST_GICV3_RDIST_STRIDE 0x20000ULL +#define GUEST_GICV3_RDIST_STRIDE xen_mk_ullong(0x00020000) #define GUEST_GICV3_RDIST_REGIONS 1 -#define GUEST_GICV3_GICR0_BASE 0x03020000ULL /* vCPU0 - vCPU127 */ -#define GUEST_GICV3_GICR0_SIZE 0x01000000ULL +#define GUEST_GICV3_GICR0_BASE xen_mk_ullong(0x03020000) /* vCPU0..127 */ +#define GUEST_GICV3_GICR0_SIZE xen_mk_ullong(0x01000000) /* * 16MB == 4096 pages reserved for guest to use as a region to map its * grant table in. */ -#define GUEST_GNTTAB_BASE 0x38000000ULL -#define GUEST_GNTTAB_SIZE 0x01000000ULL +#define GUEST_GNTTAB_BASE xen_mk_ullong(0x38000000) +#define GUEST_GNTTAB_SIZE xen_mk_ullong(0x01000000) -#define GUEST_MAGIC_BASE 0x39000000ULL -#define GUEST_MAGIC_SIZE 0x01000000ULL +#define GUEST_MAGIC_BASE xen_mk_ullong(0x39000000) +#define GUEST_MAGIC_SIZE xen_mk_ullong(0x01000000) #define GUEST_RAM_BANKS 2 -#define GUEST_RAM0_BASE 0x40000000ULL /* 3GB of low RAM @ 1GB */ -#define GUEST_RAM0_SIZE 0xc0000000ULL +#define GUEST_RAM0_BASE xen_mk_ullong(0x40000000) /* 3GB of low RAM @ 1GB */ +#define GUEST_RAM0_SIZE xen_mk_ullong(0xc0000000) -#define GUEST_RAM1_BASE 0x0200000000ULL /* 1016GB of RAM @ 8GB */ -#define GUEST_RAM1_SIZE 0xfe00000000ULL +#define GUEST_RAM1_BASE xen_mk_ullong(0x0200000000) /* 1016GB of RAM @ 8GB */ +#define GUEST_RAM1_SIZE xen_mk_ullong(0xfe00000000) #define GUEST_RAM_BASE GUEST_RAM0_BASE /* Lowest RAM address */ /* Largest amount of actual RAM, not including holes */ --- a/xen/include/public/hvm/e820.h +++ b/xen/include/public/hvm/e820.h @@ -23,6 +23,8 @@ #ifndef __XEN_PUBLIC_HVM_E820_H__ #define __XEN_PUBLIC_HVM_E820_H__ +#include "../xen.h" + /* E820 location in HVM virtual address space. */ #define HVM_E820_PAGE 0x00090000 #define HVM_E820_NR_OFFSET 0x000001E8 @@ -30,6 +32,7 @@ #define HVM_BELOW_4G_RAM_END 0xF0000000 #define HVM_BELOW_4G_MMIO_START HVM_BELOW_4G_RAM_END -#define HVM_BELOW_4G_MMIO_LENGTH ((1ULL << 32) - HVM_BELOW_4G_MMIO_START) +#define HVM_BELOW_4G_MMIO_LENGTH ((xen_mk_ullong(1) << 32) - \ + HVM_BELOW_4G_MMIO_START) #endif /* __XEN_PUBLIC_HVM_E820_H__ */ --- a/xen/include/public/memory.h +++ b/xen/include/public/memory.h @@ -486,7 +486,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_mem_access_o * for sharing utilities sitting as "filters" in IO backends * (e.g. memshr + blktap(2)). The IO backend is only exposed * to grant references, and this allows sharing of the grefs */ -#define XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG (1ULL << 62) +#define XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG (xen_mk_ullong(1) << 62) #define XENMEM_SHARING_OP_FIELD_MAKE_GREF(field, val) \ (field) = (XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG | val) --- a/xen/include/public/vcpu.h +++ b/xen/include/public/vcpu.h @@ -88,7 +88,7 @@ struct vcpu_runstate_info { * When activated via VMASST_TYPE_runstate_update_flag, set during * updates in guest memory mapped copy of vcpu_runstate_info. */ -#define XEN_RUNSTATE_UPDATE (1ULL << 63) +#define XEN_RUNSTATE_UPDATE (xen_mk_ullong(1) << 63) /* * Time spent in each RUNSTATE_* (ns). The sum of these times is * guaranteed not to drift from system time. --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -53,17 +53,22 @@ DEFINE_XEN_GUEST_HANDLE(uint64_t); DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); -/* Turn a plain number into a C unsigned (long) constant. */ +/* Turn a plain number into a C unsigned (long (long)) constant. */ #define __xen_mk_uint(x) x ## U #define __xen_mk_ulong(x) x ## UL +#ifndef __xen_mk_ullong +# define __xen_mk_ullong(x) x ## ULL +#endif #define xen_mk_uint(x) __xen_mk_uint(x) #define xen_mk_ulong(x) __xen_mk_ulong(x) +#define xen_mk_ullong(x) __xen_mk_ullong(x) #else /* In assembly code we cannot use C numeric constant suffixes. */ -#define xen_mk_uint(x) x -#define xen_mk_ulong(x) x +#define xen_mk_uint(x) x +#define xen_mk_ulong(x) x +#define xen_mk_ullong(x) x #endif --- a/xen/include/public/xenoprof.h +++ b/xen/include/public/xenoprof.h @@ -68,7 +68,7 @@ struct event_log { }; /* PC value that indicates a special code */ -#define XENOPROF_ESCAPE_CODE (~0ULL) +#define XENOPROF_ESCAPE_CODE (~xen_mk_ullong(0)) /* Transient events for the xenoprof->oprofile cpu buf */ #define XENOPROF_TRACE_BEGIN 1 --- a/xen/arch/x86/hvm/mtrr.c +++ b/xen/arch/x86/hvm/mtrr.c @@ -16,7 +16,6 @@ * this program; If not, see . */ -#include #include #include #include @@ -25,6 +24,7 @@ #include #include #include +#include /* Get page attribute fields (PAn) from PAT MSR. */ #define pat_cr_2_paf(pat_cr,n) ((((uint64_t)pat_cr) >> ((n)<<3)) & 0xff) --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -391,38 +391,38 @@ typedef uint64_t xen_callback_t; */ /* vGIC v2 mappings */ -#define GUEST_GICD_BASE 0x03001000ULL -#define GUEST_GICD_SIZE 0x00001000ULL -#define GUEST_GICC_BASE 0x03002000ULL -#define GUEST_GICC_SIZE 0x00002000ULL +#define GUEST_GICD_BASE xen_mk_ullong(0x03001000) +#define GUEST_GICD_SIZE xen_mk_ullong(0x00001000) +#define GUEST_GICC_BASE xen_mk_ullong(0x03002000) +#define GUEST_GICC_SIZE xen_mk_ullong(0x00002000) /* vGIC v3 mappings */ -#define GUEST_GICV3_GICD_BASE 0x03001000ULL -#define GUEST_GICV3_GICD_SIZE 0x00010000ULL +#define GUEST_GICV3_GICD_BASE xen_mk_ullong(0x03001000) +#define GUEST_GICV3_GICD_SIZE xen_mk_ullong(0x00010000) -#define GUEST_GICV3_RDIST_STRIDE 0x20000ULL +#define GUEST_GICV3_RDIST_STRIDE xen_mk_ullong(0x00020000) #define GUEST_GICV3_RDIST_REGIONS 1 -#define GUEST_GICV3_GICR0_BASE 0x03020000ULL /* vCPU0 - vCPU127 */ -#define GUEST_GICV3_GICR0_SIZE 0x01000000ULL +#define GUEST_GICV3_GICR0_BASE xen_mk_ullong(0x03020000) /* vCPU0..127 */ +#define GUEST_GICV3_GICR0_SIZE xen_mk_ullong(0x01000000) /* * 16MB == 4096 pages reserved for guest to use as a region to map its * grant table in. */ -#define GUEST_GNTTAB_BASE 0x38000000ULL -#define GUEST_GNTTAB_SIZE 0x01000000ULL +#define GUEST_GNTTAB_BASE xen_mk_ullong(0x38000000) +#define GUEST_GNTTAB_SIZE xen_mk_ullong(0x01000000) -#define GUEST_MAGIC_BASE 0x39000000ULL -#define GUEST_MAGIC_SIZE 0x01000000ULL +#define GUEST_MAGIC_BASE xen_mk_ullong(0x39000000) +#define GUEST_MAGIC_SIZE xen_mk_ullong(0x01000000) #define GUEST_RAM_BANKS 2 -#define GUEST_RAM0_BASE 0x40000000ULL /* 3GB of low RAM @ 1GB */ -#define GUEST_RAM0_SIZE 0xc0000000ULL +#define GUEST_RAM0_BASE xen_mk_ullong(0x40000000) /* 3GB of low RAM @ 1GB */ +#define GUEST_RAM0_SIZE xen_mk_ullong(0xc0000000) -#define GUEST_RAM1_BASE 0x0200000000ULL /* 1016GB of RAM @ 8GB */ -#define GUEST_RAM1_SIZE 0xfe00000000ULL +#define GUEST_RAM1_BASE xen_mk_ullong(0x0200000000) /* 1016GB of RAM @ 8GB */ +#define GUEST_RAM1_SIZE xen_mk_ullong(0xfe00000000) #define GUEST_RAM_BASE GUEST_RAM0_BASE /* Lowest RAM address */ /* Largest amount of actual RAM, not including holes */ --- a/xen/include/public/hvm/e820.h +++ b/xen/include/public/hvm/e820.h @@ -23,6 +23,8 @@ #ifndef __XEN_PUBLIC_HVM_E820_H__ #define __XEN_PUBLIC_HVM_E820_H__ +#include "../xen.h" + /* E820 location in HVM virtual address space. */ #define HVM_E820_PAGE 0x00090000 #define HVM_E820_NR_OFFSET 0x000001E8 @@ -30,6 +32,7 @@ #define HVM_BELOW_4G_RAM_END 0xF0000000 #define HVM_BELOW_4G_MMIO_START HVM_BELOW_4G_RAM_END -#define HVM_BELOW_4G_MMIO_LENGTH ((1ULL << 32) - HVM_BELOW_4G_MMIO_START) +#define HVM_BELOW_4G_MMIO_LENGTH ((xen_mk_ullong(1) << 32) - \ + HVM_BELOW_4G_MMIO_START) #endif /* __XEN_PUBLIC_HVM_E820_H__ */ --- a/xen/include/public/memory.h +++ b/xen/include/public/memory.h @@ -486,7 +486,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_mem_access_o * for sharing utilities sitting as "filters" in IO backends * (e.g. memshr + blktap(2)). The IO backend is only exposed * to grant references, and this allows sharing of the grefs */ -#define XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG (1ULL << 62) +#define XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG (xen_mk_ullong(1) << 62) #define XENMEM_SHARING_OP_FIELD_MAKE_GREF(field, val) \ (field) = (XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG | val) --- a/xen/include/public/vcpu.h +++ b/xen/include/public/vcpu.h @@ -88,7 +88,7 @@ struct vcpu_runstate_info { * When activated via VMASST_TYPE_runstate_update_flag, set during * updates in guest memory mapped copy of vcpu_runstate_info. */ -#define XEN_RUNSTATE_UPDATE (1ULL << 63) +#define XEN_RUNSTATE_UPDATE (xen_mk_ullong(1) << 63) /* * Time spent in each RUNSTATE_* (ns). The sum of these times is * guaranteed not to drift from system time. --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -53,17 +53,22 @@ DEFINE_XEN_GUEST_HANDLE(uint64_t); DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); -/* Turn a plain number into a C unsigned (long) constant. */ +/* Turn a plain number into a C unsigned (long (long)) constant. */ #define __xen_mk_uint(x) x ## U #define __xen_mk_ulong(x) x ## UL +#ifndef __xen_mk_ullong +# define __xen_mk_ullong(x) x ## ULL +#endif #define xen_mk_uint(x) __xen_mk_uint(x) #define xen_mk_ulong(x) __xen_mk_ulong(x) +#define xen_mk_ullong(x) __xen_mk_ullong(x) #else /* In assembly code we cannot use C numeric constant suffixes. */ -#define xen_mk_uint(x) x -#define xen_mk_ulong(x) x +#define xen_mk_uint(x) x +#define xen_mk_ulong(x) x +#define xen_mk_ullong(x) x #endif --- a/xen/include/public/xenoprof.h +++ b/xen/include/public/xenoprof.h @@ -68,7 +68,7 @@ struct event_log { }; /* PC value that indicates a special code */ -#define XENOPROF_ESCAPE_CODE (~0ULL) +#define XENOPROF_ESCAPE_CODE (~xen_mk_ullong(0)) /* Transient events for the xenoprof->oprofile cpu buf */ #define XENOPROF_TRACE_BEGIN 1