From patchwork Wed Sep 28 23:48:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 9355357 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 6ECD360756 for ; Wed, 28 Sep 2016 23:51:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 630CF2964D for ; Wed, 28 Sep 2016 23:51:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5735B29651; Wed, 28 Sep 2016 23:51:35 +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, UNPARSEABLE_RELAY 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 2CFF72964D for ; Wed, 28 Sep 2016 23:51:33 +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 1bpObA-0000sF-J2; Wed, 28 Sep 2016 23:49:12 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpOb9-0000s9-14 for xen-devel@lists.xenproject.org; Wed, 28 Sep 2016 23:49:11 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id 88/88-13744-6F65CE75; Wed, 28 Sep 2016 23:49:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRWlGSWpSXmKPExsXSO6nOVfdr2Jt wgysTLS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxfrVfYC84pVzyc8IutgfGMdBcjF4eQQBuT xOM9e9ghnG+MEpMe7mGEcDYySiw//IoZwpnAKDHn9D8gh4ODTcBE4s0qxy5GTg4RAVOJ7RNPs oDUMAvcY5Q4+3MpM0hCWMBW4v7bTawgNouAqsT0zi4WEJtXwE2i6xlIAweHhIC8xLPb9SBhTg F3idZHe8DGCwGV3FvmBxKWEDCUOP1wG+MERr4FjAyrGDWKU4vKUot0DQ31kooy0zNKchMzc3Q NDcz0clOLixPTU3MSk4r1kvNzNzECA4UBCHYwfloWcIhRkoNJSZSX0+dNuBBfUn5KZUZicUZ8 UWlOavEhRhkODiUJ3pmhQDnBotT01Iq0zBxgyMKkJTh4lER420DSvMUFibnFmekQqVOMilLiv C4gCQGQREZpHlwbLE4uMcpKCfMyAh0ixFOQWpSbWYIq/4pRnINRSZj3MMgUnsy8Erjpr4AWMw EtXnriBcjikkSElFQDo9kcpgLJ+Zk6DEVTs9/HKTD6crTkPXSKOnFY8cNKAZ4F9rcbdhwVcC+ YXuBwKkxZ+OP0apHV6/81NEz54HQ47Pt8wwr9xCAvB7bg+V3PTF021xivvyeyK+vGvFMrepda 3F2oZ3C9y2+RxMKFG63eteTFzeo7OsP4zbNo03Lb389Z7/VUZpUcUGIpzkg01GIuKk4EAFMru EyOAgAA X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1475106547!9188256!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 20056 invoked from network); 28 Sep 2016 23:49:09 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-15.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 28 Sep 2016 23:49:09 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8SNn39N002841 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 Sep 2016 23:49:04 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u8SNn2fJ005672 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 Sep 2016 23:49:03 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8SNn1Mx002654; Wed, 28 Sep 2016 23:49:02 GMT Received: from localhost.us.oracle.com (/10.154.161.113) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 28 Sep 2016 16:49:01 -0700 From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, konrad@kernel.org Date: Wed, 28 Sep 2016 19:48:48 -0400 Message-Id: <1475106529-17443-2-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1475106529-17443-1-git-send-email-konrad.wilk@oracle.com> References: <1475106529-17443-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: Andrew Cooper , Ian Jackson , Wei Liu , Jan Beulich , Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v2 1/2] hvmloader: Use MB(x) and GB(x) macros 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 instead of hardcoding values. Signed-off-by: Konrad Rzeszutek Wilk Acked-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Ian Jackson Cc: Wei Liu v2: New submission --- tools/firmware/hvmloader/e820.c | 6 +++--- tools/firmware/hvmloader/pci.c | 8 ++++---- tools/firmware/hvmloader/smbios.c | 5 ++--- tools/firmware/hvmloader/util.h | 3 +++ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tools/firmware/hvmloader/e820.c b/tools/firmware/hvmloader/e820.c index 5541b18..a3683a0 100644 --- a/tools/firmware/hvmloader/e820.c +++ b/tools/firmware/hvmloader/e820.c @@ -82,7 +82,7 @@ void adjust_memory_map(void) /* Modify the existing highmem region if it exists. */ if ( memory_map.map[i].type == E820_RAM && - high_mem_end && map_start == ((uint64_t)1 << 32) ) + high_mem_end && map_start == (uint64_t)GB(4) ) { if ( high_mem_end != map_end ) memory_map.map[i].size = high_mem_end - map_start; @@ -94,7 +94,7 @@ void adjust_memory_map(void) /* If there was no highmem region, just create one. */ if ( high_mem_end ) { - memory_map.map[i].addr = ((uint64_t)1 << 32); + memory_map.map[i].addr = (uint64_t)GB(4); memory_map.map[i].size = ((uint64_t)hvm_info->high_mem_pgend << PAGE_SHIFT) - memory_map.map[i].addr; @@ -234,7 +234,7 @@ int build_e820_table(struct e820entry *e820, } /* Low RAM goes here. Reserve space for special pages. */ - BUG_ON(low_mem_end < (2u << 20)); + BUG_ON(low_mem_end < MB(2)); /* * Construct E820 table according to recorded memory map. diff --git a/tools/firmware/hvmloader/pci.c b/tools/firmware/hvmloader/pci.c index 4eb1a31..416829d 100644 --- a/tools/firmware/hvmloader/pci.c +++ b/tools/firmware/hvmloader/pci.c @@ -59,7 +59,7 @@ static int find_next_rmrr(uint32_t base) { unsigned int i; int next_rmrr = -1; - uint64_t end, min_end = 1ULL << 32; + uint64_t end, min_end = GB(4); for ( i = 0; i < memory_map.nr_map ; i++ ) { @@ -298,7 +298,7 @@ void pci_setup(void) if ( mmio_hole_size ) { - uint64_t max_ram_below_4g = (1ULL << 32) - mmio_hole_size; + uint64_t max_ram_below_4g = GB(4) - mmio_hole_size; if ( max_ram_below_4g > HVM_BELOW_4G_MMIO_START ) { @@ -386,13 +386,13 @@ void pci_setup(void) adjust_memory_map(); high_mem_resource.base = ((uint64_t)hvm_info->high_mem_pgend) << PAGE_SHIFT; - if ( high_mem_resource.base < 1ull << 32 ) + if ( high_mem_resource.base < GB(4) ) { if ( hvm_info->high_mem_pgend != 0 ) printf("WARNING: hvm_info->high_mem_pgend %x" " does not point into high memory!", hvm_info->high_mem_pgend); - high_mem_resource.base = 1ull << 32; + high_mem_resource.base = GB(4); } printf("%sRAM in high memory; setting high_mem resource base to "PRIllx"\n", hvm_info->high_mem_pgend?"":"No ", diff --git a/tools/firmware/hvmloader/smbios.c b/tools/firmware/hvmloader/smbios.c index 210c7b0..d69312e 100644 --- a/tools/firmware/hvmloader/smbios.c +++ b/tools/firmware/hvmloader/smbios.c @@ -239,15 +239,14 @@ get_memsize(void) sz = (uint64_t)hvm_info->low_mem_pgend << PAGE_SHIFT; if ( hvm_info->high_mem_pgend ) - sz += (((uint64_t)hvm_info->high_mem_pgend << PAGE_SHIFT) - - (1ull << 32)); + sz += (((uint64_t)hvm_info->high_mem_pgend << PAGE_SHIFT) - GB(4)); /* * Round up to the nearest MB. The user specifies domU pseudo-physical * memory in megabytes, so not doing this could easily lead to reporting * one less MB than the user specified. */ - return (sz + (1ul << 20) - 1) >> 20; + return (sz + MB(1) - 1) >> 20; } void diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/util.h index 6062f0b..f2abf25 100644 --- a/tools/firmware/hvmloader/util.h +++ b/tools/firmware/hvmloader/util.h @@ -48,6 +48,9 @@ void __bug(char *file, int line) __attribute__((noreturn)); #define max_t(type,x,y) \ ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) +#define MB(_mb) (_mb##ULL << 20) +#define GB(_gb) (_gb##ULL << 30) + static inline int test_bit(unsigned int b, const void *p) { return !!(((const uint8_t *)p)[b>>3] & (1u<<(b&7)));