From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: xen-devel@lists.xenproject.org, konrad@kernel.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>, Jan Beulich <jbeulich@suse.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH v2 1/2] hvmloader: Use MB(x) and GB(x) macros
Date: Wed, 28 Sep 2016 19:48:48 -0400 [thread overview]
Message-ID: <1475106529-17443-2-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1475106529-17443-1-git-send-email-konrad.wilk@oracle.com>
instead of hardcoding values.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
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)));
--
2.4.11
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-09-28 23:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-28 23:48 [PATCH v2] Enhancements to hvmloader for Xen 4.8 Konrad Rzeszutek Wilk
2016-09-28 23:48 ` Konrad Rzeszutek Wilk [this message]
2016-09-29 6:44 ` [PATCH v2 1/2] hvmloader: Use MB(x) and GB(x) macros Jan Beulich
2016-09-28 23:48 ` [PATCH v2 2/2] hvmloader, pci: Don't try to relocate memory if 64-bit BAR is bigger than ~2GB Konrad Rzeszutek Wilk
2016-09-29 7:03 ` Jan Beulich
2016-09-29 9:23 ` Konrad Rzeszutek Wilk
2016-09-29 9:36 ` Jan Beulich
2016-09-29 10:48 ` Wei Liu
2016-09-30 14:55 ` Konrad Rzeszutek Wilk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1475106529-17443-2-git-send-email-konrad.wilk@oracle.com \
--to=konrad.wilk@oracle.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=konrad@kernel.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).